Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid sending requests to unhealthy leader #503

Merged
merged 1 commit into from
Jun 13, 2022

Conversation

sticnarf
Copy link
Collaborator

It's an improvement for recovery time when hibernate region is enabled.

When we detect a TiKV store is unreachable, we only clear the region cache of regions on it. But it's not enough.

Considering one TiKV is unhealthy, all requests sending to that store will timeout. But due to hibernate region, the regions whose leaders are on the unhealthy store will not be re-elected until a request is sent to the follower.

If there are thousands of such regions, every time we are accessing a new region, it will send a request to the original leader on the unhealthy TiKV because the leader definitely does not change. And then, the user will always experience very long request duration until all regions are touched and elect new leaders.

So, this PR simply prevents sending requests to the leader that are on unhealthy TiKVs. To achieve this, the check loop is always enabled instead of only when forwarding is enabled.

@sticnarf sticnarf force-pushed the consider-health branch 3 times, most recently from 0336712 to b0d6592 Compare May 18, 2022 12:36
@sticnarf sticnarf marked this pull request as draft May 18, 2022 12:37
@sticnarf sticnarf force-pushed the consider-health branch 3 times, most recently from f99eb84 to b6dff0d Compare May 24, 2022 08:34
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
@sticnarf sticnarf marked this pull request as ready for review June 13, 2022 03:50
@sticnarf
Copy link
Collaborator Author

@youjiali1995 @MyonKeminta PTAL

@youjiali1995 youjiali1995 merged commit be31f33 into tikv:master Jun 13, 2022
sticnarf added a commit to sticnarf/client-go that referenced this pull request Jun 14, 2022
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
sticnarf added a commit to sticnarf/client-go that referenced this pull request Jun 14, 2022
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
sticnarf added a commit to sticnarf/client-go that referenced this pull request Jun 14, 2022
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
sticnarf added a commit to sticnarf/client-go that referenced this pull request Jun 14, 2022
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
youjiali1995 pushed a commit that referenced this pull request Jun 14, 2022
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
youjiali1995 pushed a commit that referenced this pull request Jun 14, 2022
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
youjiali1995 pushed a commit that referenced this pull request Jun 14, 2022
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants