mustafa kamal created CAMEL-24545:
-------------------------------------

             Summary: Camel Shutdown Locked State With ZookeeprCluster Service
                 Key: CAMEL-24545
                 URL: https://issues.apache.org/jira/browse/CAMEL-24545
             Project: Camel
          Issue Type: Bug
          Components: camel-zookeeper, camel-zookeeper-master
    Affects Versions: 4.22.1, 4.18.5
         Environment: One ZK instance and one camel instance running 
ZooKeeperClusterService you need to use the main branch or any fix branch as 
this PR didn't span into a released version. 
            Reporter: mustafa kamal
         Attachments: dump.txt

 During shutdown, Camel's ClusteredRoutePolicy.onRemove and the Curator leader 
selector thread both run concurrently  because some routes keep the shutdown 
window open long enough. These two threads acquire the same two locks in 
opposite order, causing a classic deadlock that permanently hangs the JVM.

You can check the attached Thread Dump to see the technical level of the issue 
more.

 

Possible fix is to surround `fireLeadershipChangedEvent((CamelClusterMember) 
null);` line 154 in `ZooKeeperClusterView` class, with `if 
(!isStoppingOrStopped())` that will solve the dead lock issue 

Another issue it solved the unnecessary firing of the Leadership Change event 
because on stopping/shutting down the view all the registered listeners will be 
removed so any reaction they need to do should be before stopping the view 
because stopping the view is not as the same as Losing the Leadership Lock so 
that's more of an enhancement than breaking functionality. 

 

To reproduce the issue run the application wait until it's the Leader by 
acquiring the lock in ZK then shutting down the application, not all routes 
will produce the issue some routes have a long enough shutdown windows that 
allows the Dead Lock to happen 

 

This issue is related to the PR [https://github.com/apache/camel/pull/25611] 
for ticket https://issues.apache.org/jira/projects/CAMEL/issues/CAMEL-24457



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to