-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix edge case where racing confuses retry.Times
In the pre-racing v1.0.x world, it made sense to base the retry.Times DeciderFunc result on the execution's `Attempt` field, because `Attempt` as monotonically increasing, and by the time the retry policy's Decider was tested, `Attempt` was guaranteed to be equal to the number of retries. ...But... With v1.1.x which has the racing feature, there are some odd cases where using `Attempt` will create an undesirable result. In particular when you base things on `Attempt`, retry.Times would work differently depending on which of two racing attempts finished first even if in both cases the number of finished attempts was the same. Hence in this commit we introduce a new `AttemptEnds` field to ensure retry.Times decides based on number of total attempts completed, not which one completed first. Before this commit, Example #1 below would not cancel Attempt 1 after Attempt 0 completed, but Example #2 would cancel Attempt 0 after Attempt 1 completed, even though they are both logically equivalent from a retry standpoint. After this commit, both examples behave the same. Example 1: Retry policy uses retry.Times(1) Wave 0: +-----------------------------------------> Attempt 0: +----------------------> Attempt 1: +-----------------------------> Example 2: Retry policy uses retry.Times(1) Wave 0: +-----------------------------------------> Attempt 0: +----------------------------------> Attempt 1: +---------->
- Loading branch information
Showing
6 changed files
with
72 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters