diff --git a/server/statistics/store_collection.go b/server/statistics/store_collection.go index a26126144e5..9b622b04e41 100644 --- a/server/statistics/store_collection.go +++ b/server/statistics/store_collection.go @@ -56,7 +56,10 @@ func (s *storeStatistics) Observe(store *core.StoreInfo, stats *StoresStats) { v = unknown } key := fmt.Sprintf("%s:%s", k, v) - s.LabelCounter[key]++ + // exclude tombstone + if store.GetState() != metapb.StoreState_Tombstone { + s.LabelCounter[key]++ + } } storeAddress := store.GetAddress() id := strconv.FormatUint(store.GetID(), 10) @@ -226,4 +229,5 @@ func (m *storeStatisticsMap) Collect() { func (m *storeStatisticsMap) Reset() { storeStatusGauge.Reset() clusterStatusGauge.Reset() + placementStatusGauge.Reset() } diff --git a/server/statistics/store_collection_test.go b/server/statistics/store_collection_test.go index cbdfdf4e2e8..eb1190c8352 100644 --- a/server/statistics/store_collection_test.go +++ b/server/statistics/store_collection_test.go @@ -39,6 +39,7 @@ func (t *testStoreStatisticsSuite) TestStoreStatistics(c *C) { {Id: 6, Address: "mock://tikv-6", Labels: []*metapb.StoreLabel{{Key: "zone", Value: "z3"}, {Key: "host", Value: "h2"}}}, {Id: 7, Address: "mock://tikv-7", Labels: []*metapb.StoreLabel{{Key: "host", Value: "h1"}}}, {Id: 8, Address: "mock://tikv-8", Labels: []*metapb.StoreLabel{{Key: "host", Value: "h2"}}}, + {Id: 8, Address: "mock://tikv-9", Labels: []*metapb.StoreLabel{{Key: "host", Value: "h3"}}, State: metapb.StoreState_Tombstone}, } storesStats := NewStoresStats() stores := make([]*core.StoreInfo, 0, len(metaStores)) @@ -64,7 +65,7 @@ func (t *testStoreStatisticsSuite) TestStoreStatistics(c *C) { c.Assert(stats.RegionCount, Equals, 0) c.Assert(stats.Unhealth, Equals, 0) c.Assert(stats.Disconnect, Equals, 0) - c.Assert(stats.Tombstone, Equals, 0) + c.Assert(stats.Tombstone, Equals, 1) c.Assert(stats.LowSpace, Equals, 8) c.Assert(stats.LabelCounter["zone:z1"], Equals, 2) c.Assert(stats.LabelCounter["zone:z2"], Equals, 2)