hi all,
I still has one problem with the uncommitted problem.
If we have a cluster with 3 nodes A,B,C and A as a leader.Initially,the commitIdx is 2,2,2 and nextIdx is 3,3,3.The a client sends a write to the leader and A appends the log entry into its own log and replicates it on B but not on C,as the number of replicas fulfill the majority requirement so A commits this log and replies to the client,but the AppendEntries to update commitIdx has not been sent to the two followers,so at this moment,the cluster status is:
commitIdx nextIdx
A 3 4
B 2 4
C 2 3
Now,the A crashes and C is elected as new leader as its commitIdx is biggest among B and C.And leader C will force the B to remove logs which C doesn't have.so the cluster becomes:
commitIdx nextIdx
A off off
B 2 3
C 2 3
If the client sends a read request to read the latest written value,we will not return it because the log(log index is 3) has been removed.