After the fix did in
ZOOKEEPER-2355, the follower's transaction log might not be up to date, because with the fix in this patch, we will never do setlastProcessedZxid during a DIFF sync. For example imagine a case like this:
- Follower has its latest zxid with value a before DIFF SYNC happens.
- Leader send over proposals with zxids value b, c, d.
- Follower received and applied proposals b and c. Before follower had a chance to get hands on d, network partition happens.
- Now partition healed, follower will do a DIFF think again. Because the zk database would not be reloaded from logs (it's already initialized), follower has a skewed view of the world - it thinks it only has tnx a, but in fact it has a, b, and c. So rather asking b, c, and d, the follower could just ask d.
We should also set the zxid extracted from the current proposal packet after each proposal is committed. It is not functional critical and is an optimization because the idempotent nature of applying transactions.