[fix][broker] Clear delayed delivery state before resetting the cursor - #26420
Open
nodece wants to merge 1 commit into
Open
[fix][broker] Clear delayed delivery state before resetting the cursor#26420nodece wants to merge 1 commit into
nodece wants to merge 1 commit into
Conversation
nodece
force-pushed
the
fix-reset-clear-delayed-messages
branch
from
August 25, 2026 10:01
f7e0723 to
0b30bc7
Compare
resetCursorInternal() reset the cursor without touching the delayed delivery tracker, although a reset moves the consumption baseline the tracker state was derived from: bucket snapshots, index bits and queued entries from before the reset survived into the replay, and in-flight trims/loads/deletes could race the replayed state. Clear the delayed messages and wait for the clear to settle after disconnecting consumers and before asyncResetCursor, with the whole reset flow chained into a single error path. Without a dispatcher there is no in-flight work and the recovered bucket snapshots stay valid for the replay, so there is nothing to clear.
nodece
force-pushed
the
fix-reset-clear-delayed-messages
branch
from
August 25, 2026 10:02
0b30bc7 to
15f944a
Compare
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
PersistentSubscription#resetCursorInternalreset the cursor without touching the delayed delivery tracker. The tracker state is a derived cache of the backlog (the source of truth isdeliverAtTimein the message metadata), and a reset moves the consumption baseline, so the whole derivation is invalidated:clearBacklogand unsubscribe already clear the delayed state for the same reason; the reset path was the odd one out.Modifications
resetCursorInternalnow clears the delayed messages and waits for the clear to settle after disconnecting consumers and beforeasyncResetCursor; a clear failure unfences the subscription and fails the reset.Verifying this change
This change added tests and can be verified as follows:
BucketDelayedDeliveryTest#testResetCursorClearsDelayedMessages: tracks 100 delayed messages, resets the cursor to the earliest position and verifies the tracker count is 0 and the bucket cursor properties are removed. Without the fix the assertion fails: the tracker still reports 100 delayed messages and the bucket cursor property survives the reset.Does this pull request potentially affect one of the following parts:
Check the boxes that apply