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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentStickyKeyDispatcherMultipleConsumers.java:
##########
@@ -230,6 +253,24 @@ protected synchronized boolean 
trySendMessagesToConsumers(ReadType readType, Lis
                     }
                 }
             }
+
+            // Update if the markDeletePosition move forward
+            updateIfNeededAndGetLastSentPosition();
+
+            // Should not access to individualDeletedMessages from outside 
managed cursor
+            // because it doesn't guarantee thread safety.
+            if (lastSentPosition == null) {
+                if (cursor.getMarkDeletedPosition() != null) {
+                    lastSentPosition = ((ManagedCursorImpl) cursor)
+                            
.processIndividuallyDeletedMessagesAndGetMarkDeletedPosition(range -> {
+                                final PositionImpl lower = 
range.lowerEndpoint();
+                                final PositionImpl upper = 
range.upperEndpoint();
+                                
individuallySentPositions.addOpenClosed(lower.getLedgerId(), lower.getEntryId(),
+                                        upper.getLedgerId(), 
upper.getEntryId());
+                                return true;
+                            });
+                }
+            }

Review Comment:
   These initialize only will be called on the following cases:
   - `cursor.recover`
   - the last consumer is removed.
   
   Maybe we can move these codes to another place.



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