rails-pg-adapter 0.1.12 → 0.1.14
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 +6 -6
- data/lib/rails_pg_adapter/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c7e1211128c3e88c13486773bd6280d15350f06f6c94abbace1b84a8f47b3d9
|
4
|
+
data.tar.gz: 4a010d6eec75b677c9e902d5a054cb0db15072f6954330069f9cf21172068e7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fdb25eda60e57a8393761f5e4832d7d2551e02231b1a9c353bfe56f26d939ba5fbfb2a8404f77f383343a717e8019779228172fbfe9dc4bcca167b6553ae579
|
7
|
+
data.tar.gz: 2837781b10234cebc762f9f7ef61fa33ad08f4a5b0f990987bc9cc910b69115eb21644f8e15a9fb092fa7551c33225848847b18a40f7fe794b56976de19a2261
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [0.1.14] - 2024-02-06
|
2
|
+
|
3
|
+
- Capture the database system is in recovery mode error
|
4
|
+
|
5
|
+
## [0.1.13] - 2023-05-09
|
6
|
+
|
7
|
+
- Use throw_away! instead and capture state of transaction and re-raise accordingly
|
8
|
+
|
1
9
|
## [0.1.12] - 2023-05-08
|
2
10
|
|
3
11
|
- Slight refactor and reduce multiple disconnect attempts
|
@@ -16,6 +16,7 @@ module RailsPgAdapter
|
|
16
16
|
"is not currently accepting connections",
|
17
17
|
"too many connections",
|
18
18
|
"Connection refused",
|
19
|
+
"the database system is in recovery mode"
|
19
20
|
].freeze
|
20
21
|
CONNECTION_ERROR_RE = /#{CONNECTION_ERROR.map { |w| Regexp.escape(w) }.join("|")}/.freeze
|
21
22
|
|
@@ -44,6 +45,7 @@ module RailsPgAdapter
|
|
44
45
|
def exec_cache(*args)
|
45
46
|
sleep_times = ::RailsPgAdapter.configuration.reconnect_with_backoff.dup
|
46
47
|
query, _ = args
|
48
|
+
within_transaction = in_transaction? # capture in_transaction? state before retries
|
47
49
|
begin
|
48
50
|
super(*args)
|
49
51
|
rescue ::ActiveRecord::StatementInvalid,
|
@@ -52,6 +54,7 @@ module RailsPgAdapter
|
|
52
54
|
raise unless ::RailsPgAdapter::Patch.supported_errors?(e)
|
53
55
|
handle_schema_cache_error(e)
|
54
56
|
handle_activerecord_error(e)
|
57
|
+
raise if within_transaction
|
55
58
|
raise unless try_reconnect?(e)
|
56
59
|
|
57
60
|
sleep_time = sleep_times.shift
|
@@ -70,6 +73,7 @@ module RailsPgAdapter
|
|
70
73
|
def exec_no_cache(*args)
|
71
74
|
sleep_times = ::RailsPgAdapter.configuration.reconnect_with_backoff.dup
|
72
75
|
query, _ = args
|
76
|
+
within_transaction = in_transaction? # capture in_transaction? state before retries
|
73
77
|
begin
|
74
78
|
super(*args)
|
75
79
|
rescue ::ActiveRecord::StatementInvalid,
|
@@ -78,6 +82,7 @@ module RailsPgAdapter
|
|
78
82
|
raise unless ::RailsPgAdapter::Patch.supported_errors?(e)
|
79
83
|
handle_schema_cache_error(e)
|
80
84
|
handle_activerecord_error(e)
|
85
|
+
raise if within_transaction
|
81
86
|
raise unless try_reconnect?(e)
|
82
87
|
|
83
88
|
sleep_time = sleep_times.shift
|
@@ -103,7 +108,7 @@ module RailsPgAdapter
|
|
103
108
|
def handle_activerecord_error(e)
|
104
109
|
return unless ::RailsPgAdapter::Patch.failover_error?(e.message)
|
105
110
|
warn("clearing connections due to #{e} - #{e.message}")
|
106
|
-
|
111
|
+
throw_away!
|
107
112
|
end
|
108
113
|
|
109
114
|
def handle_schema_cache_error(e)
|
@@ -114,11 +119,6 @@ module RailsPgAdapter
|
|
114
119
|
raise(e)
|
115
120
|
end
|
116
121
|
|
117
|
-
def disconnect_conn!
|
118
|
-
disconnect!
|
119
|
-
::ActiveRecord::Base.connection_pool.remove(::ActiveRecord::Base.connection)
|
120
|
-
end
|
121
|
-
|
122
122
|
def internal_clear_schema_cache!
|
123
123
|
::ActiveRecord::Base.connection_pool.connections.each { |conn| conn.schema_cache.clear! }
|
124
124
|
::ActiveRecord::Base.descendants.each(&:reset_column_information)
|
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.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tines Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '6'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '7'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '6'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7'
|
27
33
|
description: This project allows you to monkey patch ActiveRecord (PostgreSQL) and
|
28
34
|
auto-heal applications in production when PostgreSQL database fails over or when
|
29
35
|
a cached column (in ActiveRecord schema cache) is removed from the database from
|