Skip to content

[fix][test] Wait for the ack to be persisted before rewinding in V5StreamConsumerAckWatermarkTest - #26684

Merged
lhotari merged 1 commit into
apache:masterfrom
namest504:fix/v5-ack-watermark-test-race
Sep 28, 2026
Merged

lhotari merged 1 commit into
apache:masterfrom
namest504:fix/v5-ack-watermark-test-race

Conversation

@namest504

@namest504 namest504 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #26683

Main Issue: #26683

Motivation

V5StreamConsumerAckWatermarkTest#testAckCompletedBeforeARedeliveryDoesNotSuppressTheReack fails on loaded CI runners with missed 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() equals getMarkDeletedPosition()). 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

  • Make sure that the change passes the CI checks.

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 while resetCursor() still completed normally.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc-not-needed

Matching PR in forked repository

PR in forked repository: namest504#3

…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.
@lhotari
lhotari merged commit c5a0013 into apache:master Sep 28, 2026
81 of 84 checks passed
@namest504
namest504 deleted the fix/v5-ack-watermark-test-race branch September 29, 2026 03:13
@lhotari lhotari added this to the 5.0.0 milestone Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky-test: V5StreamConsumerAckWatermarkTest.testAckCompletedBeforeARedeliveryDoesNotSuppressTheReack

3 participants