Raft Protocol: Handling Uncommitted Entries and Leader Failure Scenarios

Hi, I was reading the Raft paper and was wondering about a failure scenario. Let’s say the leader receives a write from the client and appends the entry to its own log. This entry is NOT committed right now. The leader sends AppendEntries RPC to follower nodes and asks them to append the entry to their log. The followers reply with positive ack. The leader commits the entry to its own log now.

My question is:
Does the leader send +ve ack to the client right now? If ack is sent to client, than that would mean that the write is committed to a majority of servers, right? But in this case, it is still not committed to the follower nodes. If the leader crashes after sending ack to client but before sending the next AppendEntries to followers, there can be potential data loss right?

Just correct me if I am wrong. I want to make my understanding clear.

The followers write the entry to their log before sending the ack to the leader. If the leader were to fail after having received a quorum of acks, one of the followers would be elected the leader and the one which is elected must have this log entry based on the election protocol, which ensures that the newly elected leader is at-least as up to date as the followers. The newly elected leader may need to commit log entries which were previously not yet committed. The raft paper talks about how safety is maintained during an election: the index and term of the last entry in the candidates log is compared to that of the follower’s locally. If the terms are the same then the follower will vote for the candidate if the index is greater or equal. Otherwise it will vote for the candidate if its latest entry has a higher term than the follower’s

I see. Got it thanks. So it means that at a particular instant of time, the entry was committed only on the leader and the next leader is chosen based on the persistent state of the candidate log and not on the committed entries of the candidate log. I guess this is the case.