BewareMyPower commented on code in PR #21187:
URL: https://github.com/apache/pulsar/pull/21187#discussion_r1455139453


##########
pulsar-broker/src/main/java/org/apache/pulsar/compaction/CompactedTopicImpl.java:
##########
@@ -100,7 +100,13 @@ public void asyncReadEntriesOrWait(ManagedCursor cursor,
                                        boolean isFirstRead,
                                        ReadEntriesCallback callback, Consumer 
consumer) {
             PositionImpl cursorPosition;
-            if (isFirstRead && 
MessageId.earliest.equals(consumer.getStartMessageId())){
+            boolean readFromEarliest = false;
+            if (!cursor.isDurable() || ((ManagedCursorImpl) 
cursor).isCompactionCursor()
+                    || cursor.getMarkDeletedPosition() == null
+                    || cursor.getMarkDeletedPosition().getEntryId() == -1L) {
+                readFromEarliest = isFirstRead && 
MessageId.earliest.equals(consumer.getStartMessageId());
+            }

Review Comment:
   You don't need to modify a deprecated method.



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java:
##########
@@ -362,7 +363,12 @@ private void readMoreEntries(Consumer consumer) {
                 }
                 havePendingRead = true;
                 if (consumer.readCompacted()) {
-                    boolean readFromEarliest = isFirstRead && 
MessageId.earliest.equals(consumer.getStartMessageId());
+                    boolean readFromEarliest = false;
+                    if (!cursor.isDurable() || ((ManagedCursorImpl) 
cursor).isCompactionCursor()
+                            || cursor.getMarkDeletedPosition() == null
+                            || cursor.getMarkDeletedPosition().getEntryId() == 
-1L) {
+                        readFromEarliest = isFirstRead && 
MessageId.earliest.equals(consumer.getStartMessageId());
+                    }

Review Comment:
   Could you just simplify the check with:
   
   ```java
                       boolean readFromEarliest = isFirstRead && 
cursor.isDurable()
                               && 
cursor.getName().equals(Compactor.COMPACTION_SUBSCRIPTION);
   ```
   
   You don't need to expose the `ManagedCursor#isCompactionCursor()` method.
   
   And why did you also check the mark deleted position here?



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