Skip to content

Remove execute_query_fuzzer, subsumed by clickhouse_fuzzer - #117140

Merged
yakov-olkhovskiy merged 7 commits into
masterfrom
remove-execute-query-fuzzer
Sep 3, 2026
Merged

yakov-olkhovskiy merged 7 commits into
masterfrom
remove-execute-query-fuzzer

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 30, 2026 •

Copy link
Copy Markdown
Member

clickhouse_fuzzer runs each fuzz input through a real clickhouse-local (mainEntryClickHouseLocal on a runner thread, fed via ClientBase::processQueryText), so it strictly covers everything execute_query_fuzzer does and more: client-side parsing and multi-statement splitting, input/output formats, DDL and INSERT with data, on-disk storage, and state that carries over between inputs.

execute_query_fuzzer calls DB::executeQuery directly against a DatabaseMemory-only context and executes only pulling pipelines - every non-SELECT pipeline is thrown away with onCancelOrConnectionLoss, so it cannot even populate a table to query.

Keeping both also costs real fuzzing time. The two targets are by far the slowest in the nightly libFuzzer tests job (~3-5 exec/s each under ASan), and each gets a fixed one-hour budget on a shared 16-vCPU runner. execute_query_fuzzer spent essentially all of it re-reading its own inputs: in the 2026-08-30 run it started fuzzing at 04:36:42 and wrote its first new corpus unit at 05:34:36, because it must replay 4436 persistent corpus units plus its execute_query_fuzzer.in seed directory, which is a copy of all 10418 tests/queries/0_stateless/*.sql files. Its corpus grew by 4.3 units per night over the last 59 nights, and it has not reported a finding since 2026-05-18.

clickhouse_fuzzer gets the all.dict dictionary that execute_query_fuzzer had and it did not, so the SQL keyword/function/type dictionary keeps being used for query-text fuzzing.

One follow-up for whoever merges this: fuzzer/corpus/execute_query_fuzzer.zip is left behind in the artifact bucket. It can be deleted, or merged into fuzzer/corpus/clickhouse_fuzzer.zip - the inputs are query text in both cases, so they are directly reusable.

Related: #117141
Related: #117142
Related: #117143
Related: #117144
Related: #117145

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Workflow [PR]
Sync PR [sync-upstream/pr/117140]

Version info

  • Merged into: 26.9.1.652 (included in 26.9 and later)

`clickhouse_fuzzer` runs each fuzz input through a real `clickhouse-local`
(`mainEntryClickHouseLocal` on a runner thread, fed via
`ClientBase::processQueryText`), so it strictly covers everything
`execute_query_fuzzer` does and more: client-side parsing and multi-statement
splitting, input/output formats, DDL and `INSERT` with data, on-disk storage,
and state that carries over between inputs.

`execute_query_fuzzer` calls `DB::executeQuery` directly against a
`DatabaseMemory`-only context and executes only pulling pipelines - every
non-`SELECT` pipeline is thrown away with `onCancelOrConnectionLoss`, so it
cannot even populate a table to query.

Keeping both also costs real fuzzing time. The two targets are by far the
slowest in the nightly `libFuzzer tests` job (~3-5 exec/s each under ASan),
and each gets a fixed one-hour budget on a shared 16-vCPU runner.
`execute_query_fuzzer` spent essentially all of it re-reading its own inputs:
in the 2026-08-30 run it started fuzzing at 04:36:42 and wrote its first new
corpus unit at 05:34:36, because it must replay 4436 persistent corpus units
plus its `execute_query_fuzzer.in` seed directory, which is a copy of all
10418 `tests/queries/0_stateless/*.sql` files. Its corpus grew by 4.3 units
per night over the last 59 nights, and it has not reported a finding since
2026-05-18.

Give `clickhouse_fuzzer` the `all.dict` dictionary that `execute_query_fuzzer`
had and it did not, so the SQL keyword/function/type dictionary keeps being
used for query-text fuzzing.

Note for whoever merges this: `fuzzer/corpus/execute_query_fuzzer.zip` is left
behind in the artifact bucket and can be deleted, or merged into
`fuzzer/corpus/clickhouse_fuzzer.zip` - the inputs are query text in both
cases, so they are directly reusable.
@clickhouse-gh

clickhouse-gh Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [61cd5bb]

Summary: ✅


AI Review

Summary

This PR removes execute_query_fuzzer and carries a few settings over to clickhouse_fuzzer. The timeout and max_query_size follow-ups fix earlier review points, but the replacement still is not equivalent: it drops some raw SQL-input coverage at the front door, and it leaves the accumulated execute_query_fuzzer corpus out of actual fuzzing unless someone performs a separate manual migration.

Findings

⚠️ Majors

  • [programs/local/fuzzers/clickhouse_fuzzer.cpp:427; programs/local/LocalServer.h:41; src/Client/ClientBase.cpp:3709-3866,5022-5037] Removing execute_query_fuzzer still drops part of the raw query-text contract. clickhouse_fuzzer feeds each unit through processQueryText, and clickhouse-local enables text-level client commands there, so inputs like \i ..., ls, help, exit, or a mistyped slash command are consumed before executeMultiQuery / executeQuery ever see the bytes. The old target guaranteed that every input exercised the SQL parser/executor; after this deletion, some inputs instead fuzz client front-end behavior and ambient file reads.
    Suggested fix: bypass processQueryText in the libFuzzer path and hand the buffer straight to the multi-query SQL path, or add a dedicated no-meta-command entrypoint before deleting the old target.
  • [tests/fuzz/build.sh:12-21; ci/jobs/libfuzzer_test_check.py:117-124] [dismissed by author -- https://github.com/ClickHouse/ClickHouse/pull/117140#discussion_r3889143805] The existing execute_query_fuzzer corpus is not handed over by this change; it stops participating in fuzzing as soon as the binary disappears. build.sh no longer emits any replacement query seed corpus, and download_corpus explicitly drops execute_query_fuzzer.zip as an orphan when there is no matching binary. Keeping the handoff as a manual “whoever merges this” note means the learned corpus disappears from real nightly coverage until somebody performs an out-of-band merge.
    Suggested fix: make the corpus migration part of this change itself, for example by merging or renaming the old corpus into clickhouse_fuzzer in the corpus job before removing the old binary.
Final Verdict

Changes requested. clickhouse_fuzzer is closer after the follow-up fixes, but the PR still removes SQL-fuzz coverage that is not actually preserved today.

LLVM Coverage Report

Measured on commit 61cd5bb.

Metric Baseline Current Δ
Lines 88.70% 88.70% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 81.00% 81.00% +0.00%

Changed lines: Changed C/C++ lines covered: 3/3 (100.00%) · Uncovered code

Full report · Diff report

Comment thread tests/fuzz/build.sh Resolved
@clickhouse-gh

clickhouse-gh Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 61cd5bbf6 with master a748a4544 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 15 s compile time in total, 7 of them have a recent master baseline.

Job report

@yakov-olkhovskiy yakov-olkhovskiy self-assigned this Aug 31, 2026
`clickhouse_fuzzer` runs a real `clickhouse-local`, so a fuzz input can
reach `url` or `s3` and block on a remote read. `--max_execution_time`
does not bound this: a stalled HTTP read is retried `http_max_tries`
times, each blocking for up to `http_receive_timeout`, and during query
analysis it cannot observe cancellation (the same failure mode described
in `ITableFunctionXDBC::getActualTableStructure`).

Against a server that accepts the connection and never replies,
`SELECT * FROM url(...)` takes 333 s with the current options and 1.1 s
with these four settings. The libFuzzer unit timeout for this target is
20 s, so without them such an input is reported as a timeout finding.

These settings were previously carried by `execute_query_fuzzer`, which
is removed in this pull request. `s3_retry_attempts` is deliberately not
carried over: it is deprecated by the server setting of the same name
and is already a no-op as a query setting.

Co-authored-by: Yakov Olkhovskiy <[email protected]>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ alexey-milovidov
❌ cursoragent
You have signed the CLA already but the status is still pending? Let us recheck it.

Comment thread tests/fuzz/clickhouse_fuzzer.options Resolved
`execute_query_fuzzer` called `executeQuery` with
`QueryFlags{ .internal = true }`, and that path zeroes `max_query_size`
for internal queries. `clickhouse_fuzzer` reaches `executeQuery` through
`LocalConnection`, which passes a default `QueryFlags{}`, so the normal
262144-byte limit applies and larger inputs are rejected at parse time.

This is not reachable today: `clickhouse_fuzzer.options` sets no
`max_len`, so libFuzzer derives the input ceiling from the corpus
(`SetMaxInputLen(clamp(MaxSize, 4096, 1 MiB))`) and the largest unit is
954 bytes, giving a 4096-byte ceiling. It becomes reachable as soon as
the `execute_query_fuzzer` corpus is handed over as the description
proposes: its largest unit is 286752 bytes, above the limit, so those
inputs would be dropped instead of transferring their coverage.

Verified against `clickhouse-local`: a 300 KB query through the same
multi-statement path the harness uses fails with `Max query size
exceeded` by default and succeeds with this setting.

Co-authored-by: Yakov Olkhovskiy <[email protected]>
Comment thread src/Interpreters/CMakeLists.txt Resolved
@yakov-olkhovskiy
yakov-olkhovskiy added this pull request to the merge queue Sep 3, 2026
Merged via the queue into master with commit 302f28f Sep 3, 2026
343 of 345 checks passed
@yakov-olkhovskiy
yakov-olkhovskiy deleted the remove-execute-query-fuzzer branch September 3, 2026 23:26
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants