Skip to content

Fix querier panic on tag value autocomplete with only metadata-only intrinsic conditions - #7705

Draft
zalegrala wants to merge 2 commits into
grafana:mainfrom
zalegrala:fix-tagvalues-empty-join-panic
Draft

Fix querier panic on tag value autocomplete with only metadata-only intrinsic conditions#7705
zalegrala wants to merge 2 commits into
grafana:mainfrom
zalegrala:fix-tagvalues-empty-join-panic

Conversation

@zalegrala

@zalegrala zalegrala commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What this PR does:

Fixes a querier panic when every condition in a tag value autocomplete request is a metadata-only intrinsic. SearchTagValuesV2 for span:id with query {trace:id="..."} crashes the process:

panic: runtime error: index out of range [0] with length 0
  pkg/parquetquery.(*JoinIterator).Next            iters.go:1052
  vparquet5.(*backendBlock).FetchTagValues.func2   block_autocomplete.go:281
  querier.(*Querier).SearchTagValuesV2Handler      http.go:317

span:id, span:startTime, trace:id and trace:start are skipped with a bare continue and contribute no iterator. When every condition is one of those, the span stage yields nil and createDistinctTraceIterator builds a JoinIterator over an empty slice, which indexes j.peeks[0] unconditionally.

NewLeftJoinIterator already rejects this shape; NewJoinIterator doesn't, and giving it an error return would touch ~45 call sites. So this fixes the two places that produce the degenerate input:

  • createDistinctTraceIterator returns nil, nil when it has nothing to join, matching createDistinctAttributeIterator.
  • The four autocompleteIter call sites skip a nil iterator. Required, not defensive — without it the same request panics on WAL blocks at wal_block.go:876.

Applied to vparquet3/4/5; identical code, all three reproduce. Behaviour change is limited to the crashing case: these requests now return no values, as these intrinsics already do elsewhere in this path.

Separately, these conditions are dropped rather than applied, so {trace:id="..."} returns tag values from other traces. Tracked in #7706; out of scope here.

Which issue(s) this PR fixes:

None filed; found from a production panic.

Checklist

  • Tests updated — cases in TestFetchTagValues plus a new TestWalBlockFetchTagValuesMetadataOnlyIntrinsics (WAL autocomplete had no coverage); all panic without the fix
  • Documentation added — n/a
  • Changelog entry added under .chloggen/

@zalegrala
zalegrala force-pushed the fix-tagvalues-empty-join-panic branch from 93fcba1 to 95e3034 Compare August 6, 2026 19:17
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.

1 participant