Reset election timer before the AppendEntries consistency check
@matnvd▲ 0 net votes
A failed consistency check still means the message came from a valid leader. If the timer reset happens after the rejection return, a follower that is catching up keeps timing out, starts elections, and disrupts the leader that is trying to repair it. Reset lastHeard, set state to Follower, and update the term before checking PrevLogIdx and PrevLogTerm.