Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: save leader_id if a higher term is seen when handling append-ent…
…ries RPC Problem: A follower saves hard state `(term=msg.term, voted_for=None)` when a `msg.term > local.term` when handling append-entries RPC. This is quite enough to be correct but not perfect. Correct because: - In one term, only an established leader will send append-entries; - Thus, there is a quorum voted for this leader; - Thus, no matter what `voted_for` is saved, it is still correct. E.g. when handling append-entries, a follower node could save hard state `(term=msg.term, voted_for=Some(ANY_VALUE))`. The problem is that a follower already knows the legal leader for a term but still does not save it. This leads to an unstable cluster state: The test sometimes fails. Solution: A follower always save hard state with the id of a known legal leader.
- Loading branch information