Technoboy- commented on code in PR #22751:
URL: https://github.com/apache/pulsar/pull/22751#discussion_r1713647909


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java:
##########
@@ -891,10 +897,29 @@ private boolean sendChunkedMessagesToConsumers(ReadType 
readType,
 
     @Override
     public synchronized void readEntriesFailed(ManagedLedgerException 
exception, Object ctx) {
-
         ReadType readType = (ReadType) ctx;
-        long waitTimeMillis = readFailureBackoff.next();
+        if (readType == ReadType.Normal) {
+            havePendingRead = false;
+        } else {
+            havePendingReplayRead = false;
+            if (exception instanceof 
ManagedLedgerException.InvalidReplayPositionException) {
+                PositionImpl markDeletePosition = (PositionImpl) 
cursor.getMarkDeletedPosition();
+                
redeliveryMessages.removeAllUpTo(markDeletePosition.getLedgerId(), 
markDeletePosition.getEntryId());
+            }
+        }
+        if (shouldRewindBeforeReadingOrReplaying) {
+            shouldRewindBeforeReadingOrReplaying = false;
+            cursor.rewind();
+        }
+        readBatchSize = serviceConfig.getDispatcherMinReadBatchSize();
 
+        // Do not keep reading more entries if the cursor is already closed.
+        if (exception instanceof 
ManagedLedgerException.CursorAlreadyClosedException) {
+            log.warn("[{}] Cursor was already closed when reading entries", 
name);
+            return;
+        }
+
+        long waitTimeMillis = readFailureBackoff.next();

Review Comment:
   why move these before the exception ?



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