Skip to content

Update retryable errors in unit tests #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

MAX_RETRY_COUNT = 5
RETRYABLE_ERRORS = [
/No nodes available to run query/
/No nodes available to run query/,
/failed: nodes is empty/
Copy link
Collaborator Author

@yuokada yuokada Sep 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g: https://github.com/treasure-data/trino-client-ruby/actions/runs/3148838251/jobs/5119794338

Failures:

  1) Trino::Client::Client tpch q01 with gzip option
     Failure/Error: columns, rows = run_with_retry(@client, q)
     RuntimeError:
       Fail to run query: Query 20220929_052531_00003_zcvyz failed: nodes is empty
     # ./spec/gzip_spec.rb:32:in `block (2 levels) in <top (required)>'

  2) Trino::Client::Client q01
     Failure/Error: columns, rows = run_with_retry(@client, q)
     RuntimeError:
       Fail to run query: Query 20220929_052556_00003_4bg55 failed: nodes is empty
     # ./spec/tpch_query_spec.rb:30:in `block (2 levels) in <top (required)>'

]

def run_with_retry(client, sql)
Expand All @@ -32,7 +33,7 @@ def run_with_retry(client, sql)
return columns, rows
rescue Trino::Client::TrinoQueryError => e
if RETRYABLE_ERRORS.any? { |error| e.message =~ error }
sleep(i)
sleep(2 ** i)
i += 1
next
end
Expand Down