Repository navigation
tsdb: fix flaky TestQuerierShouldNotFailIfOOOCompactionOccurs* tests - #19108
Merged
krajorama merged 1 commit intoJul 7, 2026
Merged
Conversation
These tests (and their _AppendV2 variants) waited at most one second for CompactOOOHead to finish after closing the blocking querier. The compaction goroutine only re-checks for pending readers in 500ms intervals (WaitForPendingReadersForOOOChunksAtOrBefore) and still has to garbage collect chunks and truncate the WBL after it notices the close, so the one second window sits right at the failure boundary and regularly times out on slow Windows CI runners. Widen the wait to a minute (require.Eventually returns as soon as the condition holds, so fast runners lose nothing) and move the require calls out of the compaction goroutine: require must not be called from non-test goroutines, and its late FailNow there produced the confusing secondary "compact ooo head: populate block: context canceled" failures when the DB was closed during cleanup after the timeout. Part of prometheus#17941 Signed-off-by: junkerderprovinz <[email protected]>
junkerderprovinz
requested review from
a team,
bwplotka,
codesome,
jesusvazquez and
krajorama
as code owners
July 6, 2026 22:59
4 of 5 tasks
krajorama
approved these changes
Jul 7, 2026
krajorama
left a comment
Member
There was a problem hiding this comment.
Thanks, LGTM, if this works out and you have time consider refactoring to reduce code duplication
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.
Which issue(s) does the PR fix:
Part of #17941 (the remaining
TestQuerierShouldNotFailIfOOOCompactionOccursAfterRetrievingQuerier_AppendV2/_Iterators_AppendV2Windows item; intentionally notFixesso the meta issue stays open).What this PR does:
All six
TestQuerierShouldNotFailIfOOOCompactionOccurs*tests (three indb_test.go, three_AppendV2variants) wait at most one second forCompactOOOHeadto complete after closing the blocking querier:That window sits right at the failure boundary by construction: the compaction goroutine only notices the querier close by polling in 500ms intervals (
WaitForPendingReadersForOOOChunksAtOrBefore, head.go#L1393-L1397), and after it notices it still has to garbage collect chunks and truncate the WBL. On slow Windows CI runners that regularly exceeds one second, producing the failures posted in #17941.Two changes, test-only:
require.Eventuallywindow from 1s to 1min.Eventuallyreturns as soon as the condition holds, so fast runners lose nothing; slow runners stop flaking.requirecalls out of the compaction goroutine.requiremust not be called from non-test goroutines (t.FailNowonly works on the test goroutine). This is also what produced the confusing secondarycompact ooo head: populate block: context canceledfailures in the CI logs: after theEventuallytimeout failed the test, cleanup closed the DB, and the still-running goroutine'srequire.NoErrorfired with the cancellation error. The goroutine now reports its error through a channel and all assertions (including thechunksRemovedmetric check) happen on the test goroutine after completion.The initial
time.Sleep(time.Second)+require.False(asserting compaction blocks while the querier is open) is left untouched — its semantics are unaffected.Verification
Ran natively on Windows (the platform where the flake reproduces): all six tests, three runs each, green (
go test ./tsdb/ -run "TestQuerierShouldNotFailIfOOOCompactionOccurs" -count=3).Release notes for end users (ALL commits must be considered).
Reviewers should verify clarity and quality.