trino-client 2.2.5 → 2.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52373d10e6b2a747763c91f89a5f2da08824fa239b97808b6fb50229f0501b6b
4
- data.tar.gz: 15678aba8084b3ed6845c5784d7fcc2d68699ad5f002776d6fd5897206f2bf23
3
+ metadata.gz: 69f501fb237b50a19cab4a4ca36e5702ce0b6852aa4f47c28cc58ee2bf9b0b56
4
+ data.tar.gz: 0505db32b400bd17516b49b7c151c5717a95cd6316f3a0a91258409e483822c3
5
5
  SHA512:
6
- metadata.gz: 83a93c0ed41734746f4e69a0b752c7acb978b143188e4d088ef348632ebb2df040b523eae8243b31ee1a94908d61444591405fa0d5f06cfecb2e5767e6d974d4
7
- data.tar.gz: 32dfdb8fb542c3cd8b7ebe3e01678baa2f2146c21e05a30c185b8a27b84845be96a2a3b57471bb8e667edf9c1a9449354b59e72b9149d4978cd7b8a223a55dc4
6
+ metadata.gz: f31ffb1267de01b418f3a39c244dcf34dc8f3dd2d5d3bff3e15c6dc6b8aef1c701ec70ac46c5b85f08a1de89094e0be0198439083e9a57b337bb72c6c3f549e7
7
+ data.tar.gz: 77aeab61775faadb4cd79f567089cb3cfd25c86e3a6d5469ae82da589ad2b88ca59f5e982c49d9aba3832960dc50c1236246913098bc1422587e80cdebb1e475
data/ChangeLog.md CHANGED
@@ -1,5 +1,15 @@
1
1
  trino-client-ruby
2
2
  ====
