liangyepianzhou commented on code in PR #22034: URL: https://github.com/apache/pulsar/pull/22034#discussion_r1480880177
########## managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java: ########## @@ -2667,8 +2667,10 @@ void internalTrimLedgers(boolean isTruncate, CompletableFuture<?> promise) { ledgers.headMap(slowestReaderLedgerId, false).values().iterator(); while (ledgerInfoIterator.hasNext()){ LedgerInfo ls = ledgerInfoIterator.next(); - // currentLedger can not be deleted - if (ls.getLedgerId() == currentLedger.getId()) { + // Current ledger can not be deleted when it is currently being written to. + // However, When the manager ledger state is ClosedLedger, the current ledger was closed + // and there are no pending operations. So it can be deleted. + if (ls.getLedgerId() == currentLedger.getId() && currentState != State.ClosedLedger) { Review Comment: I have considered this when writing this question, but what I am thinking is whether it is necessary to create a new ledegr if there are no new messages. Will creating a new ledger add unnecessary expenses. -- 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