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
Fix garbage collector interval and backoff resets #1663
Fix garbage collector interval and backoff resets #1663
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
@@ -111,6 +111,7 @@ func startGarbageCollectorWithMaxElapsedTime(ctx context.Context, gc GarbageColl | |||
backoffInterval.InitialInterval = interval | |||
backoffInterval.MaxInterval = max(MaxGCInterval, interval) | |||
backoffInterval.MaxElapsedTime = maxElapsedTime | |||
backoffInterval.Reset() |
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.
This is the other issue I discovered during testing. Without this, the initial interval used by the backoff will be the default 500ms
until backoffInterval.Reset()
is called. This is an edge case, but it can cause the wrong initial value to be used if the first iteration of the GC has an error.
type testGC struct{} | ||
// Fake garbage collector that returns a new incremented revision each time | ||
// TxIDBefore is called. | ||
type fakeGC struct { |
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.
I updated the testGC
to be more fake-like so it could be used to test different scenarios. In my case, I need it to intermittently fail and then recover. If you'd prefer a special, more straightforward GC implementation just for the new test, I'm happy to change 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.
I think this is great 👍🏻
I have read the CLA Document and I hereby sign the CLA |
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.
👏🏻 good find, great contribution and excellent PR description and commit history. LGTM!
type testGC struct{} | ||
// Fake garbage collector that returns a new incremented revision each time | ||
// TxIDBefore is called. | ||
type fakeGC struct { |
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.
I think this is great 👍🏻
Fixes #1659
Resets
nextInterval
back to the configured interval whenbackoffInterval.Reset()
is called on a successful garbage collection run.It also fixes a different problem I discovered while writing tests.
backoffInterval.Reset()
must be called after initialization according to these docs:When this is not done, the
InitialInterval
value is ignored, and the default500ms
is used until the first GC iteration completes successfully andbackoffInterval.Reset()
is called. I assume this is unintentional behaviour?I haven't written much Go, so please feel free to nitpick the PR. I'm open to any suggestions. 😅