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/06/30 02:25:03 UTC

[GitHub] [pulsar] BewareMyPower commented on a change in pull request #11159: Fix reading compacted data with the earliest start position by using Reader API

BewareMyPower commented on a change in pull request #11159:
URL: https://github.com/apache/pulsar/pull/11159#discussion_r661083640



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
##########
@@ -896,25 +897,60 @@ public void openCursorFailed(ManagedLedgerException exception, Object ctx) {
                     // The client will then be able to discard the first messages if needed.
                     entryId = msgId.getEntryId() - 1;
                 }
-
-                Position startPosition = new PositionImpl(ledgerId, entryId);
-                ManagedCursor cursor = null;
-                try {
-                    cursor = ledger.newNonDurableCursor(startPosition, subscriptionName, initialPosition);
-                } catch (ManagedLedgerException e) {
-                    return FutureUtil.failedFuture(e);
+                if (ledgerId == -1 && entryId == -1 && readCompacted) {
+                    CompactedTopicImpl compactedTopicImpl = (CompactedTopicImpl) this.compactedTopic;
+                    Optional<CompactedTopicImpl.CompactedTopicContext> optionalCompactedTopicContext;
+                    try {
+                        optionalCompactedTopicContext = compactedTopicImpl.getCompactedTopicContext();
+                    } catch (ExecutionException e) {
+                        subscriptionFuture.completeExceptionally(e.getCause());
+                        return subscriptionFuture;
+                    } catch (InterruptedException e) {
+                        subscriptionFuture.completeExceptionally(e);
+                        Thread.currentThread().interrupt();
+                        return subscriptionFuture;
+                    }

Review comment:
       I think it's not proper to use `getCompactedTopicContext`, which calls `CompletableFuture#get` to wait the future. It's easy to cause deadlock.




-- 
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: commits-unsubscribe@pulsar.apache.org

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