Raft Thought Question answers

2019/03/17

Could any replica execute log entry 5.1?

No. An operation cannot execute if it is not on a majority of the nodes.

Could operation 3.2 be committed in the future?

No. 3.2 could only be committed if S2 becomes the leader (any other leader would overwrite that index with another log). But S2 cannot become the leader because there is no majority where S3 has the most up-to-date log.

Could 4.1 be committed in the future?

Yes. Imagine that S1 becomes the next leader with votes from S1, S2, and S5.

Can the leader immediately reply to read-only requests?

No. The issue here is that if the leader becomes partitioned away from a majority of the nodes, that remote majority might elect a new leader. Thus the only way that the old leader can find out about this new election is by contacting a majority of the nodes (at least one of the nodes in that majority will know about the new election). Thus a leader must contact a majority of the nodes to serve out read-only requests.

Network partition question

The final question in the set of RAFT thought questions is an extension of the previous problem. In particular, having an “old” leader who doesn’t realize the new election has occured is not a problem, because any clients who try to submit or retrieve information from this outdated leader will not get a response. This is because the old leader has to contact a majority of the nodes before responding to the client. In doing that, if the old leader reaches any node with a higher term than it has, it will transition to a follower state, and tell the client that it isn’t the leader. If the old leader is entirely partitioned and can’t contact any other node, then it will not return anything to the client, which will eventually time out and try again (perhaps by contacting other nodes to see if they have more up-to-date information).