Skip to content

Commit

Permalink
fix race
Browse files Browse the repository at this point in the history
Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
  • Loading branch information
youjiali1995 committed Jan 21, 2021
1 parent 145037c commit 5c2da42
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion store/tikv/region_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ func (c *RegionCache) insertRegionToCache(cachedRegion *Region) {
// or hibernate timeout.
// To solve it, one solution is always to try a different peer if the invalid reason of the old cached region is no-leader.
// There is a small probability that the current peer who reports no-leader becomes a leader and TiDB has to retry once in this case.
if oldRegion.invalidReason == NoLeader {
if InvalidReason(atomic.LoadInt32((*int32)(&oldRegion.invalidReason))) == NoLeader {
store.workTiKVIdx = (oldRegionStore.workTiKVIdx + 1) % AccessIndex(store.accessStoreNum(TiKvOnly))
}
// Don't refresh TiFlash work idx for region. Otherwise, it will always goto a invalid store which
Expand Down

0 comments on commit 5c2da42

Please sign in to comment.