Skip to content

fix(prometheus): bump nginx-lua-prometheus-api7 to 0.20260716 to fix 100% CPU loop on full shared dict - #13708

Merged
nic-6443 merged 1 commit into
apache:masterfrom
nic-6443:fix/prometheus-bump-nlp-0.20260716
Jul 20, 2026
Merged

nic-6443 merged 1 commit into
apache:masterfrom
nic-6443:fix/prometheus-bump-nlp-0.20260716

Conversation

@nic-6443

Copy link
Copy Markdown
Member

Description

Bumps nginx-lua-prometheus-api7 to 0.20260716, which fixes the infinite busy loop behind #12275 — workers pegged at 100% CPU on a full prometheus-metrics shared dict, unresponsive even after traffic is removed.

The root cause is in the library's KeyIndex:add(): once the shared dict is full, __ngx_prom__key_count can be LRU-evicted (it is an ordinary node, only refreshed when a new series is registered, so it goes cold under steady traffic). sync() then reads it as nil → 0, and every new series does dict:add() against an already-occupied slot → "exists" → retry the same slot → forever, without ever yielding. Full analysis, profiles and a standalone reproduction are in #12275 (comment).

The fix (api7/nginx-lua-prometheus#16, released as 0.20260716) advances the counter past the occupied slot on a repeated collision, so the next sync() adopts that slot's occupant and progress resumes; a hard cap makes it degrade to the existing dict-full error instead of spinning. The regression test lives with the fix in the library repo.

I ran t/plugin/prometheus*.t locally against the bumped dependency and the prometheus suites pass. The only failures are the pre-existing worker-events ... failed to receive the header bytes: closed shutdown-race flake, which reproduces identically on the current 0.20260623 pin and is unrelated to this change.

Which issue(s) this PR fixes:

Fixes #12275

Checklist

The bumped release fixes an unbounded retry loop in KeyIndex:add().
When the shared dict is full and __ngx_prom__key_count is LRU-evicted,
sync() reads it as 0 and add() retries the same already-occupied slot
forever, pegging the worker at 100% CPU independent of traffic. The new
version advances the counter past the occupied slot so the next sync()
adopts its occupant and progress resumes.
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. dependencies Pull requests that update a dependency file labels Jul 20, 2026

@membphis membphis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@nic-6443
nic-6443 merged commit 90617c4 into apache:master Jul 20, 2026
16 checks passed
@nic-6443
nic-6443 deleted the fix/prometheus-bump-nlp-0.20260716 branch July 20, 2026 06:29
@juzhiyuan juzhiyuan mentioned this pull request Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

help request: My APISIX is experiencing 100% CPU utilization and has become unresponsive

4 participants