In raft paper section 5.4.2
If a leader crashes before committing an entry, future leaders will attempt to finish replicating the entry. However, a leader cannot immediately conclude that an entry from a previous term is committed once it is stored on a majority of servers. There could be a situation where an old log entry is stored on a majority of servers, yet can still be overwritten by a future leader.
The author mentioned that to avoid the situation above
To eliminate problems like the one in Figure 8, Raft never commits log entries from previous terms by counting replicas. Only log entries from the leader’s current term are committed by counting replicas; once an entry from the current term has been committed in this way, then all prior entries are committed indirectly because of the Log Matching Property.
But wouldn't the same problem still occur?
Given the following situation that the author provided
When S5
is elected leader it only looks at its current committed log which is (term3, index1)
and this is going to override term2
entries in all followers.
How does making a leader looking at its own committed log solve the problem?