From aee2e2cd69748df3e26298577cfdb941928457cf Mon Sep 17 00:00:00 2001 From: Karrot Date: Sat, 9 Nov 2024 19:03:42 +0900 Subject: [PATCH 1/2] fix: Retry GET against 502, 503 responses --- lib/trino/client/statement_client.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/trino/client/statement_client.rb b/lib/trino/client/statement_client.rb index 1487af9a..ab31b168 100644 --- a/lib/trino/client/statement_client.rb +++ b/lib/trino/client/statement_client.rb @@ -208,7 +208,8 @@ def faraday_get_with_retry(uri, &block) return response end - if response.status != 503 # retry only if 503 Service Unavailable + # retry if 502, 503, 504 according to the trino protocol + if response.status == 502 || response.status == 503 || response.status == 504 # deterministic error exception! TrinoHttpError.new(response.status, "Trino API error at #{uri} returned #{response.status}: #{response.body}") end From 68d4ef95fa429561dc1d4b1830eb5ea79f7c38e9 Mon Sep 17 00:00:00 2001 From: Karrot Date: Sun, 10 Nov 2024 12:05:03 +0900 Subject: [PATCH 2/2] fix: Appliy PR Review comment (style) --- lib/trino/client/statement_client.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/trino/client/statement_client.rb b/lib/trino/client/statement_client.rb index ab31b168..1f2c94e6 100644 --- a/lib/trino/client/statement_client.rb +++ b/lib/trino/client/statement_client.rb @@ -209,7 +209,7 @@ def faraday_get_with_retry(uri, &block) end # retry if 502, 503, 504 according to the trino protocol - if response.status == 502 || response.status == 503 || response.status == 504 + unless [502, 503, 504].include?(response.status) # deterministic error exception! TrinoHttpError.new(response.status, "Trino API error at #{uri} returned #{response.status}: #{response.body}") end