3
+ ## 2.2.6
4
+ - fix: improve POST retry tests and document idempotency assumption ([#159](https://github.com/treasure-data/trino-client-ruby/issues/159)) [[e64c2a9](https://github.com/treasure-data/trino-client-ruby/commit/e64c2a9)]
5
+ - Add retry to POST /v1/statement ([#157](https://github.com/treasure-data/trino-client-ruby/issues/157)) [[64a5c66](https://github.com/treasure-data/trino-client-ruby/commit/64a5c66)]
6
+ - Update psych requirement from ~> 3 to ~> 5 ([#140](https://github.com/treasure-data/trino-client-ruby/issues/140)) [[eeb3333](https://github.com/treasure-data/trino-client-ruby/commit/eeb3333)]
7
+ - Update dependabot.yaml to change the update interval from weekly to monthly and set commit message prefix to "chore". [[2fde3f2](https://github.com/treasure-data/trino-client-ruby/commit/2fde3f2)]
8
+ - Minor fix [[db03c07](https://github.com/treasure-data/trino-client-ruby/commit/db03c07)]
9
+ - Update addressable requirement from ~> 2.8.1 to ~> 2.9.0 [[1a56064](https://github.com/treasure-data/trino-client-ruby/commit/1a56064)]
10
+ - Update README.md for release instructions [skip ci] [[dda6a06](https://github.com/treasure-data/trino-client-ruby/commit/dda6a06)]
11
+ - v2.2.5 [[12ce8e8](https://github.com/treasure-data/trino-client-ruby/commit/12ce8e8)]
12
+
3
13
  ## 2.2.5
4
14
  - Merge pull request [#155](https://github.com/treasure-data/trino-client-ruby/issues/155) from murakami-ta/add-http-debug-logger-option [[143a801](https://github.com/treasure-data/trino-client-ruby/commit/143a801)]
5
15
  - Fix http_debug_logger test to work with both Faraday 1 and 2 [[0976be7](https://github.com/treasure-data/trino-client-ruby/commit/0976be7)]
data/README.md CHANGED
@@ -126,20 +126,17 @@ See [RDoc](http://www.rubydoc.info/gems/presto-client/) for the full documentati
126
126
 
127
127
  ### Releasing a new version
128
128
 
129
- 1. First update `lib/trino/client/version.rb` to the next version.
130
- 2. Run the following command which will update `ChangeLog.md` file automatically.
129
+ 1. Run the following command which will prompt for the new version, update `lib/trino/client/version.rb`, and generate/let you edit `ChangeLog.md`.
131
130
  ```
132
131
  $ ruby release.rb
133
132
  ```
134
133
 
135
- 3. Create tag
134
+ 2. Commit and tag
136
135
  ```
137
136
  $ git commit -am "vX.Y.Z"
138
137
  $ git tag "vX.Y.Z"
139
- % git push --tags
138
+ $ git push origin master
139
+ $ git push --tags
140
140
  ```
141
141
 
142
- 4. Push package by the following command which will build and push `trino-client-X.Y.Z.gem` and `trino-client-ruby-X.Y.Z.gem` automatically.
143
- ```
144
- $ ruby publish.rb
145
- ```
142
+ Pushing a `v*` tag triggers the GitHub Actions publisher workflow, which automatically builds and publishes the gem to RubyGems.org.
@@ -26,6 +26,8 @@ module Trino::Client
26
26
  :max_nesting => false
27
27
  }
28
28
 
29
+ RETRYABLE_STATUSES = [502, 503, 504]
30
+
29
31
  def initialize(faraday, query, options, next_uri=nil)
30
32
  @faraday = faraday
31
33
 
@@ -66,16 +68,31 @@ module Trino::Client
66
68
 
67
69
  def post_query_request!
68
70
  uri = "/v1/statement"
69
- response = @faraday.post do |req|
70
- req.url uri
71
+ response = with_retry_loop do
72
+ begin
73
+ r = @faraday.post do |req|
74
+ req.url uri
71
75
 
72
- req.body = @query
73
- init_request(req)
74
- end
76
+ req.body = @query
77
+ init_request(req)
78
+ end
79
+ rescue Faraday::TimeoutError, Faraday::ConnectionFailed
80
+ # POST /v1/statement is not idempotent; retrying transport-level errors
81
+ # (timeouts/connection failures) can submit duplicate queries. This is
82
+ # intentional under the assumption the failure happened before Trino
83
+ # received the request (e.g. rejected by a load balancer upstream).
84
+ throw :retry_with_backoff
85
+ rescue => e
86
+ exception! e
87
+ end
75
88
 
76
- # TODO error handling
77
- if response.status != 200
78
- exception! TrinoHttpError.new(response.status, "Failed to start query: #{response.body} (#{response.status})")
89
+ if r.status == 200
90
+ r
91
+ elsif RETRYABLE_STATUSES.include?(r.status)
92
+ throw :retry_with_backoff
93
+ else
94
+ exception! TrinoHttpError.new(r.status, "Failed to start query: #{r.body} (#{r.status})")
95
+ end
79
96
  end
80
97
 
81
98
  @results_headers = response.headers
@@ -189,31 +206,12 @@ module Trino::Client
189
206
 
190
207
  private :parse_body
191
208
 
192
- def faraday_get_with_retry(uri, &block)
209
+ def with_retry_loop
193
210
  start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
194
211
  attempts = 0
195
212
 
196
213
  loop do
197
- begin
198
- response = @faraday.get(uri)
199
- rescue Faraday::TimeoutError, Faraday::ConnectionFailed
200
- # temporally error to retry
201
- response = nil
202
- rescue => e
203
- exception! e
204
- end
205
-
206
- if response
207
- if response.status == 200 && !response.body.to_s.empty?
208
- return response
209
- end
210
-
211
- # retry if 502, 503, 504 according to the trino protocol
212
- unless [502, 503, 504].include?(response.status)
213
- # deterministic error
214
- exception! TrinoHttpError.new(response.status, "Trino API error at #{uri} returned #{response.status}: #{response.body}")
215
- end
216
- end
214
+ catch(:retry_with_backoff) { return yield }
217
215
 
218
216
  raise_if_timeout!
219
217
 
@@ -226,6 +224,28 @@ module Trino::Client
226
224
  exception! TrinoHttpError.new(408, "Trino API error due to timeout")
227
225
  end
228
226
 
227
+ private :with_retry_loop
228
+
229
+ def faraday_get_with_retry(uri)
230
+ with_retry_loop do
231
+ begin
232
+ response = @faraday.get(uri)
233
+ rescue Faraday::TimeoutError, Faraday::ConnectionFailed
234
+ throw :retry_with_backoff
235
+ rescue => e
236
+ exception! e
237
+ end
238
+
239
+ if response.status == 200 && !response.body.to_s.empty?
240
+ response
241
+ elsif RETRYABLE_STATUSES.include?(response.status)
242
+ throw :retry_with_backoff
243
+ else
244
+ exception! TrinoHttpError.new(response.status, "Trino API error at #{uri} returned #{response.status}: #{response.body}")
245
+ end
246
+ end
247
+ end
248
+
229
249
  def raise_if_timeout!
230
250
  if @started_at
231
251
  return if finished?
@@ -15,6 +15,6 @@
15
15
  #
16
16
  module Trino
17
17
  module Client
18
- VERSION = "2.2.5"
18
+ VERSION = "2.2.6"
19
19
  end
20
20
  end
data/trino-client.gemspec CHANGED
@@ -29,8 +29,8 @@ Gem::Specification.new do |gem|
29
29
  gem.add_development_dependency "rake", [">= 0.9.2", "< 14.0"]
30
30
  gem.add_development_dependency "rspec", "~> 3.13.0"
31
31
  gem.add_development_dependency "webmock", ["~> 3.0"]
32
- gem.add_development_dependency "addressable", "~> 2.8.1" # 2.5.0 doesn't support Ruby 1.9.3
32
+ gem.add_development_dependency "addressable", "~> 2.9.0"
33
33
  gem.add_development_dependency "simplecov", "~> 0.22.0"
34
34
  gem.add_development_dependency "standard", "~> 1.54.0"
35
- gem.add_development_dependency "psych", "~> 3"
35
+ gem.add_development_dependency "psych", "~> 5"
36
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trino-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.5
4
+ version: 2.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-27 00:00:00.000000000 Z
11
+ date: 2026-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -126,14 +126,14 @@ dependencies:
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: 2.8.1
129
+ version: 2.9.0
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: 2.8.1
136
+ version: 2.9.0
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: simplecov
139
139
  requirement: !ruby/object:Gem::Requirement
@@ -168,14 +168,14 @@ dependencies:
168
168
  requirements:
169
169
  - - "~>"
170
170
  - !ruby/object:Gem::Version
171
- version: '3'
171
+ version: '5'
172
172
  type: :development
173
173
  prerelease: false
174
174
  version_requirements: !ruby/object:Gem::Requirement
175
175
  requirements:
176
176
  - - "~>"
177
177
  - !ruby/object:Gem::Version
178
- version: '3'
178
+ version: '5'
179
179
  description: Trino client library
180
180
  email:
181
181
  - sf@treasure-data.com