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/12/02 16:09:18 UTC

[GitHub] [pulsar] hangc0276 commented on issue #12964: No ledger found while trying to read last entry: 306

hangc0276 commented on issue #12964:
URL: https://github.com/apache/pulsar/issues/12964#issuecomment-984771403


   When we create a ledger and not entry writes to the ledger, and then call `readLastAddConfirmedAsync`, it will just check whether the request ledger has been exist in ledgerStorage. Due to we have not write any entry into the ledger, the check will return false, and it will throw `NoLedgerException`. The following test will reproduce this issue.
   ```Java
   @Test
       public void testReadLacOnEmptyLedger() {
           try {
               CompletableFuture<Void> future = new CompletableFuture<>();
               LedgerHandle lh = bkc.createLedger(1, 1, 1, digestType, "test".getBytes());
               lh.readLastAddConfirmedAsync().thenAccept(lastAddConfirmed -> {
                   logger.info("lastAddConfirmed: {}", lastAddConfirmed);
                   future.complete(null);
               }).exceptionally(ex -> {
                   logger.error("e: ", ex);
                   future.completeExceptionally(null);
                   return null;
               });
               future.get();
           } catch (Exception e) {
               logger.error("Read last add confirmed failed: ", e);
               fail();
           }
   ```
   
   However, the response builder will wrap the exception and just return -1 as the lastAddConfirmed to represent Invalid entry id.  And in pulsar client, it won't throw exception and just use -1 to generate ledger info
   
   https://github.com/apache/pulsar/blob/2c2922d684369ac2fcc9e049376ecd2902ee9862/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ReadOnlyManagedLedgerImpl.java#L68-L91
   
   In the end, the exception is normal and it is no harm for pulsar to process messages.
   We have an PR to change the log level from error to warn.  https://github.com/apache/bookkeeper/pull/2757


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