Repository navigation
fix: Spread each bucket's hourly recheck by up to a tenth - #984
Merged
Merged
Conversation
Every bucket comes back an hour after its last reconcile. After a restart the manager reconciles the buckets as it engages their projects, so their rechecks come back an hour later in the same wave, and every hour after unless an event moves one. wait.Jitter spreads each recheck over up to 6 more minutes, so the wave widens instead of repeating.
ecv
approved these changes
Nov 3, 2026
ecv
left a comment
Contributor
There was a problem hiding this comment.
Approve.
wait.Jitter(bucketRecheckInterval, 0.1) returns between 60 and 66 minutes, so buckets reconciled together after a restart stop coming back in the same minute; this is the jitter follow-up from #978.
- Jitter only ever lengthens the interval, so no bucket is rechecked sooner than before, and the stranded-reservation recovery still runs within 66 minutes.
- The test bounds every result to [1h, 1.1h) and requires more than one distinct value across 20 reconciles, so it fails if the jitter is dropped. With continuous random durations a false failure is effectively impossible.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #978.
Every bucket comes back an hour after its last reconcile. After a restart the manager reconciles the buckets as it engages their projects (656 projects in 7 min on 2026-11-03), so their rechecks come back an hour later in the same wave, and every hour after unless an event moves one. Each recheck now waits
wait.Jitter(time.Hour, 0.1): between 60 and 66 minutes, so the wave widens instead of repeating.Corner cases
Test plan
TestAllowanceBucketComesBackAfterTheRecheckIntervalreconciles 20 times: each recheck lies in [1 h, 1.1 h), and they are not all equal. Onmainall 20 are 1h0m0s, so it fails; here it passes.go test ./internal/quota/...passes with envtest 1.37.0.