pgtk 0.30.8 → 0.30.10
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/Gemfile.lock +30 -11
- data/lib/pgtk/retry.rb +14 -9
- data/lib/pgtk/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: eef46168e2daa0ddc6721aac48a99dc20f8aa80f078cfc76a31fa4ec70759af6
|
|
4
|
+
data.tar.gz: 13dc7a6f18fcb34385c3580700e8e192b3bb38daab86f64b85fa64ac3f3dcce0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18489070b6f37d64338982c7ade356881ffe7a6fc01f6cc1b837f2433ed2779a4838388ec60468ec80c3a21342b7f9c19b52bb87792c7bf0dc7011fb7163d9cd
|
|
7
|
+
data.tar.gz: bc115bdd5e53ff555e1e1d383d90f9ecc80d33b282cd57e89b03540a14f35792e718b5f74c64a637c761da7762791edcc9534f49612ebe5984836817c1e1c314
|
data/Gemfile.lock
CHANGED
|
@@ -35,7 +35,7 @@ GEM
|
|
|
35
35
|
tago (~> 0.1)
|
|
36
36
|
ellipsized (0.3.0)
|
|
37
37
|
joined (0.4.0)
|
|
38
|
-
json (2.19.
|
|
38
|
+
json (2.19.4)
|
|
39
39
|
language_server-protocol (3.17.0.5)
|
|
40
40
|
lint_roller (1.1.0)
|
|
41
41
|
logger (1.7.0)
|
|
@@ -52,20 +52,34 @@ GEM
|
|
|
52
52
|
minitest (>= 5.0, < 7)
|
|
53
53
|
ruby-progressbar
|
|
54
54
|
minitest-stub-const (0.6)
|
|
55
|
+
nokogiri (1.19.2-aarch64-linux-gnu)
|
|
56
|
+
racc (~> 1.4)
|
|
57
|
+
nokogiri (1.19.2-aarch64-linux-musl)
|
|
58
|
+
racc (~> 1.4)
|
|
59
|
+
nokogiri (1.19.2-arm-linux-gnu)
|
|
60
|
+
racc (~> 1.4)
|
|
61
|
+
nokogiri (1.19.2-arm-linux-musl)
|
|
62
|
+
racc (~> 1.4)
|
|
55
63
|
nokogiri (1.19.2-arm64-darwin)
|
|
56
64
|
racc (~> 1.4)
|
|
57
|
-
nokogiri (1.19.2-
|
|
65
|
+
nokogiri (1.19.2-x86_64-darwin)
|
|
58
66
|
racc (~> 1.4)
|
|
59
67
|
nokogiri (1.19.2-x86_64-linux-gnu)
|
|
60
68
|
racc (~> 1.4)
|
|
69
|
+
nokogiri (1.19.2-x86_64-linux-musl)
|
|
70
|
+
racc (~> 1.4)
|
|
61
71
|
os (1.1.4)
|
|
62
72
|
parallel (2.0.1)
|
|
63
73
|
parser (3.3.11.1)
|
|
64
74
|
ast (~> 2.4.1)
|
|
65
75
|
racc
|
|
76
|
+
pg (1.6.3)
|
|
77
|
+
pg (1.6.3-aarch64-linux)
|
|
78
|
+
pg (1.6.3-aarch64-linux-musl)
|
|
66
79
|
pg (1.6.3-arm64-darwin)
|
|
67
|
-
pg (1.6.3-
|
|
80
|
+
pg (1.6.3-x86_64-darwin)
|
|
68
81
|
pg (1.6.3-x86_64-linux)
|
|
82
|
+
pg (1.6.3-x86_64-linux-musl)
|
|
69
83
|
prism (1.9.0)
|
|
70
84
|
qbash (0.8.2)
|
|
71
85
|
backtrace (> 0)
|
|
@@ -75,7 +89,7 @@ GEM
|
|
|
75
89
|
racc (1.8.1)
|
|
76
90
|
rack (3.2.6)
|
|
77
91
|
rainbow (3.1.1)
|
|
78
|
-
rake (13.
|
|
92
|
+
rake (13.4.2)
|
|
79
93
|
random-port (0.8.2)
|
|
80
94
|
tago (~> 0.0)
|
|
81
95
|
regexp_parser (2.12.0)
|
|
@@ -94,7 +108,7 @@ GEM
|
|
|
94
108
|
rubocop-ast (1.49.1)
|
|
95
109
|
parser (>= 3.3.7.2)
|
|
96
110
|
prism (~> 1.7)
|
|
97
|
-
rubocop-elegant (0.0.
|
|
111
|
+
rubocop-elegant (0.0.18)
|
|
98
112
|
lint_roller (~> 1.1)
|
|
99
113
|
rubocop (~> 1.75)
|
|
100
114
|
rubocop-minitest (0.39.1)
|
|
@@ -133,14 +147,19 @@ GEM
|
|
|
133
147
|
nokogiri (~> 1.10)
|
|
134
148
|
rainbow (~> 3.0)
|
|
135
149
|
slop (~> 4.4)
|
|
136
|
-
yard (0.9.
|
|
150
|
+
yard (0.9.43)
|
|
137
151
|
|
|
138
152
|
PLATFORMS
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
153
|
+
aarch64-linux
|
|
154
|
+
aarch64-linux-gnu
|
|
155
|
+
aarch64-linux-musl
|
|
156
|
+
arm-linux-gnu
|
|
157
|
+
arm-linux-musl
|
|
158
|
+
arm64-darwin
|
|
159
|
+
x86_64-darwin
|
|
143
160
|
x86_64-linux
|
|
161
|
+
x86_64-linux-gnu
|
|
162
|
+
x86_64-linux-musl
|
|
144
163
|
|
|
145
164
|
DEPENDENCIES
|
|
146
165
|
minitest (~> 6.0)
|
|
@@ -165,4 +184,4 @@ DEPENDENCIES
|
|
|
165
184
|
yard (~> 0.9)
|
|
166
185
|
|
|
167
186
|
BUNDLED WITH
|
|
168
|
-
2.
|
|
187
|
+
2.6.8
|
data/lib/pgtk/retry.rb
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
# SPDX-License-Identifier: MIT
|
|
5
5
|
|
|
6
6
|
require_relative '../pgtk'
|
|
7
|
+
require_relative 'impatient'
|
|
7
8
|
|
|
8
9
|
# Retry is a decorator for Pool that automatically retries failed SELECT queries.
|
|
9
10
|
# It provides fault tolerance for transient database errors by retrying read-only
|
|
@@ -48,11 +49,17 @@ require_relative '../pgtk'
|
|
|
48
49
|
# Copyright:: Copyright (c) 2019-2026 Yegor Bugayenko
|
|
49
50
|
# License:: MIT
|
|
50
51
|
class Pgtk::Retry
|
|
52
|
+
# Raised when all retry attempts have been exhausted. The original
|
|
53
|
+
# exception that caused the last failure is available via #cause,
|
|
54
|
+
# so its message and stack trace are preserved for debugging.
|
|
55
|
+
class Exhausted < StandardError; end
|
|
56
|
+
|
|
51
57
|
# Constructor.
|
|
52
58
|
#
|
|
53
59
|
# @param [Pgtk::Pool] pool The pool to decorate
|
|
54
60
|
# @param [Integer] attempts Number of attempts to make (default: 3)
|
|
55
61
|
def initialize(pool, attempts: 3)
|
|
62
|
+
raise(ArgumentError, "Attempts must be at least 2, while #{attempts} provided") if attempts < 2
|
|
56
63
|
@pool = pool
|
|
57
64
|
@attempts = attempts
|
|
58
65
|
end
|
|
@@ -78,9 +85,11 @@ class Pgtk::Retry
|
|
|
78
85
|
].join("\n")
|
|
79
86
|
end
|
|
80
87
|
|
|
81
|
-
# Execute a SQL query with automatic retry for SELECT queries.
|
|
82
|
-
#
|
|
83
|
-
#
|
|
88
|
+
# Execute a SQL query with automatic retry for SELECT queries only.
|
|
89
|
+
# Non-SELECT queries fail on the first error, since a failure may occur
|
|
90
|
+
# after the server received the query but before the acknowledgement
|
|
91
|
+
# reached the client, and retrying a non-idempotent write could duplicate
|
|
92
|
+
# it.
|
|
84
93
|
#
|
|
85
94
|
# @param [String] sql The SQL query with params inside (possibly)
|
|
86
95
|
# @return [Array] Result rows
|
|
@@ -89,14 +98,10 @@ class Pgtk::Retry
|
|
|
89
98
|
attempt = 0
|
|
90
99
|
begin
|
|
91
100
|
@pool.exec(sql, *)
|
|
92
|
-
rescue
|
|
93
|
-
attempt += 1
|
|
94
|
-
raise(e) if attempt >= @attempts
|
|
95
|
-
retry
|
|
96
|
-
rescue StandardError => e
|
|
101
|
+
rescue StandardError, Pgtk::Impatient::TooSlow => e
|
|
97
102
|
raise(e) unless query.strip.upcase.start_with?('SELECT')
|
|
98
103
|
attempt += 1
|
|
99
|
-
raise(e) if attempt >= @attempts
|
|
104
|
+
raise(Exhausted, "Retry gave up after #{@attempts} attempts: #{e.message}") if attempt >= @attempts
|
|
100
105
|
retry
|
|
101
106
|
end
|
|
102
107
|
end
|
data/lib/pgtk/version.rb
CHANGED