Skip to content

Commit

Permalink
*: remove store statistics after store tombstone (tikv#7186)
Browse files Browse the repository at this point in the history
close tikv#7187

Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and lhy1024 committed Oct 12, 2023
1 parent c3d2ee7 commit e6e7c64
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
3 changes: 1 addition & 2 deletions pkg/mcs/scheduling/server/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,7 @@ func (c *Cluster) collectClusterMetrics() {
}

func (c *Cluster) resetMetrics() {
statsMap := statistics.NewStoreStatisticsMap(c.persistConfig)
statsMap.Reset()
statistics.Reset()

c.coordinator.GetSchedulersController().ResetSchedulerMetrics()
c.coordinator.ResetHotSpotMetrics()
Expand Down
7 changes: 4 additions & 3 deletions pkg/statistics/store_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func (s *storeStatistics) Observe(store *core.StoreInfo) {
case metapb.NodeState_Removed:
s.Tombstone++
s.Removed++
s.resetStoreStatistics(storeAddress, id)
return
}

Expand Down Expand Up @@ -261,7 +260,8 @@ func (s *storeStatistics) Collect() {
}
}

func (s *storeStatistics) resetStoreStatistics(storeAddress string, id string) {
// ResetStoreStatistics resets the metrics of store.
func ResetStoreStatistics(storeAddress string, id string) {
metrics := []string{
"region_score",
"leader_score",
Expand Down Expand Up @@ -317,7 +317,8 @@ func (m *storeStatisticsMap) Collect() {
m.stats.Collect()
}

func (m *storeStatisticsMap) Reset() {
// Reset resets the metrics.
func Reset() {
storeStatusGauge.Reset()
clusterStatusGauge.Reset()
placementStatusGauge.Reset()
Expand Down
8 changes: 5 additions & 3 deletions server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,10 @@ func (c *RaftCluster) BuryStore(storeID uint64, forceBury bool) error {
// clean up the residual information.
delete(c.prevStoreLimit, storeID)
c.RemoveStoreLimit(storeID)
c.resetProgress(storeID, store.GetAddress())
addr := store.GetAddress()
c.resetProgress(storeID, addr)
storeIDStr := strconv.FormatUint(storeID, 10)
statistics.ResetStoreStatistics(addr, storeIDStr)
if !c.isAPIServiceMode {
c.hotStat.RemoveRollingStoreStats(storeID)
c.slowStat.RemoveSlowStoreStatus(storeID)
Expand Down Expand Up @@ -2169,8 +2172,7 @@ func (c *RaftCluster) collectMetrics() {
}

func (c *RaftCluster) resetMetrics() {
statsMap := statistics.NewStoreStatisticsMap(c.opt)
statsMap.Reset()
statistics.Reset()

if !c.isAPIServiceMode {
c.coordinator.GetSchedulersController().ResetSchedulerMetrics()
Expand Down

0 comments on commit e6e7c64

Please sign in to comment.