I’ve posted sample solutions here.
Consider the Raft replication system described in “In Search of an Understandable Consensus Algorithm” by Ongaro and Ousterhout. Suppose you have a five-server Raft system. Here’s the state of the servers’ logs. The notation T.N means the Nth log entry from term T. The servers are about to choose a new leader.
- S1: 3.1 4.1
- S2: 3.1 3.2
- S3: 3.1 5.1
- S4: 3.1 5.1 5.2
- S5: 3.1
Could any replica have already executed the operation in log entry 5.1?
Could operation 3.2 be committed in the future?
Could operation 4.1 be committed in the future?
A classmate points out that read-only operations could be executed much faster if the Raft leader alone executed them and sent the result back to the client, without sending such operations to the followers. After all, read-only operations don’t modify the state, so executing them on the followers is a no-op. Why might this idea lead to incorrect behavior?
Imagine that a set of 5 nodes perform a leader election, and node S1 is elected leader. Then imagine that leader S1 becomes partitioned from the remaining nodes (it cannot send or receive messages from them). After a sufficiently long period of time, will S1 still consider itself to be the leader, even though it hasn’t heard from the other nodes? If a client submits a request to this “leader”, what will happen?