reload region cache when store is resolved from invalid status (#843)#846
reload region cache when store is resolved from invalid status (#843)#846cfzjywxk merged 12 commits intotikv:tidb-6.5from
Conversation
|
cannot build. |
|
Hold this PR because it may spawns too many goroutines. |
|
See the discussions in #843.
|
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: Smityz <smityz@qq.com> Co-authored-by: disksing <i@disksing.com> Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: disksing <i@disksing.com> Signed-off-by: you06 <you1474600@gmail.com>
d8bd792 to
3b066b5
Compare
| mockRequestLiveness atomic.Value | ||
| } | ||
|
|
||
| regionsNeedReload struct { |
There was a problem hiding this comment.
How about using a channel so Mutex could be saved and operations on the RegionCache are already synchronized?
There was a problem hiding this comment.
A channel is bounded, if it's full when trying scheduling a region to it, it'll wait(maybe the asyncCheckAndResolveLoop is doing something and cannot pull the channel immediately).
internal/locate/region_cache.go
Outdated
| for regionID := range c.regionsNeedReload.toReload { | ||
| c.reloadRegion(regionID) | ||
| delete(c.regionsNeedReload.toReload, regionID) | ||
| } |
There was a problem hiding this comment.
Look like those codes should be put after line #498 ?
There was a problem hiding this comment.
Delay the reload to next loop which avoids some errors and backoffs, see the comment of Line491 to Line494
Co-authored-by: crazycs <crazycs520@gmail.com> Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
3d629f8 to
98e21b3
Compare
Signed-off-by: you06 <you1474600@gmail.com>
| // insertRegionToCache tries to insert the Region to cache. | ||
| // It should be protected by c.mu.Lock(). | ||
| func (c *RegionCache) insertRegionToCache(cachedRegion *Region) { | ||
| func (c *RegionCache) insertRegionToCache(cachedRegion *Region, invalidateOldRegion bool) { |
There was a problem hiding this comment.
Need to comment about the new parameter.
|
What's wrong with golangci-lint 🤔️ |
|
@crazycs520 @ekexium @zyguan |
Cherry-pick #843 to tidb-6.5.