Repository navigation
[fix][test] Wait for the ack to be persisted before rewinding in V5StreamConsumerAckWatermarkTest - #26684
Merged
Conversation
…reamConsumerAckWatermarkTest testAckCompletedBeforeARedeliveryDoesNotSuppressTheReack issues a cumulative ack, then rewinds the broker-side cursor from inside the consumer's before-watermark-update hook and expects the redelivery. The ack is written to the connection right before the hook runs, but the rewind is an in-process call on the broker and can overtake it. When it does, the cursor receives the reset before the ack and applies them in that order: the mark-delete persists the later position and the reset's read-position change is folded into the same batch and lost, so the reconnected consumer starts at the end of the segment and receive() times out with "missed message #0". Wait until the ack has been applied (backlog 0) and persisted (getPersistentMarkDeletedPosition equals getMarkDeletedPosition) before resetting the cursor, so the rewind always lands after the ack.
This was referenced Sep 22, 2026
merlimat
approved these changes
Sep 22, 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.
Fixes #26683
Main Issue: #26683
Motivation
V5StreamConsumerAckWatermarkTest#testAckCompletedBeforeARedeliveryDoesNotSuppressTheReackfails on loaded CI runners withmissed message #0. The test issues a cumulative ack and then rewinds the broker-side cursor from inside the consumer's before-watermark-update hook. The ack has only been written to the connection at that point, while the rewind is an in-process broker call, so the rewind can overtake the ack. The cursor then applies the two operations in arrival order: with its metadata ledger still being created, both mark-deletes are queued, the batch is persisted through its last entry only (the ack), and the reset's read-position change is dropped although its callback completes. The reconnected consumer starts at the end of the segment and nothing is redelivered. See #26683 for the log comparison between a passing and a failing run. Found while running the CI for #26672 on my fork, whose change does not touch the v5 client.Modifications
In the hook, before resetting the cursor, wait until the ack has been applied (subscription backlog is 0) and persisted (
getPersistentMarkDeletedPosition()equalsgetMarkDeletedPosition()). The rewind then always lands after the ack, which is the ordering the test is written to exercise: an ack that completed before the redelivery, observed by the v5 layer only after it.Verifying this change
This change is already covered by existing tests, such as
V5StreamConsumerAckWatermarkTest.Ran the test 8 times in a loop under full CPU load after the change: 8/8 passed. The failing interleaving could not be reproduced locally on an 8-core machine; the analysis is based on the broker logs uploaded by the failing CI run, which show the reset's
Reset readPosition ...step missing whileresetCursor()still completed normally.Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc-not-neededMatching PR in forked repository
PR in forked repository: namest504#3