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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to