You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/01/14 18:12:28 UTC

[GitHub] [pulsar] jerrypeng commented on a change in pull request #9206: [WIP] - Fix issue with topic compaction when compaction ledger is empty

jerrypeng commented on a change in pull request #9206:
URL: https://github.com/apache/pulsar/pull/9206#discussion_r557594047



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/compaction/CompactedTopicImpl.java
##########
@@ -91,6 +95,18 @@ public void asyncReadEntriesOrWait(ManagedCursor cursor, int numberOfEntriesToRe
                 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) {
+                                try {
+                                    MessageIdImpl msgId =
+                                      (MessageIdImpl) LedgerMetadataUtils.getCompactedToMessageId(context.ledger);
+                                    log.info("compaction horizaion msg id: {}", msgId);
+                                    cursor.seek(PositionImpl.get(msgId.getLedgerId(), msgId.getEntryId()));
+                                } catch (IOException e) {
+                                    new RuntimeException(e);
+                                }
+                            }

Review comment:
       we can just return CompletableFuture.completedFuture(null);




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org