Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statistic: fix the issue of tombstone for label counter (#2060) #2067

Merged
merged 2 commits into from
Dec 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion server/statistics/store_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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)
Expand Down Expand Up @@ -268,4 +271,5 @@ func (m *storeStatisticsMap) Collect() {
func (m *storeStatisticsMap) Reset() {
storeStatusGauge.Reset()
clusterStatusGauge.Reset()
placementStatusGauge.Reset()
}
3 changes: 2 additions & 1 deletion server/statistics/store_collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,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()
var stores []*core.StoreInfo
Expand All @@ -65,7 +66,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)
Expand Down