Fix flaky compactor tests: ignore user index update loop errors - #7827
Open
CharlieTLe wants to merge 1 commit into
Open
Fix flaky compactor tests: ignore user index update loop errors#7827CharlieTLe wants to merge 1 commit into
CharlieTLe wants to merge 1 commit into
Conversation
userIndexUpdateLoop runs in the background of every sharding-enabled compactor test and ticks every UsersScanner.UpdateInterval, which prepare() sets to 100ms. Each tick calls ownUser() against the ring, so any tick landing before the lifecycler is ACTIVE, or after it starts LEAVING, logs an error. The tests that assert the compactor's complete log output with ElementsMatch then fail with "elements differ" depending purely on how many ticks fell inside the test window. This showed up as TestCompactor_ShouldCompactAllUsersOnShardingEnabledButOnlyOneInstanceRunning failing twice in a row on test (arm64), with a different number of extra log lines each time. removeIgnoredLogs already suppresses the other two lines this loop can emit, but not these two, which carry a variable err= payload and so need a regex rather than an exact match. Add a unit test for the helper, since the flake itself is timing dependent and does not reproduce reliably. Fixes cortexproject#7826 Signed-off-by: Charlie Le <charlie_le@apple.com>
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.
What this PR does:
Fixes a flake in
pkg/compactorwhere background log output non-deterministically breaks the teststhat assert the compactor's complete log set.
userIndexUpdateLoopruns in the background of every sharding-enabled compactor test and ticks everyUsersScanner.UpdateInterval, whichprepare()sets to100 * time.Millisecond. Each tick callsownUser(userID, true), which consults the ring, so any tick that lands before the lifecycler isACTIVE — or after it starts LEAVING at shutdown — logs:
The 7 assertions in
compactor_test.goand 7 incompactor_paritioning_test.gothat compare the fulllog output with
ElementsMatchthen fail withelements differ, depending purely on how many ticksfell inside the test window.
removeIgnoredLogsalready suppresses the other two lines this loop can emit(
successfully updated user index,context timeout, exit user index update loop), but not thesetwo. Both carry a variable
err=payload, so they need a regex rather than an exact map entry —likely why they were missed when the others were added.
This is a test-synchronisation bug, not a product bug. The errors are legitimate signal in
production, so the fix is in the test helper rather than the loop.
Which issue(s) this PR fixes:
Fixes #7826
How this was verified:
The flake is timing dependent and does not reproduce locally, so this PR adds
TestRemoveIgnoredLogs_UserIndexUpdateLoopto cover the helper directly. I confirmed it failswithout the fix:
and passes with it. The full package also passes under the CI configuration:
Notes:
failed to update user indexfrom the same loop. Not yet observed in CI, but it hasidentical exposure.
Pollbudgets, failing as
expected 1, got 0). This one is an assertion-content race failing aselements differ.CHANGELOG.mdentry: test-only change with no user-facing impact, consistent with Fix flaky pkg/compactor tests #7796.Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]docs/configuration/v1-guarantees.mdupdated if this PR introduces experimental flags