AppendEntries: truncate only at the first conflicting entry
@matnvd▲ 0 net votes
Loop over args.Entries and compare each index with the follower's log. At the first index that is past the end or has a different term, do rf.log = append(rf.log[:idx], args.Entries[j:]...) and break. Never truncate when entries already match, because a delayed old RPC could otherwise delete newer entries that were already accepted.