activerecord-trilogy-failover 0.1.0 → 0.1.1
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/README.md +1 -12
- data/lib/activerecord_trilogy_failover/adapter_patch.rb +5 -0
- data/lib/activerecord_trilogy_failover/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 94046324e20494dbb4a8661272db0f3ccb87d74b4c64f022a5789e5bd8ccb37a
|
|
4
|
+
data.tar.gz: dfa11a6a53365823151dbf92277aa8bfd251578ffdf542aebbd62417f47cde27
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d4c5f81d0f0f665dc2bd9d3f675dd97a426ac94d78fe9e5e5e82a642f17409a92483223996a5e8451a93849ae973f6732f2c1bdfa6ec03e0aae657df92d43fe0
|
|
7
|
+
data.tar.gz: e1d29a266e17c7592b36225ec2aadbdf5b31c90f06f4168ffe73dc2287da6138d36cc4e4a181e082c7f5e120baa361bc50ff6004cd21903c2290e8f92ea22a91
|
data/README.md
CHANGED
|
@@ -22,7 +22,7 @@ This is the correct behavior — writes should not be silently retried.
|
|
|
22
22
|
Add to your Gemfile:
|
|
23
23
|
|
|
24
24
|
```ruby
|
|
25
|
-
gem "activerecord-trilogy-failover"
|
|
25
|
+
gem "activerecord-trilogy-failover"
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
## Usage
|
|
@@ -39,17 +39,6 @@ ActiveRecord::ConnectionAdapters::TrilogyAdapter.prepend(
|
|
|
39
39
|
)
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
### database.yml tuning
|
|
43
|
-
|
|
44
|
-
Rails' built-in retry settings work with this gem:
|
|
45
|
-
|
|
46
|
-
```yaml
|
|
47
|
-
production:
|
|
48
|
-
adapter: trilogy
|
|
49
|
-
connection_retries: 2 # default: 1
|
|
50
|
-
retry_deadline: 5 # seconds, default: none
|
|
51
|
-
```
|
|
52
|
-
|
|
53
42
|
## Compatibility
|
|
54
43
|
|
|
55
44
|
- Ruby >= 3.2
|
|
@@ -10,6 +10,11 @@ module ActiveRecordTrilogyFailover
|
|
|
10
10
|
|
|
11
11
|
def translate_exception(exception, message:, sql:, binds:)
|
|
12
12
|
if read_only_error?(exception)
|
|
13
|
+
# Close the underlying TCP connection to prevent pool reuse.
|
|
14
|
+
# A read-only server still accepts ROLLBACK, SELECT 1, and ping,
|
|
15
|
+
# so without closing, the connection passes verify! and stays in the pool.
|
|
16
|
+
@raw_connection&.close rescue nil
|
|
17
|
+
|
|
13
18
|
return ActiveRecord::ConnectionFailed.new(
|
|
14
19
|
"#{exception.class}: #{exception.message}",
|
|
15
20
|
connection_pool: @pool
|