poorbarcode commented on code in PR #21423:
URL: https://github.com/apache/pulsar/pull/21423#discussion_r1432354290


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java:
##########
@@ -366,6 +377,30 @@ protected void readMoreEntries(Consumer consumer) {
         }
     }
 
+    private boolean shouldPauseOnAckStatePersist() {
+        if (!((PersistentTopic) 
subscription.getTopic()).isDispatcherPauseOnAckStatePersistentEnabled()) {
+            return false;
+        }
+        if (cursor == null) {
+            return true;
+        }
+        if (!cursor.isMetadataTooLargeToPersist()) {
+            return false;
+        }
+        // The cursor state is too large to persist, let us check whether the 
read is a replay read.
+        Range<PositionImpl> lastIndividualDeletedRange = 
cursor.getLastIndividualDeletedRange();
+        if (lastIndividualDeletedRange == null) {
+            // lastIndividualDeletedRange is null means the read is not replay 
read.
+            return true;
+        }
+        // If read position is less than the last acked position, it means the 
read is a replay read.
+        PositionImpl lastAckedPosition = 
lastIndividualDeletedRange.upperEndpoint();
+        Position readPosition = cursor.getReadPosition();
+        boolean readPositionIsSmall =
+                lastAckedPosition.compareTo(readPosition.getLedgerId(), 
readPosition.getEntryId()) > 0;
+        return !readPositionIsSmall;
+    }
+

Review Comment:
   Sure, reverted the change of `PersistentDispatcherSingleActiveConsumer`. And 
added a test for this scenario: `testSingleConsumerDispatcherWillNotPause`



-- 
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]

Reply via email to