Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Zookeeper >> mail # dev >> Potential bug with Leader.TRUNC?

Copy link to this message
Potential bug with Leader.TRUNC?

In LearnerHandler, the code that sends TRUNC to the follower is shown below:

*                if (proposals.size() != 0) {
*                    if ((maxCommittedLog >= peerLastZxid)
                            && (minCommittedLog <= peerLastZxid)) {
                        packetToSend = Leader.DIFF;
                        zxidToSend = maxCommittedLog;
                        for (Proposal propose: proposals) {
                            if (propose.packet.getZxid() > peerLastZxid) {
                                QuorumPacket qcommit = new
QuorumPacket(Leader.COMMIT, propose.packet.getZxid(),
                                        null, null);
                    } else if (peerLastZxid > maxCommittedLog) {
*                        packetToSend = Leader.TRUNC;*
                        zxidToSend = maxCommittedLog;
                        updates = zxidToSend;
                } else {
                    // just let the state transfer happen
Why does it send a TRUNC only when the size of proposal's in memory is != 0?
What if after a new leader election,
the transaction log of the leader is empty (i.e., no proposals). If an old
leader tries to join and has higher transaction
ID recorded in its transaction log, then it won't truncate its transaction
log. I think with the right combination of zxid
of the transaction log and snapshot we might see this problem.

Am I misreading the code?