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

region_cache: fix issue that LocateKey may returns a wrong region #1299

Merged
merged 4 commits into from
Apr 18, 2024

Conversation

zyguan
Copy link
Contributor

@zyguan zyguan commented Apr 18, 2024

#1122 (comment) here we introduce an issue: if a region is marked as NeedDelayedReload, then we try to reload it by id and return the new region directly without checking the range, which may cause LocateKey returns a wrong region when the region is just splitted. To fix this issue, we can:

  1. always use loadRegion (by key)
  2. check the range of the new region (returned by loadRegionByID), call loadRegion if it doesn't contain the key

Here we prefer the first solution for simplicity.

internal/locate/region_cache.go Show resolved Hide resolved
Signed-off-by: zyguan <[email protected]>
@zyguan zyguan force-pushed the fix-locate-key-after-split branch from c8285ff to 3c67959 Compare April 18, 2024 09:39
@cfzjywxk cfzjywxk merged commit 09b120c into tikv:master Apr 18, 2024
10 checks passed
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.

4 participants