Skip to content

fix(compactor): Clean up stale bucket index metrics on ownership change#7487

Open
yeya24 wants to merge 1 commit intocortexproject:masterfrom
yeya24:fix/compactor-bucket-index-metric-cleanup
Open

fix(compactor): Clean up stale bucket index metrics on ownership change#7487
yeya24 wants to merge 1 commit intocortexproject:masterfrom
yeya24:fix/compactor-bucket-index-metric-cleanup

Conversation

@yeya24
Copy link
Copy Markdown
Contributor

@yeya24 yeya24 commented May 7, 2026

When a tenant's compactor ownership changes due to ring rebalancing, the old compactor's cortex_bucket_index_last_successful_update_timestamp_seconds metric was not being cleaned up. This caused the metric to have duplicate series (one stale from the old owner, one fresh from the new owner), triggering false alarms on bucket index update rate.

The fix ensures scanUsers() properly detects tenants that were previously owned but are no longer in the current owned set, and cleans up their metrics. Also extracts metric deletion into a reusable deleteUserMetrics() helper to reduce code duplication.

What this PR does:

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]
  • docs/configuration/v1-guarantees.md updated if this PR introduces experimental flags

When a tenant's compactor ownership changes due to ring rebalancing, the
old compactor's cortex_bucket_index_last_successful_update_timestamp_seconds
metric was not being cleaned up. This caused the metric to have duplicate
series (one stale from the old owner, one fresh from the new owner),
triggering false alarms on bucket index update rate.

The fix ensures scanUsers() properly detects tenants that were previously
owned but are no longer in the current owned set, and cleans up their
metrics. Also extracts metric deletion into a reusable deleteUserMetrics()
helper to reduce code duplication.

Signed-off-by: Ben Ye <benye@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant