rails-pg-adapter 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/rails_pg_adapter/patch.rb +45 -16
- data/lib/rails_pg_adapter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b13533de6e67440feaaee7799c583984672793b16b10aee60ca89091cadef545
|
4
|
+
data.tar.gz: e6927d01f1604871d426d8fa894dc400ac3626191c151b034b12771ee68b91ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d60b542abec512d9f5d1567f65d4327e3bc299d8ac740616fbec5aeb394f612698db6c74f5a462640cd96bdb1fb7013ff433f28780ef5cb5c3c0157ca0fa10b4
|
7
|
+
data.tar.gz: 16bbac80afd152b275c451243331318be772c88b9dcce2ddb1eb30be5875556f489b476b55e3b34ec618e6047a00405ca6d9caa73729d83d480101c1849a0ec8
|
data/CHANGELOG.md
CHANGED
@@ -13,6 +13,7 @@ module RailsPgAdapter
|
|
13
13
|
"the database system is starting up",
|
14
14
|
"connection is closed",
|
15
15
|
"could not connect",
|
16
|
+
"is not currently accepting connections",
|
16
17
|
].freeze
|
17
18
|
CONNECTION_ERROR_RE = /#{CONNECTION_ERROR.map { |w| Regexp.escape(w) }.join("|")}/.freeze
|
18
19
|
|
@@ -22,19 +23,45 @@ module RailsPgAdapter
|
|
22
23
|
private
|
23
24
|
|
24
25
|
def exec_cache(*args)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
sleep_times = RailsPgAdapter.configuration.reconnect_with_backoff.dup
|
27
|
+
begin
|
28
|
+
super(*args)
|
29
|
+
rescue ::ActiveRecord::StatementInvalid,
|
30
|
+
::ActiveRecord::ConnectionNotEstablished,
|
31
|
+
::ActiveRecord::NoDatabaseError => e
|
32
|
+
raise unless supported_errors?(e)
|
33
|
+
|
34
|
+
if try_reconnect?(e)
|
35
|
+
sleep_time = sleep_times.shift
|
36
|
+
handle_error(e) unless sleep_time
|
37
|
+
warn("Retry query failed, retrying again in #{sleep_time} sec.")
|
38
|
+
sleep(sleep_time)
|
39
|
+
retry
|
40
|
+
else
|
41
|
+
handle_error(e)
|
42
|
+
end
|
43
|
+
end
|
30
44
|
end
|
31
45
|
|
32
46
|
def exec_no_cache(*args)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
47
|
+
sleep_times = RailsPgAdapter.configuration.reconnect_with_backoff.dup
|
48
|
+
begin
|
49
|
+
super(*args)
|
50
|
+
rescue ::ActiveRecord::StatementInvalid,
|
51
|
+
::ActiveRecord::ConnectionNotEstablished,
|
52
|
+
::ActiveRecord::NoDatabaseError => e
|
53
|
+
raise unless supported_errors?(e)
|
54
|
+
|
55
|
+
if try_reconnect?(e)
|
56
|
+
sleep_time = sleep_times.shift
|
57
|
+
handle_error(e) unless sleep_time
|
58
|
+
warn("Retry query failed, retrying again in #{sleep_time} sec.")
|
59
|
+
sleep(sleep_time)
|
60
|
+
retry
|
61
|
+
else
|
62
|
+
handle_error(e)
|
63
|
+
end
|
64
|
+
end
|
38
65
|
end
|
39
66
|
|
40
67
|
def try_reconnect?(e)
|
@@ -43,7 +70,7 @@ module RailsPgAdapter
|
|
43
70
|
return false unless RailsPgAdapter.reconnect_with_backoff?
|
44
71
|
|
45
72
|
begin
|
46
|
-
|
73
|
+
disconnect_conn!
|
47
74
|
true
|
48
75
|
rescue ::ActiveRecord::ConnectionNotEstablished
|
49
76
|
false
|
@@ -53,11 +80,13 @@ module RailsPgAdapter
|
|
53
80
|
def handle_error(e)
|
54
81
|
if failover_error?(e.message) && RailsPgAdapter.failover_patch?
|
55
82
|
warn("clearing connections due to #{e} - #{e.message}")
|
56
|
-
|
83
|
+
disconnect_conn!
|
57
84
|
raise(e)
|
58
85
|
end
|
59
86
|
|
60
|
-
|
87
|
+
unless missing_column_error?(e.message) && RailsPgAdapter.reset_column_information_patch?
|
88
|
+
return
|
89
|
+
end
|
61
90
|
|
62
91
|
warn("clearing column information due to #{e} - #{e.message}")
|
63
92
|
|
@@ -73,7 +102,7 @@ module RailsPgAdapter
|
|
73
102
|
CONNECTION_SCHEMA_RE.match?(error_message)
|
74
103
|
end
|
75
104
|
|
76
|
-
def
|
105
|
+
def disconnect_conn!
|
77
106
|
disconnect!
|
78
107
|
::ActiveRecord::Base.connection_pool.remove(::ActiveRecord::Base.connection)
|
79
108
|
end
|
@@ -112,12 +141,12 @@ module ActiveRecord
|
|
112
141
|
sleep_times = RailsPgAdapter.configuration.reconnect_with_backoff.dup
|
113
142
|
begin
|
114
143
|
old_new_client_method.bind(self).call(args)
|
115
|
-
rescue ::ActiveRecord::ConnectionNotEstablished => e
|
144
|
+
rescue ::ActiveRecord::ConnectionNotEstablished, ::ActiveRecord::NoDatabaseError => e
|
116
145
|
raise(e) unless RailsPgAdapter.failover_patch? && RailsPgAdapter.reconnect_with_backoff?
|
117
146
|
|
118
147
|
sleep_time = sleep_times.shift
|
119
148
|
raise unless sleep_time
|
120
|
-
warn(
|
149
|
+
warn("Could not establish a connection from new_client, retrying again in #{sleep_time} sec.")
|
121
150
|
sleep(sleep_time)
|
122
151
|
retry
|
123
152
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-pg-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tines Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|