Repository navigation
Run AST fuzzer oracle sub-queries on a thread group of their own context - #124547
Merged
PedroTadim merged 6 commits intoOct 15, 2026
Merged
Conversation
`executeASTFuzzerQueries` attaches the thread to a thread group of `fuzz_context`, which pins `max_rows_to_read = 100000` and `read_overflow_mode = 'break'`, and keeps it attached while `QueryOracleChecker::check` runs. Each oracle sub-query runs on a separate context from `makeOracleContext` (read caps off, overflow modes `throw`, `max_threads = 1`), but `executeQuery` does not switch the thread group for an internal query, so the thread's query context stays `fuzz_context`. With `make_distributed_plan = 1`, `QueryPlan::convertToDistributed` and `ReadFromDistributedPlanSource` take the context from the thread, and every stage task copies it. The stage tasks of an oracle sub-query then read under the fuzzed query's 100000-row 'break' cap: on the CI failure each of the 3 reader tasks stopped after 130818-196227 of 900000 rows, while the TLP reference was answered exactly by the trivial count, so the job reported a false `TLP Aggregate oracle mismatch`. The same leak hid the oracle's `max_threads = 1` pin and DQP's per-variant settings from the stage tasks. Attach each sub-query in `executeAndCollectSortedRows`, `executeScalar` and `executeWithSettings` to `ThreadGroup::createForQuery(oracle_context)` with a nested `ThreadGroupSwitcher` (`allow_existing_group = true`), which restores the fuzz group when the sub-query finishes, including on exceptions. Drop the comment in `executeASTFuzzerQueries` that claimed the oracle's nested queries run on `fuzz_context`. Related: ClickHouse#114043 Co-Authored-By: Claude Opus 5.5 <[email protected]>
… DQP The TLP Aggregate guard now also requires `DistributedPlanLocalExecution` on the metamorphic `countMerge` sub-query, so a plan that silently falls back to local execution no longer satisfies it (with `make_distributed_plan = 0` the guard prints 0). Each round also runs a seed without aggregates, so NoREC runs and its sub-queries go through `executeScalar`; a second guard asserts that NoREC ran. Removing the thread group switch from `executeScalar` now reds the test 10 of 10 (only NoREC mismatches). Rounds go from 8 to 16 so that the probability-gated DQP oracle also pins the `executeWithSettings` switch: removing it reds the test 9 of 10 (only DQP mismatches). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each fuzzed seed runs the whole oracle suite, and every oracle sub-query is bounded only by the oracle's `max_execution_time = 10`, so one heavy fuzzer mutation can take close to a minute on a debug build. The flaky check runs the test in parallel copies of itself and fails a non-`long` run over 180 s, so the test is tagged `long`, like 05099. DQP only detects a missing thread-group switch in `executeWithSettings` when a query reads past the fuzzed query's 100000-row cap. The second seed reads only the primary-key-pruned tail and never could, so the mutant that drops that switch went undetected in 3 of 20 runs. A full-table `max(id)` seed gives DQP a read past the cap in every round (`max` is not in the oracle's excluded aggregate lists, unlike `sum` and `avg`). With it the mutant is red in 29 of 30 runs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
Internal second-model review (rounds 1-3 of review)
|
Collaborator
Author
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-40:20261008-030400 |
Contributor
|
Workflow [PR], commit [ef0e915] Summary: ✅
AI ReviewSummaryThe change runs each AST fuzzer oracle sub-query in a thread group bound to its own context, so distributed stages receive the oracle's read limits, thread limits, and DQP settings. The regression test exercises the three execution helpers. No actionable findings in the current diff. Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested; current-head CI validation remains pending. |
1 task done
This was referenced Oct 10, 2026
On ASan with S3 storage in the flaky check, every TLP `countMerge` sub-query of one run exceeded the oracle's own 10 s `max_execution_time` (`TIMEOUT_EXCEEDED`), so no `QueryFinish` row matched and the test printed `TLP Aggregate checked 0`. Such a sub-query still ran under the distributed plan, so it counts too. The row count stays at 900000: with fewer rows a reader bucket would fit under the fuzzed query's cap, and the test would stop catching the bug. CI report: https://d1k2gkhrlfqv31.cloudfront.net/clickhouse-test-reports-private/praktika.html?PR=80005&sha=7ce92c97e2f259e87ff1ce0bf1b1999f9fa58f5d&name_0=PR PR: ClickHouse/clickhouse-private#80005 Related: ClickHouse#124547 Co-Authored-By: Claude Opus 5.5 <[email protected]>
PedroTadim
approved these changes
Oct 15, 2026
PedroTadim
enabled auto-merge
October 15, 2026 12:06
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.
Related: #114043 (comment)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Requested by @ alexey-milovidov on #114043:
AST fuzzer (amd_release, oracle)reportedTLP Aggregate oracle mismatchforSELECT count() FROM tab__fuzz_0 WHERE val = 'hit' WINDOW w AS ()withmake_distributed_plan = 1(report). No related open issue found. The masterTLP Aggregaterows of 2026-10-06 ran without the distributed plan and are a different defect (#113332).Root cause.
executeASTFuzzerQueriespinsmax_rows_to_read = 100000,read_overflow_mode = 'break'onfuzz_contextand keeps the thread attached to its thread group while the oracle runs. Each oracle sub-query has its own context frommakeOracleContext(caps off,throw,max_threads = 1), butexecuteQuerydoes not switch the thread group for an internal query.QueryPlan::convertToDistributedandReadFromDistributedPlanSourcetake the context from the thread, so every stage task of an oracle sub-query read under the fuzzed query's cap: in the CI log each reader task stopped after 130818-196227 of 900000 rows, while the reference was the exact trivial count.Change. Each sub-query in
executeAndCollectSortedRows,executeScalarandexecuteWithSettingsruns under a nestedThreadGroupSwitcheronThreadGroup::createForQuery(oracle_context), the mechanism the fuzzed query already uses. This also makes the oracle'smax_threads = 1and DQP's per-variant settings reach the stage tasks. The comment claiming the oracle runs onfuzz_contextis removed.Validation.
05339_ast_fuzzer_oracle_distributed_plan_read_capfails 10 of 10 randomized runs without the change and passes 50 of 50 with it; the existing oracle tests pass. If #117187 lands first, its executors need the same switch.Workflow [PR]
Sync PR [sync-upstream/pr/124547]
Workflow [PR]
Sync PR [sync-upstream/pr/124547]
Version info
26.10.1.2514-master(included in26.10and later)