You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by "Ken Huang (Jira)" <ji...@apache.org> on 2022/06/26 14:55:00 UTC

[jira] [Comment Edited] (CURATOR-644) CLONE - Race conditions in LeaderLatch after reconnecting to ensemble

    [ https://issues.apache.org/jira/browse/CURATOR-644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17558895#comment-17558895 ] 

Ken Huang edited comment on CURATOR-644 at 6/26/22 2:54 PM:
------------------------------------------------------------

[~tison] it didn't help. We encountered a similar issue 9 months ago, we also found the FLINK ticket, and set as it described. but the same issue happened days ago, so I think the solution didn't work.


was (Author: JIRAUSER291535):
[~tison] it didn't help. We encountered a similar issue before, we also found the FLINK ticket, and set as it described. but the same issue happened days ago, so I think the solution didn't work.

> CLONE - Race conditions in LeaderLatch after reconnecting to ensemble
> ---------------------------------------------------------------------
>
>                 Key: CURATOR-644
>                 URL: https://issues.apache.org/jira/browse/CURATOR-644
>             Project: Apache Curator
>          Issue Type: Bug
>    Affects Versions: 4.1.0
>            Reporter: Ken Huang
>            Assignee: Jordan Zimmerman
>            Priority: Minor
>
> Clone from CURATOR-504.
> We use LeaderLatch in a lot of places in our system and when ZooKeeper ensemble is unstable and clients are reconnecting to logs are full of messages like the following:
> {{{}[2017-08-31 19:18:34,562][ERROR][org.apache.curator.framework.recipes.leader.LeaderLatch] Can't find our node. Resetting. Index: -1 {{}}}}
> According to the [implementation|https://github.com/apache/curator/blob/4251fe328908e5fca37af034fabc190aa452c73f/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java#L529-L536], this can happen in two cases:
>  * When internal state `ourPath` is null
>  * When the list of latches does not have the expected one.
> I believe we hit the first condition because of races that occur after client reconnects to ZooKeeper.
>  * Client reconnects to ZooKeeper and LeaderLatch gets the event and calls reset method which set the internal state (`ourPath`) to null, removes old latch and creates a new one. This happens in thread "Curator-ConnectionStateManager-0".
>  * Almost simultaneously, LeaderLatch gets another even NodeDeleted ([here|https://github.com/apache/curator/blob/4251fe328908e5fca37af034fabc190aa452c73f/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java#L543-L554]) and tries to re-read the list of latches and check leadership. This happens in the thread "main-EventThread".
> Therefore, sometimes there is a situation when method `checkLeadership` is called when `ourPath` is null.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)