nodece opened a new pull request, #25571: URL: https://github.com/apache/pulsar/pull/25571
## Motivation Dispatcher notification logic (`afterAckMessages` + `markDeletePositionMoveForward`) was scattered across multiple callback sites in `PersistentSubscription` (markDeleteCallback, deleteCallback, clearBacklog, skipMessages, resetCursor). This led to: - Duplicated `dispatcher.afterAckMessages()` calls that could fire even when the mark-delete position hadn't actually changed. - Redelivery tracker and pending acks cleanup was only performed inside `readMoreEntries()` for the `PersistentDispatcherMultipleConsumers` base class, meaning `Key_Shared` subscriptions had to duplicate the logic. Other subscription types (Shared, Failover) missed cleanup opportunities when messages expired via TTL. - `PersistentMessageExpiryMonitor` only triggered `markDeletePositionMoveForward()` for `Key_Shared` subscriptions, leaving other subscription types without proper cleanup after message expiry. ## Changes ### `PersistentSubscription` - Consolidated all `dispatcher.afterAckMessages()` calls into the single `notifyTheMarkDeletePositionChanged()` method, which now also calls `dispatcher.markDeletePositionMoveForward()`. - Removed scattered `afterAckMessages` calls from `markDeleteCallback`, `deleteCallback`, `clearBacklog`, `skipMessages`, and `resetCursor`. - Added `oldMarkDeletePosition` capture in `clearBacklog`, `skipMessages`, and `resetCursor` to route through the centralized path. ### `PersistentDispatcherMultipleConsumers` - Moved redelivery tracker and pending acks cleanup from `readMoreEntries()` into `markDeletePositionMoveForward()`, so it fires precisely when the mark-delete position advances rather than opportunistically on the next read cycle. - Removed `lastMarkDeletePositionBeforeReadMoreEntries` field. ### `PersistentStickyKeyDispatcherMultipleConsumers` - Added `super.markDeletePositionMoveForward()` call so Key_Shared subscriptions also clean up stale entries from the redelivery tracker and pending acks. ### `PersistentMessageExpiryMonitor` - Changed the post-expiry dispatcher notification from a `Key_Shared`-only check to a general `dispatcher != null` check, so all subscription types benefit from cleanup after message TTL expiry. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
