poorbarcode commented on code in PR #24096:
URL: https://github.com/apache/pulsar/pull/24096#discussion_r2006829543
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentSubscription.java:
##########
@@ -538,6 +556,127 @@ public void deleteFailed(ManagedLedgerException
exception, Object ctx) {
}
};
+ private void updatePendingAckMessagesAfterAcknowledged(Consumer ackFrom,
List<Position> positions) {
+ Dispatcher dispatcher0 = getDispatcher();
+ if (dispatcher0 != null) {
+ /*
+ * There is a race condition which leads us to add this
"synchronized" block.
+ * - consumer-1 received msg-A
+ * - consumption task is in-progress
+ * - topic was unloaded
+ * - reset messages to consumer-2
+ * At this moment, race-condition occurs:
+ * - consumer-1 is acknowledging msg-A
+ * - dispatcher is delivering msg-A to consumer-2
+ * Issue: broker received the acknowledging of msg-A, but no
consumer has pending acknowledge that relate
+ * to msg-A so broker can not know how many single messages in
the batched message.
+ * Solve: to get a precise messages number, this "synchronized"
block is needed.
+ */
+ synchronized (dispatcher0) {
Review Comment:
- There is a race condition which was described by the code comments.
- There are no other locks in the thread, `cursor.lock.writeLock()` has
released when execute `delete callback`
--
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]