I found that my question is basically the same as
http://zookeeper-user.578899.n2.nabble.com/Q-about-ZK-internal-how-commit-is-being-remembered-td4464847.html
but reading that thread still leaves me unclear as to my original question.
the following snippet from LearnerHandler.run() seems to be what the
newly-elected leader is doing, basically bringing up every follower to
its max committed proposal, and discard the rest.
---- if this is a correct understanding, then the P1 commit in my
original question seems to be lost. ??
Thanks
Yang
final long maxCommittedLog =
leader.zk.getZKDatabase().getmaxCommittedLog();
final long minCommittedLog =
leader.zk.getZKDatabase().getminCommittedLog();
LinkedList<Proposal> proposals =
leader.zk.getZKDatabase().getCommittedLog();
if (proposals.size() != 0) {
if ((maxCommittedLog >= peerLastZxid)
&& (minCommittedLog <= peerLastZxid)) {
packetToSend = Leader.DIFF;
zxidToSend = maxCommittedLog;
for (Proposal propose: proposals) {
if (propose.packet.getZxid() > peerLastZxid) {
queuePacket(propose.packet);
QuorumPacket qcommit = new
QuorumPacket(Leader.COMMIT, propose.packet.getZxid(),
null, null);
queuePacket(qcommit);
}
}
} else if (peerLastZxid > maxCommittedLog) {
packetToSend = Leader.TRUNC;
zxidToSend = maxCommittedLog;
updates = zxidToSend;
}
} else {
// just let the state transfer happen
}
On Tue, Jul 19, 2011 at 2:44 PM, Yang <[email protected]> wrote:
> like the first figure in the ZAB paper described,
> say we have node A B C, A is leader now
>
> all 3 nodes see proposals P1, P2, an all acked both,
> A sees acks for P1, and commits it, but right after this A dies.
>
> now B is elected, B does not see any commit, so (according to my
> possibly wrong understanding from the code)
> B throws away P1 P2, and starts a new epoch.
> is this the current behavior of code?
>
> but then the commit of P1 on A is lost?
>
> Thanks
> Yang
>