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

invalidate all region cache on store when store id not found #170

Merged
merged 2 commits into from
May 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/main/java/org/tikv/common/region/RegionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,15 @@ public Pair<TiRegion, Store> getRegionStorePairByKey(
if (isReplicaRead) {
Peer peer = region.getCurrentFollower();
store = cache.getStoreById(peer.getStoreId(), backOffer);
if (store == null) {
cache.invalidateRegion(region);
}
} else {
Peer leader = region.getLeader();
store = cache.getStoreById(leader.getStoreId(), backOffer);
if (store == null) {
cache.clearAll();
}
}
} else {
outerLoop:
Expand Down Expand Up @@ -316,8 +322,8 @@ public synchronized void invalidateAllRegionForStore(long storeId) {

// remove region
for (TiRegion r : regionToRemove) {
regionCache.remove(r.getId());
keyToRegionIdCache.remove(makeRange(r.getStartKey(), r.getEndKey()));
regionCache.remove(r.getId());
}
}

Expand All @@ -340,5 +346,10 @@ public synchronized Store getStoreById(long id, BackOffer backOffer) {
throw new GrpcException(e);
}
}

public synchronized void clearAll() {
keyToRegionIdCache.clear();
regionCache.clear();
}
}
}