Hi Shay,
I have a question here. Why zk3 compare the zk1 vote first then zk2
one? What's the rule zookeeper would compare the votes?
Thanks.
Eric
On Sun, Oct 27, 2019 at 7:31 PM Lee Eric <openlinuxsource@gmail.com> wrote:
>
> Hi Shay,
>
> Thanks for your reply. It seems the PDF version has a typo on that
> part. Thank you for your clarifications.
>
> Eric
>
> On Sun, Oct 27, 2019 at 4:40 PM shay shimony <shayshim@gmail.com> wrote:
> >
> > Hi Eric,
> >
> > I checked the Leader Elections section in the ZooKeeper book of Junqueira and Reed,
and found that you have a mistake in the rules that you quoted  the '>' sign should be
'<':
> >
> > 1. If (voteZxid < myZxid) or (voteZxid = myZxid and voteId < mySid),
> > keep the current vote.
> > 2. Otherwise, change my vote by assigning myZxid to voteZxid and mySid to vote zxid.
> >
> > When z3 compares votes from z1(1, 6) and its current vote (3, 5), it changes its
vote to (1, 6).
> > Next, z3 compares (2, 5) and its current vote (1, 6), and keeps its current vote
(1, 6).
> >
> > After these 2 iterations z3 will send again its vote to z1 and z2  this time (1,
6).
> > Next, z3 and z1 form a quorum of 2, with z1 as leader and z3 as its follower.
> >
> > Hopefully z2 will be on the same page, similarly will join the quorum, and set itself
as follower of z1 as well (normally it will).
> >
> > Hope it helps,
> > Shay
> >
> > On Sun, Oct 27, 2019 at 8:11 AM Lee Eric <openlinuxsource@gmail.com> wrote:
> >>
> >> Hi,
> >>
> >> I have a dumb question about the way how zookeeper does leader election.
> >>
> >> There is a quorum zk1(1,6), zk2(2,5) and zk3(3,5). The number in
> >> parentheses is sid and latest zxid. So my question is, when each
> >> server sends out the vote to other 2, say, zk1 and zk2 send the votes
> >> to zk3. So zk3 has 2 votes (1,6) and (2,5). Now, based on the rules:
> >>
> >> 1. If (voteZxid > myZxid) or (voteZxid = myZxid and voteId > mySid),
> >> keep the current vote.
> >> 2. Otherwise, change my vote by assigning myZxid to voteZxid and mySid to vote
> >> Zxid.
> >>
> >> So what zk3 vote would be? I'm confused because to compare zk1 and
> >> zk3, the vote on zk3 is (1,6); but to compare zk2 and zk3, zk3 should
> >> keep its vote.
> >>
> >> So in this case, how the vote should be settled?
> >>
> >> Thanks.
> >>
> >> Eric
