gaoran10 commented on code in PR #17736:
URL: https://github.com/apache/pulsar/pull/17736#discussion_r977280528


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java:
##########
@@ -2463,12 +2473,19 @@ void internalTrimLedgers(boolean isTruncate, 
CompletableFuture<?> promise) {
                 log.debug("[{}] Start TrimConsumedLedgers. ledgers={} 
totalSize={}", name, ledgers.keySet(),
                         TOTAL_SIZE_UPDATER.get(this));
             }
-            if (STATE_UPDATER.get(this) == State.Closed) {
+            State currentState = STATE_UPDATER.get(this);
+            if (currentState == State.Closed) {
                 log.debug("[{}] Ignoring trimming request since the managed 
ledger was already closed", name);
                 trimmerMutex.unlock();
                 promise.completeExceptionally(new 
ManagedLedgerAlreadyClosedException("Can't trim closed ledger"));
                 return;
             }
+            if (currentState == State.Fenced) {
+                log.debug("[{}] Ignoring trimming request since the managed 
ledger was already fenced", name);
+                trimmerMutex.unlock();

Review Comment:
   Sorry, after checking the code, I think we should release the lock, or else 
the scheduled task will always try to get the lock per 100 milliseconds.



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