[fix][test] Fix flaky OffloadPrefixTest.testPositionOnEdgeOfLedger race with ledger rollover#25561
Merged
lhotari merged 1 commit intoapache:masterfrom Apr 22, 2026
Merged
Conversation
…ce with ledger rollover After writing exactly 20 entries with maxEntriesPerLedger=10, the second ledger is closed and a third empty ledger is created asynchronously on the managed ledger executor. The test assertion that the ledger list size is 2 races with that async creation, so the test intermittently sees 3 ledgers and fails. Wait for the rollover to finish (3 ledgers: l1 full, l2 full, l3 empty) before proceeding; all other assertions in the test already work correctly with this stable state.
lhotari
approved these changes
Apr 22, 2026
srinath-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Apr 23, 2026
…ce with ledger rollover (apache#25561) (cherry picked from commit 77999fc) (cherry picked from commit 6f57b19)
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
OffloadPrefixTest.testPositionOnEdgeOfLedgeris flaky. The test writes exactly 20 entries withmaxEntriesPerLedger=10, which fills two ledgers. Once the second ledger is full, it is closed and a third (empty) ledger starts being created asynchronously on the managed-ledger executor. The test's next line asserts that only 2 ledgers exist — this races with the async rollover and the test intermittently fails with a third ledger already present.Example failure
Modifications
Replace the hard-coded
assertEquals(size, 2)with anAwaitility.await()that waits for the 3-ledger steady state (l1 full, l2 full, l3 empty). The rest of the test (getLastConfirmedEntryreturning the last entry of l2, thenaddEntry("entry-blah")being stored in l3, then the twooffloadPrefixcalls) already works correctly against this stable state, so no other changes are required.Verifying this change
This change is already covered by existing tests, such as
OffloadPrefixTest.testPositionOnEdgeOfLedger.Does this pull request potentially affect one of the following parts: