Skip to content

queryrange: fix panic in AnalyzesMerge due to wrong slice index#8701

Merged
GiedriusS merged 1 commit into
thanos-io:mainfrom
bejaratommy:fix/analyzes-merge-index-panic
Mar 9, 2026
Merged

queryrange: fix panic in AnalyzesMerge due to wrong slice index#8701
GiedriusS merged 1 commit into
thanos-io:mainfrom
bejaratommy:fix/analyzes-merge-index-panic

Conversation

@ricardbejarano

Copy link
Copy Markdown
  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

AnalyzesMerge incorrectly indexed the top-level 'analysis' variadic parameter instead of the loop-local 'elements' slice when accumulating execution times. When the analysis tree had more nodes than the number of analyses being merged, this caused an index-out-of-range panic.

This was reported in production environments running Thanos v0.37.2 and v0.38, where the query frontend would panic during response merging.

The fix replaces 'analysis[i]' with the correct 'elements[i]' and adds comprehensive test coverage for AnalyzesMerge, including the exact scenario that triggered the panic.

Fixes #8128

Verification

PR includes several tests.

AnalyzesMerge incorrectly indexed the top-level 'analysis' variadic
parameter instead of the loop-local 'elements' slice when accumulating
execution times. When the analysis tree had more nodes than the number
of analyses being merged, this caused an index-out-of-range panic.

This was reported in production environments running Thanos v0.37.2 and
v0.38, where the query frontend would panic during response merging.

The fix replaces 'analysis[i]' with the correct 'elements[i]' and adds
comprehensive test coverage for AnalyzesMerge, including the exact
scenario that triggered the panic.

Fixes thanos-io#8128
Signed-off-by: bejaratommy <[email protected]>
@bejaratommy
bejaratommy force-pushed the fix/analyzes-merge-index-panic branch from 9c872ed to 41efdcb Compare March 4, 2026 13:31
@ricardbejarano

Copy link
Copy Markdown
Author

@fpetkovski DCO fixed

@GiedriusS GiedriusS 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.

🙇

@GiedriusS
GiedriusS enabled auto-merge March 9, 2026 08:12
@ricardbejarano

Copy link
Copy Markdown
Author

@GiedriusS @fpetkovski I don't think any of the CI failures are related, are they?

@GiedriusS
GiedriusS merged commit d9d8884 into thanos-io:main Mar 9, 2026
33 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Querier Panic - index out of range [2] with length 2

4 participants