Skip to content

Commit

Permalink
cache: clean up pending peers.
Browse files Browse the repository at this point in the history
  • Loading branch information
disksing committed Mar 24, 2017
1 parent f46ce0b commit f9fc32a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ func (c *clusterInfo) handleRegionHeartbeat(region *regionInfo) error {
if len(region.DownPeers) > 0 || len(region.PendingPeers) > 0 {
saveCache = true
}
if len(origin.DownPeers) > 0 || len(origin.DownPeers) > 0 {
if len(origin.DownPeers) > 0 || len(origin.PendingPeers) > 0 {
saveCache = true
}
}
Expand Down
9 changes: 7 additions & 2 deletions server/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,13 @@ func (s *testClusterInfoSuite) testRegionHeartbeat(c *C, cache *clusterInfo) {
c.Assert(cache.handleRegionHeartbeat(region), IsNil)
checkRegions(c, cache.regions, regions[:i+1])

// Clear down and pending peers.
region.DownPeers, region.PendingPeers = nil, nil
// Clear down peers.
region.DownPeers = nil
c.Assert(cache.handleRegionHeartbeat(region), IsNil)
checkRegions(c, cache.regions, regions[:i+1])

// Clear pending peers.
region.PendingPeers = nil
c.Assert(cache.handleRegionHeartbeat(region), IsNil)
checkRegions(c, cache.regions, regions[:i+1])
}
Expand Down

0 comments on commit f9fc32a

Please sign in to comment.