retry: Default MaxBackoff is unintuitive
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 71
- Forks
- 33
- Avg merge
- 6h 53m
- Merged PRs (30d)
- 6
Description
Issue
I would expect the following
func Test(t *testing.T) {
err:=retry.Do(
context.Background(),
func() error {
fmt.Println(time.Now())
return errors.New("some errors")
},
retry.WithInitialBackoff(10*time.Second), retry.WithMultiplier(1), retry.WithMaxAttempts(5),
)
require.NoError(t,err)
}
To output one log line every 10 seconds. However what this actually outputs is
2019-01-16 14:51:16.025567248 -0800 PST m=+0.011095106
2019-01-16 14:51:18.092852159 -0800 PST m=+2.078377531
2019-01-16 14:51:20.357685855 -0800 PST m=+4.343208502
2019-01-16 14:51:22.459165577 -0800 PST m=+6.444685696
2019-01-16 14:51:24.425426817 -0800 PST m=+8.410944570
The reason for this output is the default for MaxBackoff is as follows:
// WithMaxBackoff sets upper limit on backoff duration.
//
// Max backoff of 0 indicates no limit.
//
// If max backoff option is not used, then default value of 2 seconds is used.
While the documentation is good, this caused us to write bugs that affected us in production as I think it's unintuitive.
Proposal
Set the default value of max backoff to 0 instead of 2 seconds, so that the max backoff will be unlimited.
I realize this is a breaking change, but I would believe that most people using this library would expect it to work this way
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at retry.Do and the WithMaxBackoff option described in the issue, then inspect how the default is selected and how backoff timing is tested. Review the unresolved discussion before changing this breaking behavior, and ensure coverage confirms that omitting MaxBackoff allows unlimited backoff while explicit limits remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100