Issues in the Implementation of ReadIndex in TinyKV

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: TinyKV中ReadIndex实现的问题

| username: redgame

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 time out), with a probability of about 1/20. Checking the logs, I found that the test’s requests frequently encounter not_leader issues because the network instability often causes the leader to step down.

My analysis is that if my read-only requests go through log synchronization, 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?

| username: Billmay表妹 | Original post link

This issue might be caused by the implementation of ReadIndex. The implementation of ReadIndex can indeed lead to read-only requests being directly reported as errors and resent when switching Leaders, because ReadIndex forces the Leader to handle read requests instead of forwarding them to the new Leader. Therefore, in an unstable network environment, this might cause read-only requests to be continuously resent, leading to timeouts and not_leader issues.

If you want to resolve this issue, you can consider using Lease Read. Unlike ReadIndex, Lease Read does not force the Leader to handle read requests but forwards them to the new Leader. This way, during Leader switches, read-only requests can continue to be processed without being directly reported as errors and resent. Additionally, you can consider optimizing the network environment to reduce the frequency of Leader resignations, thereby reducing the number of times read-only requests are resent.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.