coderzc commented on code in PR #24441: URL: https://github.com/apache/pulsar/pull/24441#discussion_r2162917043
########## managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpFindNewest.java: ########## @@ -115,31 +119,93 @@ public void readEntryComplete(Entry entry, Object ctx) { } else { // start binary search state = State.searching; - searchPosition = ledger.getPositionAfterN(startPosition, mid(), PositionBound.startExcluded); + this.mid = mid(); + searchPosition = ledger.getPositionAfterN(startPosition, this.mid, PositionBound.startExcluded); find(); } break; case searching: if (condition.test(entry)) { // mid - last lastMatchedPosition = position; - min = mid(); + min = mid; } else { // start - mid - max = mid() - 1; + max = mid - 1; } + this.mid = mid(); if (max <= min) { callback.findEntryComplete(lastMatchedPosition, OpFindNewest.this.ctx); return; } - searchPosition = ledger.getPositionAfterN(startPosition, mid(), PositionBound.startExcluded); + searchPosition = ledger.getPositionAfterN(startPosition, this.mid, PositionBound.startExcluded); find(); } } @Override public void readEntryFailed(ManagedLedgerException exception, Object ctx) { + if (exception instanceof ManagedLedgerException.NonRecoverableLedgerException + && ledger.getConfig().isAutoSkipNonRecoverableData()) { + log.info("[{}] Ledger {} is not recoverable, skip non-recoverable data, state:{}", ledger.getName(), + searchPosition, state); + Position nextPosition = null; + if (exception instanceof ManagedLedgerException.LedgerNotExistException) { + Long nextLedgerId = ledger.getNextValidLedger(searchPosition.getLedgerId()); + if (nextLedgerId != null) { + nextPosition = PositionFactory.create(nextLedgerId, 0); Review Comment: Add check logic -- 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-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org