Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 想请教下TinyKV中ReadIndex实现的问题
I implemented ReadIndex myself, but in the TestSplitConfChangeSnapshotUnreliableRecoverConcurrentPartition3B test, it causes read-only requests to report Request Time (after running four or five hundred times, I confirmed that only read-only requests timeout), with a probability of about 1/20. Checking the logs, I found that the test’s Request encountered a lot of not_leader issues because the network instability frequently caused the Leader to step down.
My analysis is that if my read-only request is synchronized through the Log, even if the Leader switches, my Log might still be committed and then returned. However, after implementing ReadIndex, switching the Leader causes read-only requests to directly report errors and resend, leading to read-only requests continuously resending in an unstable network environment.
I feel this might be the reason. If so, does it mean I can’t implement ReadIndex, or do you have any good ideas?