Accepted membership subqueries with hit counts can terminate the process
perfloop-oss/victorialogs · Uncatalogued correctness
https://perfloop.ai/t/oss/case_0xkkph4n78
Verdict
VERIFIED · settled 2026-11-22
What happened: The check fails before this change and passes with it.
Hypothesis
Accepted membership subqueries requesting unique values with hit counts can hand an extra output column to a value-only collector. The resulting background panic may terminate the query process. The submitter reports a default-configuration reproduction over one stored row; this session has source evidence, not an independently observed crash or deployed impact.
The submitter attributes the reproduction to a Perfloop correctness run on VictoriaLogs 34613acae0 and reports byte-identical lib/ and app/ trees against 857713bccf, with empty git diff --stat. They report a bounded sweep of six projection shapes at limits 0, 1 and 2 over one stored row. Fields-only, unique-only and explicit-projection controls passed, while the unprojected hit-count form failed with "BUG: expecting one column; got 2 columns" at storage_search.go:493. Those run and revision-equivalence reports remain unconfirmed here.
parseInQuery and getFieldNameFromPipes accept the described membership subquery ending in uniq by one field with hits: the uniq branch checks grouping-field count but not the added hit-count column (lib/logstorage/parser.go:3729-3783). The source subject is getFieldValuesGeneric at lib/logstorage/storage_search.go:458-521, including the supplied locality at line 491. It leaves a final uniq unchanged at 462-481, while its nonempty-block callback obtains all output columns and calls logger.Panicf unless exactly one exists at 486-505.
The producer appends the hits field alongside the grouping field (lib/logstorage/pipe_uniq.go:328-385) and forwards those columns downstream (511-524). Its flush launches output workers with wg.Go at 316-323. logger.Panicf invokes the panic path (vendor/github.com/VictoriaMetrics/VictoriaMetrics/lib/logger/logger.go:142-144,323-329), supporting the concern about a panic outside the HTTP handler's goroutine. The shipped local-storage query route reaches Storage.RunQuery through app/vlstorage/main.go:556-573. Membership and unique hit counts are documented in docs/victorialogs/logsql.md:1247-1281,4062-4096. These source facts support investigation, not an independently reproduced process exit.
The requested coverage is every accepted single-field subquery shape, including _stream_id subqueries, which share value collection through lib/logstorage/storage_search.go:1047-1063,1071-1087. A provisional smallest next check is isolated parser/output-contract and safe-handling assertions over that domain and the reported controls, without issuing a process-fatal query. Check that collection returns the requested field's values or unsupported shapes receive a normal parse error, and establish that accepted shapes cannot produce an escaping background panic. The checker layout is provisional, not an additional frozen repair requirement.
The bounded upstream review covered all 85 open PRs. Inspected implementation changes in https://github.com/VictoriaMetrics/VictoriaLogs/pull/1924, https://github.com/VictoriaMetrics/VictoriaLogs/pull/1857 and https://github.com/VictoriaMetrics/VictoriaLogs/pull/1685 concern tenant filters, subquery time ranges and sort/limit handling, respectively; they do not implement this collector's requested-field/output-shape repair. No separate review venue was identified from the contribution guidance. Recent merged-file history remains an evidence gap because the checkout is shallow and the bounded provider history read was refused.
Change to test: Ensure membership-subquery initialization returns the requested field's values or a normal parse error, never a panic in a background goroutine. When the last pipe is uniq with hits, collect only the requested field or reject unsupported shapes at parse time, covering every accepted single-field subquery shape including _stream_id.
Where it lives
perfloop-oss/victorialogs · app/vlselect/logsql/logsql.go
Evidence
The check fails before this change and passes with it: `Single-field membership subqueries ending in uniq with hits collect the requested field's values, including _stream_id, without the additional hit-count column causing a collector panic.`
Checks: 4 of 4 passed. Verification: no defect found.
Timeline
2026-11-22· Case opened