[ https://issues.apache.org/jira/browse/ZOOKEEPER-1404?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13532664#comment-13532664 ]
Alexander Shraer commented on ZOOKEEPER-1404: --------------------------------------------- Edward, the intention wasn't "highest" but that client i watches the "highest sequence number j such that j < i", so highest which is still smaller than its own sequence number. The suggestion on the jira seems correct to me - otherwise everyone watch the znode of the current leader and wake up when it fails. > leader election pseudo code probably incorrect > ---------------------------------------------- > > Key: ZOOKEEPER-1404 > URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1404 > Project: ZooKeeper > Issue Type: Bug > Components: documentation > Affects Versions: 3.4.3 > Reporter: Robert Varga > > The pseudo code for leader election in the recipes.html page of 3.4.3 > documentation is the following... > {quote} > Let ELECTION be a path of choice of the application. To volunteer to be a > leader: > 1.Create znode z with path "ELECTION/guid-n_" with both SEQUENCE and > EPHEMERAL flags; > 2.Let C be the children of "ELECTION", and i be the sequence number of z; > 3.Watch for changes on "ELECTION/guid-n_j", where j is the > {color:red}*smallest*{color} sequence number such that j < i and n_j is a > znode in C; > Upon receiving a notification of znode deletion: > 1.Let C be the new set of children of ELECTION; > 2.If z is the smallest node in C, then execute leader procedure; > 3.Otherwise, watch for changes on "ELECTION/guid-n_j", where j is the > {color:red}*smallest*{color} sequence number such that j < i and n_j is a > znode in C; > {quote} > I think, in both third steps *highest* should appear instead of > {color:red}*smallest*{color}. -- 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