Skip to content

Commit

Permalink
statistics: fix the memory leak of region statistics (tikv#8711) (tik…
Browse files Browse the repository at this point in the history
…v#8747)

close tikv#8710

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

Co-authored-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
ti-chi-bot and rleungx authored Oct 28, 2024
1 parent b54c794 commit 6d7be9a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/statistics/region_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
4 changes: 4 additions & 0 deletions server/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 6d7be9a

Please sign in to comment.