Repository navigation
AST fuzzer oracle: skip a nested LIMIT in a distributed plan - #130656
alexey-milovidov merged 2 commits into
Conversation
`AST fuzzer (amd_release, oracle)` reported a false TLP Aggregate mismatch on master for a query reading `(SELECT * FROM testoffset LIMIT 328)` after a seed test left `make_distributed_plan = 1` on in the fuzzer session. Under the distributed plan the subquery's LIMIT takes rows from one stream per reader bucket (`GatherReceiveStep` keeps one stream per source task even with `max_threads = 1`), and which rows fill the limit changes with the query built around it. The TLP partitions are three reads of the subquery under three filters, so each kept a different subset (30 + 222 + 0 = 252 vs 328). Every subset is a legal result of LIMIT without ORDER BY. Without the distributed plan the oracle reads one stream and the LIMIT keeps the same rows on each read. Skip the oracle when the query has LIMIT, OFFSET, LIMIT BY or LIMIT AFTER/UNTIL in any subquery and `make_distributed_plan` is on, and apply the same check in the definitions screen (view bodies, column expressions, row policies). A top-level row limit was already rejected. An unconditional nested-LIMIT gate was not used: nested-LIMIT queries without the distributed plan found real wrong-result bugs in the last 30 days. Validation (`clickhouse local`, 60 fuzzer rounds of the seed and 60 of the CI query): with `make_distributed_plan = 1`, 25 mismatches on master and 0 with this change; with it off, 0 on both and the same order of TLP Aggregate checks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the clause list from the hasRowLimitAnywhere comment; the condition below names the clauses. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (2 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-11:20261110-233001 |
|
cc @qoega, could you review this? With make_distributed_plan on, a LIMIT without ORDER BY in a subquery keeps rows that depend on the query built around it, so the three TLP partitions read different subsets and report a false mismatch; the oracle now skips a nested LIMIT/OFFSET/LIMIT BY in that mode, including in view bodies and row policies. |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-40:20261110-231200 |
|
Workflow [PR], commit [2fc28db] Summary: ✅
AI ReviewSummaryThe PR prevents false AST fuzzer oracle mismatches by skipping queries with row limits, including limits in stored definitions, when Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units7 translation units recompiled, 14 s compile time in total, 7 of them have a recent master baseline. |
fce5e5a
…e monolith The branch's previous master merge used a stale `origin/master`, so the PR still conflicted with the real current master. Merge current `origin/master` and re-resolve the two conflicted files (`QueryOracleChecker.cpp`/`.h`), keeping the branch's extracted `QueryOracles/` architecture and porting the genuinely-new master changes: - Ported `hasRowLimitInDistributedPlan` / `hasRowLimitAnywhere` and the `make_distributed_plan` setting extern, and wired the gate into `check` and the stored-definition screen (master #130656: a nested `LIMIT` under a distributed plan feeds one stream per source task, so the oracle's rewritten reads keep different rows — a false `TLP Aggregate` mismatch). - Ported the new `SHUFFLE` screen in the unstable-identifier gate (`SHUFFLE` returns rows in random order, a random subset with `LIMIT`). - Kept the branch's `referencesNonDeterministicEngineAnywhere` (covers `Distributed`/`Buffer`, superseding master's `referencesDistributedTableAnywhere`) and dropped master's duplicate top-level `WITH TOTALS` skip (the branch already has `hasGroupByTotalsModifierAnywhere`). - Dropped master's `recordReadParts`/`readPartsChanged`/`read_parts` from the header (superseded by `OracleExec::isStable`, as in the earlier merge). Co-Authored-By: Claude Opus 4.8 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Stop the AST fuzzer oracles from reporting false mismatches for a query with
LIMITin a subquery whenmake_distributed_planis enabled.Description
AST fuzzer (amd_release, oracle)failed on master with a TLP Aggregate mismatch(report)
on
SELECT count() IGNORE NULLS FROM (SELECT day + 365 AS day, * ... FROM (SELECT * FROM testoffset LIMIT 328)) WHERE ....A seed test's
SET make_distributed_plan = 1had stayed on in the fuzzer session.Under the distributed plan the
LIMITof the subquery takes rows from one stream per reader bucket(
GatherReceiveStepkeeps one stream per source task, even withmax_threads = 1), and which rows fill the 328changes with the query built around the subquery (deterministic per query, measured locally). The TLP partitions are
three reads of that subquery under three different filters, so each keeps a different subset: 30 + 222 + 0 = 252 rows
against 328 in the reference. Every subset is a legal result of
LIMITwithoutORDER BY, so the engine is fine; theoracle's assumption that a re-read keeps the same rows does not hold here. Without the distributed plan the oracle
reads one stream and the
LIMITkeeps the same rows each time.The change skips the oracle for a query with
LIMIT,OFFSET,LIMIT BYorLIMIT AFTER/UNTILin any subquerywhen
make_distributed_planis on, and applies the same check to the view bodies, column expressions and row policiesthe query reads. A top-level row limit was already rejected. Nothing changes without the distributed plan, so
nested-
LIMITqueries that found real bugs there stay covered.No test, as for #127078. Validation with
clickhouse local, 60 fuzzer rounds each of the seed and of the CI query:Code: 906mismatches withmake_distributed_plan = 1: master 25/120, this PR 0/120; with it off: 0/120 on both,with a similar number of TLP Aggregate checks (33 and 36).
Workflow [PR]
Sync PR [sync-upstream/pr/130656]
Version info
26.11.1.2045-master(included in26.11and later)