rails_failover 0.5.1 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +42 -0
- data/Gemfile.lock +4 -4
- data/README.md +1 -1
- data/lib/rails_failover/active_record/middleware.rb +7 -5
- data/lib/rails_failover/redis/connector.rb +1 -1
- data/lib/rails_failover/redis/handler.rb +2 -2
- data/lib/rails_failover/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3a3ec0058f66ac60c355117284cc6c3ef9edbde71d74d966e38c2e10d38b828
|
4
|
+
data.tar.gz: dbfbe03fe13a70ecbc32729ce47223e41b4d9c53d6baeb42df296391490b6116
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7283bd61a7804eb4b5e501e03b71343c620e84f3b334665783a99d8c19fb135d5f49bb97d2f537938d4e73427086c7815981eb4c684b7ed3a38befd878014753
|
7
|
+
data.tar.gz: 3856f52865af591c157d29b0613382dd54a4614cc943313f373077db4ab950beaaba953f696faf7298304c283123e0b40ff48d29ea4d8672025ff7d49e778b1f
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.5.6] - 2020-09-14
|
10
|
+
|
11
|
+
- FIX: Iteration and mutation of primaries_down in separate threads (#5)
|
12
|
+
|
13
|
+
Ruby hashes can't be modified whilst they are being iterated over.
|
14
|
+
|
15
|
+
Here, the primaries_down hash is iterated over to check each previously
|
16
|
+
unavailable primary to see if it is now contactable. However, since this
|
17
|
+
hash can be updated in other threads, this iteration isn't safe.
|
18
|
+
|
19
|
+
To prevent this, a copy of the hash is iterated over instead.
|
20
|
+
|
21
|
+
The GIL should not be released during a hash dup [1], but let's not tie
|
22
|
+
ourselves unnecessarily to current MRI behaviour.
|
23
|
+
|
24
|
+
[1]: https://github.com/ruby-concurrency/concurrent-ruby/issues/528
|
25
|
+
|
26
|
+
|
27
|
+
## [0.5.5] - 2020-08-04
|
28
|
+
|
29
|
+
- FIX: Rescue from `Redis::TimeoutError` instead of `Timeout::Error`.
|
30
|
+
|
31
|
+
## [0.5.4] - 2020-07-21
|
32
|
+
|
33
|
+
- FIX: Undefined method on nil class error in forking servers.
|
34
|
+
|
35
|
+
## [0.5.3] - 2020-07-20
|
36
|
+
|
37
|
+
- FIX: Incorrectly rescuing from `PG::ServerError`.
|
38
|
+
|
39
|
+
## [0.5.2] - 2020-06-23
|
40
|
+
|
41
|
+
### Changed
|
42
|
+
- FIX: Only rescue from connection errors.
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rails_failover (0.5.
|
4
|
+
rails_failover (0.5.6)
|
5
5
|
activerecord (~> 6.0)
|
6
6
|
railties (~> 6.0)
|
7
7
|
|
@@ -41,19 +41,19 @@ GEM
|
|
41
41
|
erubi (1.9.0)
|
42
42
|
i18n (1.8.2)
|
43
43
|
concurrent-ruby (~> 1.0)
|
44
|
-
loofah (2.
|
44
|
+
loofah (2.7.0)
|
45
45
|
crass (~> 1.0.2)
|
46
46
|
nokogiri (>= 1.5.9)
|
47
47
|
method_source (1.0.0)
|
48
48
|
mini_portile2 (2.4.0)
|
49
49
|
minitest (5.14.1)
|
50
|
-
nokogiri (1.10.
|
50
|
+
nokogiri (1.10.10)
|
51
51
|
mini_portile2 (~> 2.4.0)
|
52
52
|
parallel (1.19.1)
|
53
53
|
parser (2.7.1.2)
|
54
54
|
ast (~> 2.4.0)
|
55
55
|
pg (1.2.3)
|
56
|
-
rack (2.2.
|
56
|
+
rack (2.2.3)
|
57
57
|
rack-test (1.1.0)
|
58
58
|
rack (>= 1.0, < 3)
|
59
59
|
rails-dom-testing (2.0.3)
|
data/README.md
CHANGED
@@ -3,18 +3,20 @@
|
|
3
3
|
module RailsFailover
|
4
4
|
module ActiveRecord
|
5
5
|
class Interceptor
|
6
|
-
def self.
|
7
|
-
@
|
6
|
+
def self.adapter_errors
|
7
|
+
@adapter_errors ||= begin
|
8
8
|
if defined?(::PG)
|
9
|
-
::PG::
|
9
|
+
[::PG::UnableToSend, ::PG::ConnectionBad]
|
10
10
|
elsif defined?(::Mysql2)
|
11
|
-
::Mysql2::Error
|
11
|
+
[::Mysql2::Error::ConnectionError]
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.handle(request, exception)
|
17
|
-
|
17
|
+
exception = resolve_cause(exception)
|
18
|
+
|
19
|
+
if adapter_errors.any? { |error| exception.is_a?(error) }
|
18
20
|
Handler.instance.verify_primary(request.env[Middleware::WRITING_ROLE_HEADER])
|
19
21
|
end
|
20
22
|
end
|
@@ -63,7 +63,7 @@ module RailsFailover
|
|
63
63
|
|
64
64
|
active_primaries_keys = {}
|
65
65
|
|
66
|
-
primaries_down.each do |key, options|
|
66
|
+
mon_synchronize { primaries_down.dup }.each do |key, options|
|
67
67
|
info = nil
|
68
68
|
options = options.dup
|
69
69
|
|
@@ -163,7 +163,7 @@ module RailsFailover
|
|
163
163
|
@primaries_down[process_pid] = @primaries_down[@ancestor_pid] || {}
|
164
164
|
|
165
165
|
if process_pid != @ancestor_pid
|
166
|
-
@primaries_down.delete(@ancestor_pid)
|
166
|
+
@primaries_down.delete(@ancestor_pid)&.each do |id, options|
|
167
167
|
verify_primary(options)
|
168
168
|
end
|
169
169
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_failover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alan Tan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- ".rspec"
|
50
50
|
- ".rubocop.yml"
|
51
51
|
- ".travis.yml"
|
52
|
+
- CHANGELOG.md
|
52
53
|
- CODE_OF_CONDUCT.md
|
53
54
|
- Gemfile
|
54
55
|
- Gemfile.lock
|