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/09/29 07:57:09 UTC

[GitHub] [pulsar] eolivelli commented on a change in pull request #12071: Fail managed ledger initialization if LCE belongs to non-existing ledger

eolivelli commented on a change in pull request #12071:
URL: https://github.com/apache/pulsar/pull/12071#discussion_r718249013



##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
##########
@@ -320,9 +319,44 @@ public ManagedLedgerImpl(ManagedLedgerFactoryImpl factory, BookKeeper bookKeeper
         }
     }
 
-    synchronized void initialize(final ManagedLedgerInitializeLedgerCallback callback, final Object ctx) {
+    synchronized void initialize(final ManagedLedgerInitializeLedgerCallback originalCb, final Object ctx) {
         log.info("Opening managed ledger {}", name);
 
+        ManagedLedgerInitializeLedgerCallback callback = new ManagedLedgerInitializeLedgerCallback() {
+            @Override
+            public void initializeComplete() {
+                if (lastConfirmedEntry != null && lastConfirmedEntry.entryId != -1) {
+                    // check that ledger used by lastConfirmedEntry actually exists
+                    try {
+                        getLedgerMetadata(lastConfirmedEntry.getLedgerId()).get();

Review comment:
       should we chain this CompletableFuture and call` originalCb.initializeComplete();` on completion ?
   otherwise we are introducing a blocking call in the chain, also getLedgerMetadata will be a blocking call related to ZK client
   
   ```
   getLedgerMetadata(lastConfirmedEntry.getLedgerId()).thenRun( () -> {
         originalCb.initializeComplete();
   }).exceptionally((err) -> {
        originalCb.initializeFailed(err);
        ....
   });
   ```




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