Skip to content

Fuzz functions from system table and update - #105550

Merged
PedroTadim merged 43 commits into
masterfrom
fuzz-functions
May 27, 2026
Merged

PedroTadim merged 43 commits into
masterfrom
fuzz-functions

Conversation

@PedroTadim

@PedroTadim PedroTadim commented May 21, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

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

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

  • Load available functions from system table instead of hardcoding them in the grammar in BuzzHouse.
  • For AST fuzzer, fuzz PASTE JOINs, swap ON and USING conditions, negative LIMIT (BY) and OFFSET, fuzz AggregateFunctionType, fuzz INTO OUTFILE clause.
  • New settings and swappable functions.
  • Added Polygon dictionaries to BuzzHouse.
  • For both fuzzers, do better lambda parameter fuzzing.

Version info

  • Merged into: 26.6.1.188

@clickhouse-gh

clickhouse-gh Bot commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5db5c66]

Summary: ⏳

job_name test_name status info comment
Stateless tests (amd_debug, parallel) FAIL
Received signal 6 (internal) (STID: 4793-48f3) FAIL cidb, issue ISSUE EXISTS
Stateless tests (amd_msan, WasmEdge, parallel, 1/2) FAIL
03772_temporary_files_codec FAIL cidb, issue ISSUE EXISTS
Stress test (amd_tsan) FAIL
Cannot start clickhouse-server FAIL cidb, issue ISSUE EXISTS
Check failed FAIL cidb IGNORED

AI Review

Summary

This PR modernizes BuzzHouse function/aggregate fuzzing by loading metadata from system.functions, switching many protobuf fields from enum-based function ids to string names, and expanding AST fuzzer mutations. The direction is good, but one new regression introduces deterministic parser exceptions for view replacement syntax, and two previously-discussed coverage regressions remain in current code.

Findings

❌ Blockers

  • src/Client/BuzzHouse/AST/SQLProtoStr.cpp:4345 CreateViewToString now always emits VIEW after CreateOrReplaceToString. Because CreateOrReplaceToString can emit REPLACE, this produces REPLACE [MATERIALIZED] VIEW ..., but the parser only accepts CREATE OR REPLACE ... VIEW (not standalone REPLACE VIEW). This creates deterministic parse exceptions whenever CreateReplaceOption::Replace is chosen for views.
    Suggested fix: for views, map CreateReplaceOption::Replace to CREATE OR REPLACE, or stop generating Replace in generateNextCreateView.

