Skip to content

Commit

Permalink
update all region stats
Browse files Browse the repository at this point in the history
Close #3286, close #3558, close #3199

Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed Nov 24, 2021
1 parent 1c542d4 commit 07d9360
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ func (c *RaftCluster) processRegionHeartbeat(region *core.RegionInfo) error {
hotStat.CheckWriteAsync(statistics.NewCheckPeerTask(peerInfo, region))
}

statsJobs := []func(){func() { c.updateStats(region) }}
// Save to storage if meta is updated.
// Save to cache if meta or leader is updated, or contains any down/pending peer.
// Mark isNew if the region in cache does not have leader.
Expand Down Expand Up @@ -707,11 +708,10 @@ func (c *RaftCluster) processRegionHeartbeat(region *core.RegionInfo) error {
changedRegions := c.changedRegions
c.Unlock()

var statsJobs []func()
for _, item := range overlaps {
statsJobs = append(statsJobs, func() { c.clearStats(item) })
statsJobs = append([]func(){func() { c.clearStats(item) }}, statsJobs...)
}
c.statsJobCh <- append(statsJobs, func() { c.updateStats(region) })
c.statsJobCh <- statsJobs

if storage != nil {
// If there are concurrent heartbeats from the same region, the last write will win even if
Expand Down

0 comments on commit 07d9360

Please sign in to comment.