poorbarcode commented on code in PR #20649:
URL: https://github.com/apache/pulsar/pull/20649#discussion_r1250532829


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java:
##########
@@ -2451,15 +2451,15 @@ private void trimConsumedLedgersInBackground() {
 
     @Override
     public void trimConsumedLedgersInBackground(CompletableFuture<?> promise) {
-        executor.execute(() -> internalTrimConsumedLedgers(promise));
+        scheduledExecutor.execute(() -> internalTrimConsumedLedgers(promise));
     }
 
     public void trimConsumedLedgersInBackground(boolean isTruncate, 
CompletableFuture<?> promise) {

Review Comment:
   @315157973 
   
   Now the tasks `publish` and `trim ledgers` all run in the thread `executor`( 
it is a single thread pool, and the tasks of same topic will be executed in the 
same thread<sup>[L-1]</sup> ), right?<sup>[Q-1]</sup>
   
   ---
   
   if yes<sup>[Q-1]</sup>, the task `trim ledgers` blocks the task `publish`, 
which this PR tries to fix, right?<sup>[Q-2]</sup>
   
   ---
   if yes<sup>[Q-2]</sup>, but both tasks `trim ledgers`<sup>[L-2]</sup> and 
`internalAsyncAddEntry`<sup>[L-3]</sup> will try to acquire the same lock 
`synchronized(ml)`, so the task `trim ledgers` is still blocking the task 
`publish` even if this patch is merged, right?[Q-3]</sup>
   
   ---
   **[L-1]**: 
https://github.com/apache/pulsar/blob/master/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java#L348
   **[L-2]**:  
https://github.com/apache/pulsar/blob/master/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java#L2608
   **[L-3]**: 
https://github.com/apache/pulsar/blob/master/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java#L798



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