⚠️ Majors

  • src/Client/BuzzHouse/Generator/FuzzConfig.cpp:797 [dismissed by author -- https://github.com/Fuzz functions from system table and update #105550#discussion_r3282807089] Aggregate argument arity is still collapsed to {0,1,2} via count + two_arg_aggrs heuristic, ignoring many valid multi-argument aggregates (sequenceMatch, windowFunnel, retention, etc.). This still causes deterministic semantic exceptions and lower useful fuzz coverage.
  • src/Common/QueryFuzzer.cpp:5168 [dismissed by author -- https://github.com/Fuzz functions from system table and update #105550#discussion_r3288634835] INTO OUTFILE mutation still hardcodes /dev/null, which is typically outside user_files_path; this keeps producing immediate path-access exceptions instead of exercising output-format/compression paths.
Final Verdict

Status: ⚠️ Request changes
Minimum required actions:

  1. Make view replacement serialization parseable (CREATE OR REPLACE ... VIEW) for all view/materialized-view paths.
  2. Address deterministic aggregate-arity misgeneration (either by stronger metadata extraction or an explicit multi-arg allowlist for known aggregates).
  3. Make INTO OUTFILE mutation target an allowed path (for example a relative file under user_files_path) or gate mutation generation accordingly.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 21, 2026
@PedroTadim PedroTadim changed the title Fuzz functions and update Fuzz functions from system table and update May 21, 2026
Comment thread src/Common/QueryFuzzer.cpp Resolved
Comment thread programs/client/FuzzLoop.cpp Resolved
Comment thread src/Common/QueryFuzzer.cpp Resolved
Comment thread src/Common/QueryFuzzer.cpp Resolved
@PedroTadim

Copy link
Copy Markdown
Member Author

@groeneai the test 04043_system_asynchronous_inserts_user_filter failed from the 4135428ca59670af9cb6f7bd52b8791395840af4 commit CI run. Can you look and fix if needed?

@groeneai

Copy link
Copy Markdown
Collaborator

The 04043 failure on commit 4135428ca5 (2026-05-22 18:17 UTC, Stateless tests (amd_tsan, s3 storage, parallel, 2/2)) predates the master fix.

This was a chronic flaky tracked across 24+ unrelated PRs over 14 days. Root cause: AsynchronousInsertQueue::max_busy_timeout_exceeded() flushed the entry immediately when the query landed on an idle queue shard, before the visibility SELECT ran.

Master fix: #105759 (merged 2026-05-25 05:49 UTC). Pins async_insert_use_adaptive_busy_timeout=0, re-adds no-parallel, adds a 30s polling loop. CIDB shows 0 master failures on 2026-05-24 and 2026-05-25 vs 2/day on 2026-05-22 and 2026-05-23.

Rebase on latest master to pull in the fix.

@clickhouse-gh

clickhouse-gh Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.20% +0.10%
Functions 91.40% 91.40% +0.00%
Branches 76.60% 76.70% +0.10%

Changed lines: 17.17% (34/198) | lost baseline coverage: 171 line(s) · Uncovered code

Full report · Diff report

@PedroTadim
PedroTadim added this pull request to the merge queue May 27, 2026
@PedroTadim

Copy link
Copy Markdown
Member Author

There are opened issues for the CI failures, plus fixes on the way

Merged via the queue into master with commit 4c4e1b4 May 27, 2026
160 of 165 checks passed
@PedroTadim
PedroTadim deleted the fuzz-functions branch May 27, 2026 12:51
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 27, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Jun 8, 2026
…ous 04296

The Bugfix-validation framework reported that 04295 and 04296 do not
reproduce the SIGSEGV in `canSkipConversionToNullable` against master:
the natural race needs ZooKeeper fault injection plus aggressive concurrent
ALTER chaos that no stateless test can stage.

Add a dedicated `mt_mutate_task_can_skip_conversion_to_nullable_force_null_column_desc`
failpoint that forces `metadata_snapshot->getColumns().tryGet(...)` to return
null inside `canSkipConversionToNullable`. Pre-fix, the next line dereferences
the null `ColumnDescription*` at offset 0x90 (the `statistics` field), exactly
the address pattern from the original CI sighting on PR ClickHouse#105550. With the
existing `!column_desc ||` guard the optimization is simply skipped and the
mutation falls through to the normal rewrite path.

Rewrite 04295 as a deterministic regression test that toggles the failpoint
around an `ALTER MODIFY COLUMN y Nullable(UInt8)` on a table with
`STATISTICS(tdigest)`. On master without the guard the mutation worker
crashes the server with SIGSEGV at address 0x90 and the test diffs against
the reference. On the PR with the guard the optimization returns false, the
mutation completes through the normal path, the column type becomes
`Nullable(UInt8)` and data is preserved.

Drop 04296 (concurrent inserts shape) which never reproduced the bug
deterministically and was the second source of Bugfix-validation false
positives. The deterministic 04295 covers the regression strictly better.

Verified locally: 10/10 passes with the fix; the broken version (null guard
removed) raises SIGSEGV with `Address: 0x90. Access: read. Address not
mapped to object.` exactly matching the original signature from
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105550&sha=5db5c66a4c135950ddd8ac21fe895a693ae75bec&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29

Co-Authored-By: Claude Opus 4.8 <[email protected]>
pull Bot pushed a commit to admariner/ClickHouse that referenced this pull request Jun 9, 2026
`canSkipConversionToNullable` in `src/Storages/MergeTree/MutateTask.cpp`
calls `metadata_snapshot->getColumns().tryGet(command.column_name)` and
then dereferences the result without a null check. `tryGet` returns
`nullptr` when the column is missing from the metadata snapshot used by
the mutation task, which can happen under concurrent `ALTER DROP COLUMN`
in stress tests (see Issue ClickHouse#105912 from PedroTadim). The deref hits
address `0x90` (the offset of the `statistics` field in
`ColumnDescription`), matching the observed SIGSEGV signature.

Guard with the same `!column_desc || ...` pattern already used at the
sibling `READ_COLUMN` site (line 1173-1174) of the same file. When
`column_desc` is null, return `false` so this optimization is skipped
and the normal mutation path surfaces the error.

The new stateless regression test exercises the path through
`canSkipConversionToNullable` with `STATISTICS(tdigest)` and an
`ALTER MODIFY COLUMN ... Nullable(T)`, ensuring the function works in
the common case where statistics are present. The race itself was
observed in `Stress test (amd_tsan)` on PR ClickHouse#105550 and is not directly
reproducible from a stateless test because the in-tree safety check
`checkDropOrRenameCommandDoesntAffectInProgressMutations` blocks the
non-concurrent path.

Closes ClickHouse#105912
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.

3 participants