[improve][broker] Centralize mark-delete position change handling#25571
Closed
nodece wants to merge 1 commit intoapache:masterfrom
Closed
[improve][broker] Centralize mark-delete position change handling#25571nodece wants to merge 1 commit intoapache:masterfrom
nodece wants to merge 1 commit intoapache:masterfrom
Conversation
lhotari
reviewed
Apr 23, 2026
Comment on lines
+349
to
+355
| redeliveryMessages.removeAllUpTo(mdp.getLedgerId(), mdp.getEntryId()); | ||
| for (Consumer consumer : consumerList) { | ||
| PendingAcksMap pendingAcks = consumer.getPendingAcks(); | ||
| if (pendingAcks != null) { | ||
| pendingAcks.removeAllUpTo(mdp.getLedgerId(), mdp.getEntryId()); | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
Is there a significant different in the frequency that this gets called? When this logic was previously in readMoreEntries, it would only get called there if the mark delete position moved since the last call to readMoreEntries, which is not as frequent as the mark delete position might move forward. This has been intentional behavior in the past and I have a concern that this change would cause a performance regression.
Member
Author
There was a problem hiding this comment.
There's likely a performance impact due to the higher invocation frequency. Thanks for pointing that out. I'll revisit the change and adjust it to avoid unnecessary executions!
Member
Author
|
Closed by #25592 |
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
Dispatcher notification logic (
afterAckMessages+markDeletePositionMoveForward) was scattered across multiple callback sites inPersistentSubscription(markDeleteCallback, deleteCallback, clearBacklog, skipMessages, resetCursor). This led to:dispatcher.afterAckMessages()calls that could fire even when the mark-delete position hadn't actually changed.readMoreEntries()for thePersistentDispatcherMultipleConsumersbase class, meaningKey_Sharedsubscriptions had to duplicate the logic. Other subscription types (Shared, Failover) missed cleanup opportunities when messages expired via TTL.PersistentMessageExpiryMonitoronly triggeredmarkDeletePositionMoveForward()forKey_Sharedsubscriptions, leaving other subscription types without proper cleanup after message expiry.Changes
PersistentSubscriptiondispatcher.afterAckMessages()calls into the singlenotifyTheMarkDeletePositionChanged()method, which now also callsdispatcher.markDeletePositionMoveForward().afterAckMessagescalls frommarkDeleteCallback,deleteCallback,clearBacklog,skipMessages, andresetCursor.oldMarkDeletePositioncapture inclearBacklog,skipMessages, andresetCursorto route through the centralized path.PersistentDispatcherMultipleConsumersreadMoreEntries()intomarkDeletePositionMoveForward(), so it fires precisely when the mark-delete position advances rather than opportunistically on the next read cycle.lastMarkDeletePositionBeforeReadMoreEntriesfield.PersistentStickyKeyDispatcherMultipleConsumerssuper.markDeletePositionMoveForward()call so Key_Shared subscriptions also clean up stale entries from the redelivery tracker and pending acks.PersistentMessageExpiryMonitorKey_Shared-only check to a generaldispatcher != nullcheck, so all subscription types benefit from cleanup after message TTL expiry.