Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 线性一致性如何保证reader能读到最近的修改?
TiDB’s read index achieves linear consistency by reading the committed raft log with the highest number from the leader. Suppose the scenario is as follows:
- Thread 1 obtains commit_ts from PD and starts committing.
- Thread 2 obtains read_ts from PD and starts reading (commit_ts < read_ts).
- When thread 2 reads from the leader region, thread 1’s raft log has not yet been successfully committed (it might be in the process of replication).
In this case, wouldn’t the raft log index read by thread 2 not include the commit from thread 1? However, the read time of thread 2 is later than that of thread 1. What mechanism does TiDB have to avoid this scenario?