curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jordan Zimmerman (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CURATOR-47) Two leaders in the leader election recipe
Date Wed, 17 Jul 2013 17:53:47 GMT

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

Jordan Zimmerman commented on CURATOR-47:
-----------------------------------------

With a slight modification you will no longer see the "more than one leader" message. This
modification also exposes why you sometimes see the message in the first place. In the stateChanged()
method, change "if ( leader.get() == id )" to "if ( leader.getAndSet(NO_ONE) == id )".

The thing is that we are dealing with multiple threads and the OS's scheduler. Curator/ZooKeeper
is telling us that the connect is lost but it takes time for the semaphore notification to
take place. In this time, there is a slight possibility that another leader will be selected.
When Curator calls stateChanged() at THAT MOMENT you are no longer leader. 

Maybe there's a way I can improve this in Curator? I can't think of anything but I'm open
to suggestions.
                
> Two leaders in the leader election recipe
> -----------------------------------------
>
>                 Key: CURATOR-47
>                 URL: https://issues.apache.org/jira/browse/CURATOR-47
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Recipes
>    Affects Versions: 2.1.0-incubating
>         Environment: Windows and Java 1.7
>            Reporter: Germán Blanco
>             Fix For: TBD
>
>         Attachments: patch_test_rolling.patch, TestLeaderElection.java
>
>
> When using the Leader Election recipe and doing a rolling restart of the zookeeper servers
in the cluster, it seems that at some points there are two participants that see themselves
as leaders.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message