ex_aws
ex_aws copied to clipboard
Retry cycle is performed one attempt less than expected
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 hackney1.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:
-
attemptis initially set to1(request.ex:20). - An attempt is made.
- If it fails,
attempt_again?is called. Now in this circumstance:- If
max_attemptsis1, the >= condition will match and we'll fail. - If
max_attemptsis2, the >= condition will not match, and we'll go to theelseblock
- If
- At this point, we add 1 to the
attemptcount, and loop back and try again. So we'll get 2 attempts, as per the config option.