-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor retry machinery to allow the use of exponential backoff #1588
Conversation
70e0cf9
to
b2fb634
Compare
Ooh nice, I like the look of it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, YAY exponential backoff and jitter. I'm all for this.
I've only really checked out the retrier.go
code in detail. I like it. But there's an annoying number of pointy bits in this kind of code. Have you explored pulling in a library for this rather than us rolling our own?
yeah, i looked into this a bit - there weren't any libraries that i really loved, and none as nice as eg. python's tenacity or ruby's retryable. i suspect that it's the kind of thing that gets reimplemented privately a lot, because the libraries out there aren't awesome - QED, that's exactly what i did 😅 |
de5ee5a
to
e3719c8
Compare
430e9e3
to
cb442dd
Compare
// WithJitter enables jitter on the retrier, which will cause all of the retries to wait a random amount of time < 1 second | ||
// The idea here is to avoid thundering herds - retries that are in parallel will happen at slightly different times when | ||
// jitter is enabled, whereas if jitter is disabled, all the retries might happen at the same time, causing further load | ||
// on the system that we're tryung to do something with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: 'trying'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it
cb442dd
to
17c1acc
Compare
🤔 Problem: The retry util we currently use has a couple of issues:
✅ Solution: This PR replaces the existing machinery (encapsulated in the
retry.Do
function and theretry.Config
struct), with a struct calledretry.Retrier
.Retrier
intentionally has a similar user interface toretry.Do
, but it adds:💬 Things to discuss:
retry.Exponential
function means that i can't have a base lower than 1 second, as i convert thetime.Duration
into an integer number of seconds, but if i don't do that, then the math gets all wack becausetime.Duration
s are integer numbers of nanoseconds - eg,math.Pow(2*time.Second, 2) != math.Pow(2, 2) * time.Second
. is there a happy middle ground here? i'm embarrassed to say that my arithmetic skills are failing me here.I've changed the artifact batch creation to use exponential backoff, but should we change other operations to use exponential? if so, which ones?This is no longer true, i'll change things to use expo backoff in another PR.This PR will be most easily reviewed commit-by-commit
Closes PIP-234