coderzc commented on code in PR #20697:
URL: https://github.com/apache/pulsar/pull/20697#discussion_r1249137491


##########
pulsar-broker/src/main/java/org/apache/pulsar/compaction/CompactedTopicImpl.java:
##########
@@ -101,32 +100,25 @@ public void asyncReadEntriesOrWait(ManagedCursor cursor,
 
             // TODO: redeliver epoch link 
https://github.com/apache/pulsar/issues/13690
             ReadEntriesCtx readEntriesCtx = ReadEntriesCtx.create(consumer, 
DEFAULT_CONSUMER_EPOCH);
-            if (compactionHorizon == null
-                || compactionHorizon.compareTo(cursorPosition) < 0) {
+
+            final PositionImpl currentCompactionHorizon = compactionHorizon;
+
+            if (currentCompactionHorizon == null
+                || currentCompactionHorizon.compareTo(cursorPosition) < 0) {
                 cursor.asyncReadEntriesOrWait(numberOfEntriesToRead, callback, 
readEntriesCtx, PositionImpl.LATEST);
             } else {
                 compactedTopicContext.thenCompose(
                     (context) -> findStartPoint(cursorPosition, 
context.ledger.getLastAddConfirmed(), context.cache)
                         .thenCompose((startPoint) -> {
                             // do not need to read the compaction ledger if it 
is empty.
                             // the cursor just needs to be set to the 
compaction horizon
-                            if (startPoint == COMPACT_LEDGER_EMPTY) {
-                                cursor.seek(compactionHorizon.getNext());
+                            if (startPoint == COMPACT_LEDGER_EMPTY || 
startPoint == NEWER_THAN_COMPACTED) {
+                                
cursor.seek(currentCompactionHorizon.getNext());
                                 
callback.readEntriesComplete(Collections.emptyList(), readEntriesCtx);
                                 return CompletableFuture.completedFuture(null);
-                            }
-                            if (startPoint == NEWER_THAN_COMPACTED && 
compactionHorizon.compareTo(cursorPosition) < 0) {
-                                
cursor.asyncReadEntriesOrWait(numberOfEntriesToRead, callback, readEntriesCtx,

Review Comment:
   Condition is always false because it has been judged line-107.



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