Skip to content

generator: fix drain old series on metric replacement to prevent limi… - #6653

Merged
carles-grafana merged 4 commits into
grafana:mainfrom
carles-grafana:fix-limiter-leak
Mar 12, 2026
Merged

generator: fix drain old series on metric replacement to prevent limi…#6653
carles-grafana merged 4 commits into
grafana:mainfrom
carles-grafana:fix-limiter-leak

Conversation

@carles-grafana

Copy link
Copy Markdown
Contributor

…ter leak

When a processor config change (dimensions, histogram buckets, etc.) triggers processor recreation, old metrics are replaced in the registry via registerMetric. Previously, the old metric's series were silently garbage-collected without calling OnDelete on the limiter, permanently inflating LocalSeriesLimiter.activeSeries. Each replacement accumulated more leaked counts, eventually pushing activeSeries above maxActiveSeries and trapping the tenant in permanent overflow.

Drain all old series through removeStaleSeries before replacing the metric, which properly calls OnDelete for each series and decrements the limiter's counter.

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]
…ter leak

When a processor config change (dimensions, histogram buckets, etc.)
triggers processor recreation, old metrics are replaced in the registry
via registerMetric. Previously, the old metric's series were silently
garbage-collected without calling OnDelete on the limiter, permanently
inflating LocalSeriesLimiter.activeSeries. Each replacement accumulated
more leaked counts, eventually pushing activeSeries above maxActiveSeries
and trapping the tenant in permanent overflow.

Drain all old series through removeStaleSeries before replacing the
metric, which properly calls OnDelete for each series and decrements
the limiter's counter.
Comment thread modules/generator/registry/registry.go Outdated
@carles-grafana
carles-grafana merged commit 9fd8c65 into grafana:main Mar 12, 2026
24 checks passed
carles-grafana pushed a commit to carles-grafana/tempo that referenced this pull request Mar 27, 2026
Add 3 entries that were missing from the unreleased changelog:
- [BUGFIX] grafana#6774: target_info skipped when resource attributes have empty values
- [BUGFIX] grafana#6653: drain old series on metric replacement to prevent limiter leak
- [ENHANCEMENT] grafana#6371: make trace_too_large log line an insight
carles-grafana added a commit that referenced this pull request Mar 27, 2026
Add 3 entries that were missing from the unreleased changelog:
- [BUGFIX] #6774: target_info skipped when resource attributes have empty values
- [BUGFIX] #6653: drain old series on metric replacement to prevent limiter leak
- [ENHANCEMENT] #6371: make trace_too_large log line an insight

Co-authored-by: Carles Grafana <carles@grafana.com>
mattdurham pushed a commit to mattdurham/tempo that referenced this pull request Jun 18, 2026
grafana#6653)

* generator: fix drain old series on metric replacement to prevent limiter leak

When a processor config change (dimensions, histogram buckets, etc.)
triggers processor recreation, old metrics are replaced in the registry
via registerMetric. Previously, the old metric's series were silently
garbage-collected without calling OnDelete on the limiter, permanently
inflating LocalSeriesLimiter.activeSeries. Each replacement accumulated
more leaked counts, eventually pushing activeSeries above maxActiveSeries
and trapping the tenant in permanent overflow.

Drain all old series through removeStaleSeries before replacing the
metric, which properly calls OnDelete for each series and decrements
the limiter's counter.

* fix lint: rename unused onAddFunc parameter to _

* remove unnecessary logging change, keep original log line

* use math.MaxInt64 instead of time.Now().Add(time.Hour) for drain timestamp
mattdurham pushed a commit to mattdurham/tempo that referenced this pull request Jun 18, 2026
Add 3 entries that were missing from the unreleased changelog:
- [BUGFIX] grafana#6774: target_info skipped when resource attributes have empty values
- [BUGFIX] grafana#6653: drain old series on metric replacement to prevent limiter leak
- [ENHANCEMENT] grafana#6371: make trace_too_large log line an insight

Co-authored-by: Carles Grafana <carles@grafana.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants