In raft if a log replicated to majority, it is considered as committed in leader. Then leader send msg to follower to tell follower an entry become commit.If not, how and when follower know an entry become committed???
Another question,if an out of date can win an election in the following case? 5 nodes cluster, node A is the current leader.
A: 0 1 2 3 4
B: 0 1 2 3 4
C: 0 1 2 3 4
D: 0 1 2 3
E: 0 1
When node A (current leader) receive a request (entry 4), log it and replicated it to node B and node C. Then node A apply entry 4 in state machine and reply to client (In this point entry is considered committed by node B and node C or not ?). Then node A and node B crash, node D start new election vote itself and get vote by node E, then win the election. Will this case happen?
The AppendEntries RPC that the leader sends to followers includes the commit index, the followers can apply those log entries to their state machines when they receive this from the leader. The followers only ever gets a commit index from the leader, it never calculates it itself. If the leader fails, the new leader will calculate the relevant commit index and send it with its AppendEntries RPC calls.
For the election question, D can't win the election, it needs 3 votes to win, and it'll not get a vote from C. Eventually C will start an election and win it and continue as leader.