active_record_postgresql_xverify 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +60 -0
- data/.rubocop.yml +3 -2
- data/Appraisals +8 -5
- data/README.md +10 -2
- data/active_record_postgresql_xverify.gemspec +5 -2
- data/docker-compose.yml +1 -1
- data/gemfiles/{ar42.gemfile → ar60.gemfile} +1 -2
- data/gemfiles/ar61.gemfile +7 -0
- data/lib/active_record_postgresql_xverify/error_handler.rb +1 -1
- data/lib/active_record_postgresql_xverify/verifier.rb +8 -8
- data/lib/active_record_postgresql_xverify/version.rb +1 -1
- data/seq.wsd +38 -0
- metadata +41 -12
- data/.travis.yml +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14508fac6c2dafcea7f28a85979929fab7fd4ed92bbe2faed319bacfed708b4e
|
4
|
+
data.tar.gz: fc881cbfe9d04d83419ff6c8a23a04504cc893619aa59545c858e3d425e89e49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16542154cd66be756831f254a6f96fdb77167bace1dee5e13cf19573ffb9c2151188faff809a0431350c1064f8a095d168d526fa8b58c936458618fe11f1fea7
|
7
|
+
data.tar.gz: a6bce580d15a2f0085434234094b01879763a0bf4651899a9b004b4388b4a557431ca8995727861bb3ebc0e0036ad2eb89397ad65b4e8e525c4ac78a4a6aff22
|
@@ -0,0 +1,60 @@
|
|
1
|
+
name: test
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
pull_request:
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
fail-fast: false
|
12
|
+
matrix:
|
13
|
+
ruby:
|
14
|
+
- 2.4
|
15
|
+
- 2.5
|
16
|
+
- 2.6
|
17
|
+
- 2.7
|
18
|
+
- 3.0
|
19
|
+
gemfile:
|
20
|
+
- gemfiles/ar50.gemfile
|
21
|
+
- gemfiles/ar51.gemfile
|
22
|
+
- gemfiles/ar52.gemfile
|
23
|
+
- gemfiles/ar60.gemfile
|
24
|
+
- gemfiles/ar61.gemfile
|
25
|
+
exclude:
|
26
|
+
- ruby: 2.4
|
27
|
+
gemfile: gemfiles/ar60.gemfile
|
28
|
+
- ruby: 2.4
|
29
|
+
gemfile: gemfiles/ar61.gemfile
|
30
|
+
- ruby: 3.0
|
31
|
+
gemfile: gemfiles/ar50.gemfile
|
32
|
+
- ruby: 3.0
|
33
|
+
gemfile: gemfiles/ar51.gemfile
|
34
|
+
- ruby: 3.0
|
35
|
+
gemfile: gemfiles/ar52.gemfile
|
36
|
+
|
37
|
+
steps:
|
38
|
+
- uses: actions/checkout@v2
|
39
|
+
- uses: ruby/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
ruby-version: ${{ matrix.ruby }}
|
42
|
+
- uses: actions/cache@v2
|
43
|
+
with:
|
44
|
+
path: gemfiles/vendor/bundle
|
45
|
+
key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.gemfile }}
|
46
|
+
restore-keys: |
|
47
|
+
${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.gemfile }}
|
48
|
+
- name: Setup dependencies
|
49
|
+
run: |
|
50
|
+
for i in {1..60}; do docker-compose up -d && break; sleep 1; done
|
51
|
+
bundle config path vendor/bundle
|
52
|
+
bundle install --jobs 4 --retry 3
|
53
|
+
function pg_ping { PGPASSWORD=postgres pg_isready -U postgres -h 127.0.0.1 -p 12345 >/dev/null 2>/dev/null; }
|
54
|
+
for i in {1..60}; do pg_ping && break; sleep 1; done
|
55
|
+
env:
|
56
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
57
|
+
- name: Run tests
|
58
|
+
run: bundle exec rake
|
59
|
+
env:
|
60
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
data/.rubocop.yml
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
AllCops:
|
2
2
|
Exclude:
|
3
3
|
- 'gemfiles/**/*'
|
4
|
-
TargetRubyVersion: 2.
|
4
|
+
TargetRubyVersion: 2.4
|
5
|
+
NewCops: enable
|
5
6
|
Metrics/BlockLength:
|
6
7
|
Enabled: false
|
7
8
|
Metrics/LineLength:
|
8
9
|
Enabled: false
|
9
10
|
Metrics/MethodLength:
|
10
11
|
Enabled: false
|
11
|
-
Naming/
|
12
|
+
Naming/MethodParameterName:
|
12
13
|
Enabled: false
|
13
14
|
Style/Documentation:
|
14
15
|
Enabled: false
|
data/Appraisals
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
appraise 'ar42' do
|
4
|
-
gem 'activerecord', '~> 4.2.10'
|
5
|
-
gem 'pg', '~> 0.15'
|
6
|
-
end
|
7
|
-
|
8
3
|
appraise 'ar50' do
|
9
4
|
gem 'activerecord', '~> 5.0.7'
|
10
5
|
end
|
@@ -16,3 +11,11 @@ end
|
|
16
11
|
appraise 'ar52' do
|
17
12
|
gem 'activerecord', '~> 5.2.1'
|
18
13
|
end
|
14
|
+
|
15
|
+
appraise 'ar60' do
|
16
|
+
gem 'activerecord', '~> 6.0.1'
|
17
|
+
end
|
18
|
+
|
19
|
+
appraise 'ar61' do
|
20
|
+
gem 'activerecord', '~> 6.1.0'
|
21
|
+
end
|
data/README.md
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
# active_record_postgresql_xverify
|
2
2
|
|
3
|
-
It is a library
|
3
|
+
It is a library to solve Amazon RDS failover problems.
|
4
|
+
|
5
|
+
cf. https://github.com/brianmario/mysql2/issues/948
|
6
|
+
|
7
|
+
**Note: This library does not retry queries. Just reconnect.**
|
4
8
|
|
5
9
|
[![Gem Version](https://badge.fury.io/rb/active_record_postgresql_xverify.svg)](http://badge.fury.io/rb/active_record_postgresql_xverify)
|
6
|
-
[![Build Status](https://
|
10
|
+
[![Build Status](https://github.com/winebarrel/active_record_postgresql_xverify/workflows/test/badge.svg?branch=master)](https://github.com/winebarrel/active_record_postgresql_xverify/actions)
|
11
|
+
|
12
|
+
## How it works
|
13
|
+
|
14
|
+
![](https://user-images.githubusercontent.com/117768/59006968-7ce27f80-885f-11e9-9c4a-a71ecb679c9c.png)
|
7
15
|
|
8
16
|
## Installation
|
9
17
|
|
@@ -23,12 +23,15 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.bindir = 'exe'
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
25
|
spec.require_paths = ['lib']
|
26
|
+
spec.required_ruby_version = '>= 2.4'
|
26
27
|
|
27
|
-
spec.add_dependency 'activerecord'
|
28
|
+
spec.add_dependency 'activerecord', '>= 5'
|
28
29
|
spec.add_dependency 'pg'
|
29
30
|
spec.add_development_dependency 'appraisal'
|
30
31
|
spec.add_development_dependency 'bundler'
|
31
32
|
spec.add_development_dependency 'rake'
|
32
33
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
|
-
spec.add_development_dependency 'rubocop'
|
34
|
+
spec.add_development_dependency 'rubocop', '>= 1.8.0'
|
35
|
+
spec.add_development_dependency 'rubocop-rake'
|
36
|
+
spec.add_development_dependency 'rubocop-rspec'
|
34
37
|
end
|
data/docker-compose.yml
CHANGED
@@ -5,14 +5,14 @@ module ActiveRecordPostgresqlXverify
|
|
5
5
|
def active?
|
6
6
|
if _extend_verify?
|
7
7
|
is_active = begin
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
verifier = ActiveRecordPostgresqlXverify.verify
|
9
|
+
verifier.call(@connection)
|
10
|
+
rescue StandardError => e
|
11
|
+
ActiveRecordPostgresqlXverify.logger.warn("Connection verification failed: #{_build_verify_error_message(e)}")
|
12
|
+
false
|
13
|
+
ensure
|
14
|
+
Thread.current[ActiveRecordPostgresqlXverify::EXTEND_VERIFY_FLAG] = false
|
15
|
+
end
|
16
16
|
|
17
17
|
unless is_active
|
18
18
|
ActiveRecordPostgresqlXverify.logger.info(
|
data/seq.wsd
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
@startuml{seq.png}
|
2
|
+
|
3
|
+
actor Client
|
4
|
+
participant Rails
|
5
|
+
participant "Connection pool" as cp
|
6
|
+
participant "<size:10>active_recode_postgresql_xverify</size>" as arsx
|
7
|
+
participant PostgreSQL
|
8
|
+
|
9
|
+
Client -> Rails : Request
|
10
|
+
activate Rails
|
11
|
+
Rails -> PostgreSQL : Query
|
12
|
+
activate PostgreSQL
|
13
|
+
group neg
|
14
|
+
Rails <-- PostgreSQL : <font color=red>PG::ReadOnlySqlTransaction</font>
|
15
|
+
deactivate PostgreSQL
|
16
|
+
Client <-- Rails : <font color=red>Error</font>
|
17
|
+
deactivate Rails
|
18
|
+
end
|
19
|
+
|
20
|
+
Client -> Rails : Request
|
21
|
+
activate Rails
|
22
|
+
Rails -> cp : checkout
|
23
|
+
activate cp
|
24
|
+
cp -> arsx : active?
|
25
|
+
activate arsx
|
26
|
+
arsx -> PostgreSQL : Fetch "transaction_read_only"
|
27
|
+
activate PostgreSQL
|
28
|
+
arsx <-- PostgreSQL : "on"
|
29
|
+
deactivate PostgreSQL
|
30
|
+
cp <-- arsx : false
|
31
|
+
deactivate arsx
|
32
|
+
cp --> PostgreSQL : reconnect!
|
33
|
+
activate PostgreSQL
|
34
|
+
deactivate PostgreSQL
|
35
|
+
Rails <-- cp : Connection
|
36
|
+
deactivate cp
|
37
|
+
|
38
|
+
@enduml
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_postgresql_xverify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- winebarrel
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pg
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,6 +96,34 @@ dependencies:
|
|
96
96
|
version: '3.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.8.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.8.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop-rspec
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
100
128
|
requirements:
|
101
129
|
- - ">="
|
@@ -116,10 +144,10 @@ executables: []
|
|
116
144
|
extensions: []
|
117
145
|
extra_rdoc_files: []
|
118
146
|
files:
|
147
|
+
- ".github/workflows/test.yml"
|
119
148
|
- ".gitignore"
|
120
149
|
- ".rspec"
|
121
150
|
- ".rubocop.yml"
|
122
|
-
- ".travis.yml"
|
123
151
|
- Appraisals
|
124
152
|
- Gemfile
|
125
153
|
- LICENSE.txt
|
@@ -130,10 +158,11 @@ files:
|
|
130
158
|
- bin/setup
|
131
159
|
- docker-compose.yml
|
132
160
|
- gemfiles/.bundle/config
|
133
|
-
- gemfiles/ar42.gemfile
|
134
161
|
- gemfiles/ar50.gemfile
|
135
162
|
- gemfiles/ar51.gemfile
|
136
163
|
- gemfiles/ar52.gemfile
|
164
|
+
- gemfiles/ar60.gemfile
|
165
|
+
- gemfiles/ar61.gemfile
|
137
166
|
- lib/active_record_postgresql_xverify.rb
|
138
167
|
- lib/active_record_postgresql_xverify/config.rb
|
139
168
|
- lib/active_record_postgresql_xverify/constants.rb
|
@@ -143,11 +172,12 @@ files:
|
|
143
172
|
- lib/active_record_postgresql_xverify/verifier.rb
|
144
173
|
- lib/active_record_postgresql_xverify/verifiers/aurora_master.rb
|
145
174
|
- lib/active_record_postgresql_xverify/version.rb
|
175
|
+
- seq.wsd
|
146
176
|
homepage: https://github.com/winebarrel/active_record_postgresql_xverify
|
147
177
|
licenses:
|
148
178
|
- MIT
|
149
179
|
metadata: {}
|
150
|
-
post_install_message:
|
180
|
+
post_install_message:
|
151
181
|
rdoc_options: []
|
152
182
|
require_paths:
|
153
183
|
- lib
|
@@ -155,16 +185,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
185
|
requirements:
|
156
186
|
- - ">="
|
157
187
|
- !ruby/object:Gem::Version
|
158
|
-
version: '
|
188
|
+
version: '2.4'
|
159
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
190
|
requirements:
|
161
191
|
- - ">="
|
162
192
|
- !ruby/object:Gem::Version
|
163
193
|
version: '0'
|
164
194
|
requirements: []
|
165
|
-
|
166
|
-
|
167
|
-
signing_key:
|
195
|
+
rubygems_version: 3.0.3
|
196
|
+
signing_key:
|
168
197
|
specification_version: 4
|
169
198
|
summary: It is a library that performs extended verification when an error occurs
|
170
199
|
when executing SQL.
|
data/.travis.yml
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
---
|
2
|
-
dist: xenial
|
3
|
-
sudo: required
|
4
|
-
language: ruby
|
5
|
-
cache: bundler
|
6
|
-
rvm:
|
7
|
-
- 2.3.8
|
8
|
-
- 2.4.6
|
9
|
-
- 2.5.3
|
10
|
-
- 2.6.3
|
11
|
-
before_install:
|
12
|
-
- docker-compose up -d
|
13
|
-
- function pg_ping { PGPASSWORD=postgres pg_isready -U postgres -h 127.0.0.1 -p 12345 >/dev/null 2>/dev/null; }
|
14
|
-
- for i in {1..60}; do pg_ping && break; sleep 1; done
|
15
|
-
script:
|
16
|
-
- bundle exec rake
|
17
|
-
gemfile:
|
18
|
-
- gemfiles/ar42.gemfile
|
19
|
-
- gemfiles/ar50.gemfile
|
20
|
-
- gemfiles/ar51.gemfile
|
21
|
-
- gemfiles/ar52.gemfile
|
22
|
-
addons:
|
23
|
-
apt:
|
24
|
-
packages:
|
25
|
-
- postgresql
|