Raft(2) - Linearizability

Migo·2025년 2월 8일

Raft

목록 보기
2/2

Read Raft(1) if you haven't already.

Stale read

After the successful write operation, what would happen if client requests read?

Unless the write requests ALWAYS lands on to the master(which is not exactly performant), the following stale read can happen.

  • The client reads the value of A from the state machine on Follower2.
  • Since Follower2 has not yet committed to its state, the client reads stale data.

ReadIndex

If read index is used, this issue is mitigated as follows:

  • After committing the value A, the leader returns read index from current log offset.

  • the client starts to read A from Follower2 with read index.

  • Server3 first requests the read index from the leader

  • Since server3 has not committed x yet, its read index is less than the readIndex.

  • The follower contacts the leader to get the current ReadIndex (the latest committed index).

  • _Follower2 wait till its log offset ≥ read index

  • _Follower2 commits A in state machien, and its log offset increases by one.

  • As Follower2’s log offset matches the read index, it returns the value A

profile
Dude with existential crisis

0개의 댓글