[BUGFIX] Ingester: fix inflight query counter leak on resource rejection#7539
Open
sandy2008 wants to merge 2 commits into
Open
[BUGFIX] Ingester: fix inflight query counter leak on resource rejection#7539sandy2008 wants to merge 2 commits into
sandy2008 wants to merge 2 commits into
Conversation
Signed-off-by: Sandy Chen <Yuxuan.Chen@morganstanley.com>
4cb0968 to
92f7156
Compare
SungJin1212
reviewed
May 22, 2026
- Add clarifying comment before the post-rejection QueryStream block, per inline review nit. - Replace `i.resourceBasedLimiter = nil` with mutating the underlying mock monitor's heap utilization, so the same live limiter admits the second query. The regression test now exercises the limiter machinery on the retry instead of bypassing it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Sandy Chen <Yuxuan.Chen@morganstanley.com>
SungJin1212
approved these changes
May 22, 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.
What this PR does
Ingester.trackInflightQueryRequestincremented and trackedinflightQueryRequestsbefore callingresourceBasedLimiter.AcceptNewRequest(). If the resource limiter rejected the query, the helper returnedlimiter.ErrResourceLimitReachedwithout returning a cleanup callback or decrementing the counter.Symptom: each resource-rejected query permanently consumed one ingester inflight-query slot. Once enough rejections accumulated to reach
MaxInflightQueryRequests, later queries could be rejected witherrTooManyInflightQueryRequestseven after resource pressure dropped. The counter only recovered when the ingester restarted.Fix: run the resource-based admission check before incrementing and tracking the inflight query counter. Resource-rejected queries are not admitted as inflight work, so they no longer consume max-inflight capacity or inflate the max inflight metric. The regression test now enables
MaxInflightQueryRequests, verifies the counter remains zero after resource rejection, and verifies a later query succeeds once the resource limiter is disabled.Which issue(s) this PR fixes
Fixes #7538
Checklist
CHANGELOG.mdupdated —[BUGFIX] Ingester:entry undermaster / unreleased.make docnot required).Test_Ingester_Query_ResourceThresholdBreachednow covers the leaked inflight-query counter path.Test plan
git diff --check— cleango test -timeout 2400s -tags "netgo slicelabels" ./pkg/ingester -run '^Test_Ingester_Query_ResourceThresholdBreached$' -count=1— PASSgo test -timeout 2400s -tags "netgo slicelabels" ./pkg/ingester— PASSgo test -timeout 2400s -tags "netgo slicelabels" ./pkg/compactor -run '^TestPartitionCompactor_DeleteLocalSyncFiles$' -count=1— PASS locally after unrelated CI flake intest-no-race (amd64)