Retry cycle is performed one attempt less than expected
ironaimer opened this issue · comments
Environment
-
Elixir & Erlang versions (elixir --version): Erlang/OTP 23, Interactive Elixir (1.10.4)
-
ExAws version
mix deps |grep ex_aws
2.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.
I may be wrong, but that's not how I read it:
attempt
is initially set to1
(request.ex:20
).- An attempt is made.
- If it fails,
attempt_again?
is called. Now in this circumstance:- If
max_attempts
is1
, the >= condition will match and we'll fail. - If
max_attempts
is2
, the >= condition will not match, and we'll go to theelse
block
- If
- 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.