Skip to content

count shared <initlabels> against every section's limit - #267

Merged
Watson1978 merged 2 commits into
fluent:masterfrom
kenhys:fix-initlabels-followup
Sep 1, 2026
Merged

count shared <initlabels> against every section's limit#267
Watson1978 merged 2 commits into
fluent:masterfrom
kenhys:fix-initlabels-followup

Conversation

@kenhys

@kenhys kenhys commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Before: the check ran in the constructor. Only a section with
ran it. A section without initialized true was never
checked. A section with max_series_per_metric 0 did not add its
to the shared count. In both cases the limit was already
full at startup. The section then dropped every record with a new label
set. The order of the sections changed the result as well.

After: take their slots even when the section has no limit.
The check runs for every section after all of them are built. A section
is refused at startup when the shared label sets do not fit its limit.
The order of the sections does not matter.

@kenhys

kenhys commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

This is follow-up of #266

@kenhys
kenhys force-pushed the fix-initlabels-followup branch 2 times, most recently from 63423e1 to 8714ccd Compare August 31, 2026 05:45
Before: the check ran in the constructor. Only a section with
<initlabels> ran it. A section without `initialized true` was never
checked. A section with `max_series_per_metric 0` did not add its
<initlabels> to the shared count. In both cases the limit was already
full at startup. The section then dropped every record with a new label
set. The order of the sections changed the result as well.

After: <initlabels> take their slots even when the section has no limit.
The check runs for every section after all of them are built. A section
is refused at startup when the shared label sets do not fit its limit.
The order of the sections does not matter.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
@kenhys
kenhys force-pushed the fix-initlabels-followup branch from 8714ccd to 0061160 Compare August 31, 2026 05:47
@kenhys
kenhys marked this pull request as ready for review August 31, 2026 05:49
@kenhys
kenhys requested a review from Watson1978 August 31, 2026 05:49
Comment thread lib/fluent/plugin/prometheus.rb Outdated
def check_series_limit!
return if @max_series_per_metric <= 0
# two <initlabels> blocks with the same values make one label set
held = @series_set.size

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reloading via /api/config.gracefulReload now fails.
The RPC returns {"ok":true} but the worker logs "metric X already holds 4 label sets from <initlabels> ... but max_series_per_metric is 3" and keeps the old config.

Before: the check counted every label set the metric held, and the set
stays on the client metric over a reload. A reload then failed with
"already holds N label sets from <initlabels>" even when the
configuration did not change. A section with no <initlabels> was refused
too, when another section with the same name had a wider limit.

After: the check counts only the label sets from <initlabels>. A reload
with the same configuration passes. Those read before the reload are
still counted, because the client still holds them.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
@Watson1978
Watson1978 merged commit db2e319 into fluent:master Sep 1, 2026
9 checks passed
@kenhys
kenhys deleted the fix-initlabels-followup branch September 2, 2026 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants