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

Retry cycle is performed one attempt less than expected #913

Open
ironaimer opened this issue Oct 24, 2022 · 1 comment
Open

Retry cycle is performed one attempt less than expected #913

ironaimer opened this issue Oct 24, 2022 · 1 comment

Comments

@ironaimer
Copy link

Environment

  • Elixir & Erlang versions (elixir --version): Erlang/OTP 23, Interactive Elixir (1.10.4)

  • ExAws version mix deps |grep ex_aws2.0.2

  • HTTP client version. IE for hackney do mix deps | grep hackney 1.16

Current behavior

In case of SQS unavailability retry cycle is executed one iteration less than expected.

It seems strict ">" should be used in attempt_again? in request.ex as "attempt" starts from 1.

  def attempt_again?(attempt, reason, config) do
    if attempt >= config[:retries][:max_attempts] do

So retry cycle is executed (max_attempts - 1) times.

Expected behavior

Retry cycle should be executed max_attempts times.

@bernardd
Copy link
Contributor

I may be wrong, but that's not how I read it:

  • attempt is initially set to 1 (request.ex:20).
  • An attempt is made.
  • If it fails, attempt_again? is called. Now in this circumstance:
    • If max_attempts is 1, the >= condition will match and we'll fail.
    • If max_attempts is 2, the >= condition will not match, and we'll go to the else block
  • At this point, we add 1 to the attempt count, and loop back and try again. So we'll get 2 attempts, as per the config option.

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

No branches or pull requests

2 participants