Description
Current LearnerHandler's syncFollower does not consider the situation that the proposal (0,0) is committed and snaped. It will not use snap to sync when minCommittedLog is 0.
The bug can be reproduced by modifying testNewEpochZxid in LearnerHandlerTest:
public void testNewEpochZxid() throws Exception { long peerZxid; db.txnLog.add(createProposal(getZxid(0, 0))); // Added db.txnLog.add(createProposal(getZxid(0, 1))); db.txnLog.add(createProposal(getZxid(1, 1))); db.txnLog.add(createProposal(getZxid(1, 2))); // After leader election, lastProcessedZxid will point to new epoch db.lastProcessedZxid = getZxid(2, 0); db.committedLog.add(createProposal(getZxid(0, 0))); // Added db.committedLog.add(createProposal(getZxid(1, 1))); db.committedLog.add(createProposal(getZxid(1, 2))); // Peer has zxid of epoch 0 peerZxid = getZxid(0, 0); // We should get snap, we can do better here, but the main logic is // that we should never send diff if we have never seen any txn older // than peer zxid assertTrue(learnerHandler.syncFollower(peerZxid, leader)); // Fail here