This is an automated email from the ASF dual-hosted git repository.

penghui pushed a commit to branch branch-2.8
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit d7117fba68a0dbdb992680103c6d4e2676336c2d
Author: lipenghui <[email protected]>
AuthorDate: Fri Jan 14 17:47:13 2022 +0800

    Fix the deadlock while using zookeeper thread to create ledger (#13744)
    
    ### Motivation
    
    Fixes: #13736, the deadlock when using ZK thread to create a ledger.
    
    ### Modification
    
    Use the executor of the managed ledger to create the ledger to avoid the 
deadlock.
    
    (cherry picked from commit 1d4c374d9a87e5188c8b64677b8c6bea652a2d2a)
---
 .../java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java   | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git 
a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
 
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
index 9ee0a8f..b8a21f4 100644
--- 
a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
+++ 
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
@@ -1593,7 +1593,10 @@ public class ManagedLedgerImpl implements ManagedLedger, 
CreateCallback {
             STATE_UPDATER.set(this, State.CreatingLedger);
             this.lastLedgerCreationInitiationTimestamp = 
System.currentTimeMillis();
             mbean.startDataLedgerCreateOp();
-            asyncCreateLedger(bookKeeper, config, digestType, this, 
Collections.emptyMap());
+            // Use the executor here is to avoid use the Zookeeper thread to 
create the ledger which will lead
+            // to deadlock at the zookeeper client, details to see 
https://github.com/apache/pulsar/issues/13736
+            this.executor.execute(() ->
+                    asyncCreateLedger(bookKeeper, config, digestType, this, 
Collections.emptyMap()));
         }
     }
 

Reply via email to