Skip to content
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

fix: Retry GET against 502, 503 and 504 responses #129

Merged
merged 2 commits into from
Nov 10, 2024

Conversation

kar0t
Copy link
Contributor

@kar0t kar0t commented Nov 9, 2024

Purpose

Retry GET against 502, 504 responses.

Overview

According to the trino client protocol, it should also retry for 502 and 504. (#128)

https://trino.io/docs/current/develop/client-protocol.html#overview-of-query-processing
If the client request returns an HTTP 502, 503, or 504, that means there was an intermittent problem processing request and the client should try again in 50-100 ms. Trino does not generate those codes by itself, but those can be generated by load balancers in front of Trino.

Checklist

  • Code compiles correctly
  • Created tests which fail without the change (if possible)
  • All tests passing
  • Extended the README / documentation, if necessary

@kar0t kar0t requested a review from a team as a code owner November 9, 2024 10:07
@github-actions github-actions bot added the bug label Nov 9, 2024
@kar0t
Copy link
Contributor Author

kar0t commented Nov 9, 2024

Hi, @yuokada, @ybiquitous maintainers.
Can I ask for a code review of this PR?

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if response.status == 502 || response.status == 503 || response.status == 504
unless [502, 503, 504].include?(response.status)

Copy link
Contributor Author

@kar0t kar0t Nov 10, 2024

Choose a reason for hiding this comment

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

Hi, @exoego Thanks for the review.

Turns out I had modified the error handling code to do the opposite, thanks for letting me know.
I have applied your review comment code.

@exoego exoego merged commit 80f342d into treasure-data:master Nov 10, 2024
8 checks passed
@exoego exoego changed the title fix: Retry GET against 502, 503 responses fix: Retry GET against 502, 503 and 504 responses Nov 10, 2024
@kar0t
Copy link
Contributor Author

kar0t commented Nov 10, 2024

Close #128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants