Stabilize flaky CleanupManagerTest.testCleanupHappens#262
Open
vharseko wants to merge 1 commit into
Open
Conversation
The test offered 500 cleanup actions and waited only while getEnqueuedCount() > 0. That counter drops to 0 as soon as the background CLEANUP_MANAGER thread dequeues the batch -- before performAction runs -- so on a slow runner the wait loop exited with no action yet performed and _counter still 0 (expected:<500> but was:<0>, seen on ubuntu-latest JDK 17). Wait on the manager's own performed/error counters (which advance only after each action completes) until all 500 are processed, with a 30s cap.
maximthomas
approved these changes
Jul 10, 2026
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.
Problem
CleanupManagerTest.testCleanupHappensis flaky. It offers 500 cleanup actions and then waits for them to run — but the wait loops only while the queue is non-empty:getEnqueuedCount()drops to 0 as soon as the backgroundCLEANUP_MANAGERthread dequeues the batch — which happens beforeperformActionruns. So on a slow/loaded runner the wait loop seesgetEnqueuedCount() == 0on the first check, exits without sleeping, and asserts while no action has been performed yet:Observed on
build-maven (ubuntu-latest, 17); passes elsewhere.Fix
Wait on the manager's own performed/error counters (
getPerformedCount() + getErrorCount()), which advance only after each action completes, until all 500 are processed — with a 30 s cap. This waits for the actions to actually run rather than merely leave the queue. All four existing assertions (_counter == 500,errorCount == 1,performedCount == 499, in-order) are unchanged.Not caused by this PR's parent change
Unrelated to the PR it was blocking (#228, make
Key.SDFthread-safe): that change is aSimpleDateFormat → ThreadLocalinKey, nothing to do with the cleanup manager.CleanupManagerTestwas previously touched by #240 for a different race (out-of-order recording), not this queue-drain wait.Verification
testCleanupHappens6/6 green; fullCleanupManagerTestclass 3/3.performAction), so this is a deterministic fix.