[fix][test] Fix flaky ManagedLedgerTest.testCursorPointsToDeletedLedgerAfterTrim#25476
Merged
nodece merged 1 commit intoapache:masterfrom Apr 7, 2026
Merged
Conversation
…erAfterTrim The test used a 30s BK write delay to simulate slow persistence, but this made the outcome timing-dependent: sometimes persistence completed before trim checked positions, sometimes not. Simplify the test to verify the correct behavior without artificial delays: maybeUpdateCursorBeforeTrimmingConsumedLedger advances the cursor past fully consumed ledgers, and trim cleans them up.
nodece
approved these changes
Apr 7, 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.
Motivation
ManagedLedgerTest.testCursorPointsToDeletedLedgerAfterTrimis flaky because it injects a 30s BK write delay and then asserts the persistent position hasn't advanced. However, the outcome is timing-dependent: sometimes the delayed persistence completes before the trim checks cursor positions, sometimes not.The test's assertions were also incorrect —
maybeUpdateCursorBeforeTrimmingConsumedLedger()is designed to advance the cursor past fully consumed ledgers, and it's perfectly fine for the persistent position to advance. The old assertions expected the persistent position to remain at the old value.Stack trace
Modifications
Simplify the test by removing the 30s BK write delay and the complex out-of-order deletion pattern. The test now straightforwardly verifies that
maybeUpdateCursorBeforeTrimmingConsumedLedgeradvances the cursor past a fully consumed ledger, and trimming correctly deletes it.Documentation
doc-not-needed