Skip to content

Commit

Permalink
store/tikv: fix data race caused by race fixing. (pingcap#5204)
Browse files Browse the repository at this point in the history
  • Loading branch information
disksing authored Nov 23, 2017
1 parent 69352a0 commit 90971a8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions store/tikv/region_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,9 @@ func (c *RegionCache) insertRegionToCache(r *Region) {
}
}

// getCachedRegion loads a region from cache, it drops the cached region if it
// was not accessed for a long time (maybe out of date).
// getCachedRegion loads a region from cache. It also checks if the region has
// not been accessed for a long time (maybe out of date). In this case, it
// returns nil so the region will be loaded from PD again.
// Note that it should be called with c.mu.RLock(), and the returned Region
// should not be used after c.mu is RUnlock().
func (c *RegionCache) getCachedRegion(id RegionVerID) *Region {
Expand All @@ -282,7 +283,6 @@ func (c *RegionCache) getCachedRegion(id RegionVerID) *Region {
atomic.StoreInt64(&cachedRegion.lastAccess, time.Now().Unix())
return cachedRegion.region
}
c.dropRegionFromCache(id)
return nil
}

Expand Down

0 comments on commit 90971a8

Please sign in to comment.