davsclaus opened a new pull request, #25791:
URL: https://github.com/apache/camel/pull/25791

   ## Backport of #25611
   
   Cherry-pick of #25611 onto `camel-4.18.x`.
   
   **Original PR:** #25611 - CAMEL-24457: Fix ZooKeeper cluster split-brain on 
leader isolation
   **Original author:** @mustafaAlmonayer
   **Target branch:** `camel-4.18.x`
   
   ### Original description
   
   ZooKeeperClusterView.CamelLeaderElectionListener.takeLeadership() fired
   its leadership-lost event while Curator's hasLeadership() still
   returned true, since the event fired from inside takeLeadership()
   before Curator's internals had flipped leadership state. This caused
   ClusteredRoutePolicy to see no leadership change and keep the route
   running on a node that had lost its ZooKeeper session, while a healthy
   node elected a new leader and started the same route — a split-brain
   with duplicate message processing.
   
   Track leadership state in a view-owned volatile flag instead of
   delegating to leaderSelector.hasLeadership(), set it before firing the
   leadership-gained/lost events in takeLeadership()'s try/finally, and
   close (not just interrupt) the LeaderSelector in doStop() so a
   deliberate stop cannot race an auto-requeue. autoRequeue() is enabled
   in doStart() so the node re-enters the election after ZooKeeper
   reconnects.
   
   Adds ZooKeeperClusterViewLeadershipLostIT to exercise the split-brain
   scenario end-to-end: acquire leadership, lose it on ZK session loss,
   and reclaim it after reconnect.
   
   Closes #25611


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