Skip to content

Commit

Permalink
Fix a timing issue in the waiters retry delay calculation
Browse files Browse the repository at this point in the history
Subtracting `minDelay` from `remainingTime` results in the waiter
exiting before the user's desired max wait time. This is especially
apparent in models that use a `minDelay` value that is larger than the
default 2 seconds. For example, AWS EC2 uses 15 seconds, so it would
exit the waiter a full 15 seconds before the desired max wait time.
  • Loading branch information
jdisanti authored and kstich committed May 2, 2024
1 parent 4db4374 commit 4fb0fe2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions docs/source-1.0/spec/waiters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ exponential backoff with jitter through the following algorithm:
delay = random(minDelay, delay)
if remainingTime - delay <= minDelay:
delay = remainingTime - minDelay
delay = remainingTime
If the computed ``delay`` subtracted from ``remainingTime`` is less than
or equal to ``minDelay``, then set ``delay`` to ``remainingTime`` minus
``minDelay`` and perform one last retry. This prevents a waiter from waiting
needlessly only to exceed ``maxWaitTime`` before issuing a final request.
or equal to ``minDelay``, then set ``delay`` to ``remainingTime`` and
perform one last retry. This prevents a waiter from waiting needlessly
only to exceed ``maxWaitTime`` before issuing a final request.

Using the default ``minDelay`` of 2, the default ``maxDelay`` of 120, a caller
provided ``maxWaitTime`` of 300 (5 minutes), and assuming that requests
Expand Down
12 changes: 6 additions & 6 deletions docs/source-2.0/additional-specs/waiters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ exponential backoff with jitter through the following algorithm:
delay = random(minDelay, delay)
if remainingTime - delay <= minDelay:
delay = remainingTime - minDelay
delay = remainingTime
If the computed ``delay`` subtracted from ``remainingTime`` is less than
or equal to ``minDelay``, then set ``delay`` to ``remainingTime`` minus
``minDelay`` and perform one last retry. This prevents a waiter from waiting
needlessly only to exceed ``maxWaitTime`` before issuing a final request.
or equal to ``minDelay``, then set ``delay`` to ``remainingTime`` and
perform one last retry. This prevents a waiter from waiting needlessly
only to exceed ``maxWaitTime`` before issuing a final request.

Using the default ``minDelay`` of 2, the default ``maxDelay`` of 120, a caller
provided ``maxWaitTime`` of 300 (5 minutes), and assuming that requests
Expand Down Expand Up @@ -259,8 +259,8 @@ follows:
- 296
- 4
* - 13 (last attempt)
- 2
- 298
- 4
- 300
- N/A

.. note::
Expand Down

0 comments on commit 4fb0fe2

Please sign in to comment.