poorbarcode commented on code in PR #22034:
URL: https://github.com/apache/pulsar/pull/22034#discussion_r1480833495
##########
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:
The managed ledger's `current ledger` is still pointed at this ledger, but
you deleted it.
You can trigger a Current ledger switch if you just want to free the storage
usage.
--
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]