feat(collector): clean up expired tables during hotspot detection#2369
Merged
empiredan merged 3 commits intoapache:masterfrom Mar 20, 2026
Merged
Conversation
8 tasks
acelyc111-bot
left a comment
There was a problem hiding this comment.
Review: Clean up expired tables during hotspot detection
Summary: Adds periodic cleanup of expired table analyzers in the hotspot partition detector, controlled by a new retention_period config (default 24h). Also fixes a TODO by using proper HostPort.Equal() comparison.
What's good:
- Clean implementation with proper goroutine lifecycle management (context + WaitGroup for graceful shutdown)
retireExpiredTablesuses a single lock acquisition per cleanup cycle — efficient- Expiration timestamp is set at analysis time (not creation time), so active tables never expire
- Bonus: Fixed the
TODO(wangdan)forHostPort.Equal()usage - Config validation ensures
RetentionPeriod > 0
Minor notes:
- The
checkExpirationticker interval equalsRetentionPeriod(24h default) — this means tables could live up to 2x retention period in the worst case. Consider using a shorter check interval (e.g.,RetentionPeriod / 4or a fixed 1h) for tighter cleanup. Not a blocker though. - Config file has some formatting cleanup (extra spaces removed) — fine, but ideally in a separate commit
Verdict: ✅ Approve — Well-structured, properly tested. Ready to merge.
foreverneverer
approved these changes
Mar 19, 2026
GehaFearless
approved these changes
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#2358
Currently, when collecting hotspot-related metrics, the Go collector only adds
new tables. If a large number of tables are deleted, the collector may still retain
those deleted tables in memory, leading to excessive memory usage.
This PR introduces a table cleanup mechanism: if no metric data has been collected
for a table over a prolonged period, the table will be removed to release the memory
it occupies.