Fix root cause of nil return in queryWithRetry and labelsWithRetry#7375
Open
friedrichg wants to merge 1 commit intomasterfrom
Open
Fix root cause of nil return in queryWithRetry and labelsWithRetry#7375friedrichg wants to merge 1 commit intomasterfrom
friedrichg wants to merge 1 commit intomasterfrom
Conversation
When ingesterQueryMaxAttempts > 1 and the context is cancelled before the backoff loop starts, retries.Ongoing() returns false immediately and the loop never executes, causing both retry functions to return (nil, nil). This propagates ctx.Err() from the retry functions themselves so all callers are protected, and removes the caller-side nil guard added in #7369. Also aligns the early-return check in labelsWithRetry to use <= 1 consistently with queryWithRetry. Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com>
be6821e to
a1ed0ca
Compare
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.
Summary
ctx.Err()fromqueryWithRetryandlabelsWithRetrywhen the backoff loop exits without executing (e.g. context cancelled before the first attempt), preventing(nil, nil)returnsstreamingSelectadded by Fix nil when ingesterQueryMaxAttempts > 1 #7369, since the root cause is now fixed at the sourcelabelsWithRetryearly-return check to use<= 1consistently withqueryWithRetryContext
PR #7369 fixed the immediate panic in
streamingSelectby guarding against nil results at the call site. However the root cause — both retry functions returning(nil, nil)— was still present, leavinglabelsWithRetrycallers (LabelNames,LabelValues) silently returning empty results with nil error on cancelled context.Test plan
TestDistributorQuerier_Select_CancelledContextto assertcontext.Cancelederror (not just no-panic)TestDistributorQuerier_Labels_CancelledContextcoveringLabelNamesandLabelValueswith cancelled context andingesterQueryMaxAttempts > 1