XComp opened a new pull request, #20709:
URL: https://github.com/apache/flink/pull/20709

   
   
   ## What is the purpose of the change
   
   CURATOR-645 covers a bug in the LeaderLatch implementation that causes a 
race condition if a child node, participating in the leader election, is 
removed too fast. This results in a different code branch being executed which 
triggers a reset of the LeaderLatch instead of re-collecting the children to 
determine the next leader.
   The issue occurs because LeaderLatch#checkLeadership is not executed 
transactionally, i.e. retrieving the children and setting up the watcher for 
the predecessor is not done atomically. This leads to the race condition where 
a children (the previous leader's node) is removed before setting up the 
watcher which results in an invalid handling of the situation using reset.
   Adding some sleep here (simulating the leader actually doing something) will 
reduce the risk of falling into the race condition because it will give curator 
to more time to set up the watchers properly. This is only meant as a temporary 
solution until CURATOR-645 is resolved and the curator dependency on the Flink 
side is upgraded.
   
   ## Brief change log
   
   * Adds a minor `Thread.sleep` to simulate actual workload on the leader to 
prevent the LeaderLatch going into the buggy code branch.
   
   ## Verifying this change
   
   Runs test repeatedly without the fix and with the fix to see whether we can 
observe a difference.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / no)
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: (yes / no)
     - The serializers: (yes / no / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / no / 
don't know)
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
     - The S3 file system connector: (yes / no / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs 
/ not documented)
   


-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to