Skip to content

Commit

Permalink
add region cache state test & fix some issues of replica selector (#910)
Browse files Browse the repository at this point in the history
Signed-off-by: you06 <[email protected]>

remove duplicate code

Signed-off-by: you06 <[email protected]>
  • Loading branch information
you06 committed Aug 14, 2023
1 parent a0ac170 commit e2455c1
Show file tree
Hide file tree
Showing 5 changed files with 871 additions and 3 deletions.
4 changes: 3 additions & 1 deletion internal/locate/region_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,12 @@ func (c *RegionCache) Close() {
c.cancelFunc()
}

var reloadRegionInterval = int64(10 * time.Second)

// asyncCheckAndResolveLoop with
func (c *RegionCache) asyncCheckAndResolveLoop(interval time.Duration) {
ticker := time.NewTicker(interval)
reloadRegionTicker := time.NewTicker(10 * time.Second)
reloadRegionTicker := time.NewTicker(time.Duration(atomic.LoadInt64(&reloadRegionInterval)))
defer func() {
ticker.Stop()
reloadRegionTicker.Stop()
Expand Down
1 change: 1 addition & 0 deletions internal/locate/region_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -2014,6 +2014,7 @@ func (s *RegionRequestSender) onRegionError(
}

// This peer is removed from the region. Invalidate the region since it's too stale.
// if the region error is from follower, can we mark the peer unavailable and reload region asynchronously?
if regionErr.GetRegionNotFound() != nil {
s.regionCache.InvalidateCachedRegion(ctx.Region)
return false, nil
Expand Down
Loading

0 comments on commit e2455c1

Please sign in to comment.