diff --git a/server/statistics/region_collection.go b/server/statistics/region_collection.go index 7b354ce9f54..8d4d6d1849c 100644 --- a/server/statistics/region_collection.go +++ b/server/statistics/region_collection.go @@ -283,6 +283,7 @@ func (r *RegionStatistics) ClearDefunctRegion(regionID uint64) { } } if oldIndex, ok := r.offlineIndex[regionID]; ok { + delete(r.offlineIndex, regionID) r.deleteOfflineEntry(oldIndex, regionID) } } diff --git a/server/statistics/region_collection_test.go b/server/statistics/region_collection_test.go index 6f27443b24f..aa5a8399ab6 100644 --- a/server/statistics/region_collection_test.go +++ b/server/statistics/region_collection_test.go @@ -129,6 +129,10 @@ func TestRegionStatistics(t *testing.T) { stores[3] = store3 regionStats.Observe(region1, stores) re.Empty(regionStats.stats[OfflinePeer]) + + regionStats.ClearDefunctRegion(1) + re.Equal(1, len(regionStats.index)) + re.Equal(1, len(regionStats.offlineIndex)) } func TestRegionStatisticsWithPlacementRule(t *testing.T) {