Skip to content

Commit

Permalink
fix the memory leak of region statistics
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Oct 15, 2024
1 parent c325311 commit 744b219
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/statistics/region_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ func (r *RegionStatistics) ClearDefunctRegion(regionID uint64) {
}
}
if oldIndex, ok := r.offlineIndex[regionID]; ok {
delete(r.offlineIndex, regionID)
r.deleteOfflineEntry(oldIndex, regionID)
}
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/statistics/region_collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 744b219

Please sign in to comment.