Skip to content

Cap select_parser_fuzzer max_parser_backtracks at 10000 - #104922

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-select-parser-fuzzer-timeout
May 14, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-select-parser-fuzzer-timeout

Conversation

@groeneai

@groeneai groeneai commented May 14, 2026 •

Copy link
Copy Markdown
Collaborator

Description / motivation

Cap select_parser_fuzzer's per-input max_parser_backtracks budget at 10000
via the .options file. This is a CI-only configuration fix; no source code
is changed.

Regression source. Commit
b5a006c49a7
("add parameters for select_parser_fuzzer, set default threshoulds lower",
2026-05-11) made the per-input limits configurable via
-ignore_remaining_args=1 -max_parser_backtracks=N. As a side effect, the
in-source default for max_parser_backtracks went from 5000 to
DBMS_DEFAULT_MAX_PARSER_BACKTRACKS (1000000) — a 200x increase.

For the sibling create_parser_fuzzer, the same author added the matching
.options entry in commit
e9453b722ae
("tune up create_parser_fuzzer settings") so that libFuzzer runs with
a fuzzer-safe 10000-step budget. The matching update to
tests/fuzz/select_parser_fuzzer.options was missed, so since 2026-05-11 every
PR running the libFuzzer check has been parsing each select_parser_fuzzer
corpus input with a 1,000,000-step budget. On pathological inputs (deeply
nested parentheses with mixed function-call / subquery shapes — exactly the
pattern of closed issue #92282) the parser spends 20-26s before bailing,
which is above the 20s libFuzzer timeout.

CIDB evidence. select_parser_fuzzer FAIL/ERROR rows in the last 30 days:

day fails distinct PRs
2026-04-19 1 1 (PR #99740, author's own branch)
... ... ...
2026-05-11 1 1 (PR #99740)
2026-05-13 24 24 (all unrelated PRs)
2026-05-14 13 13 (all unrelated PRs)

The 2026-05-13 spike is exactly the first master day after commit
b5a006c49a7 was merged. Every recent failure is a timeout-* artefact of
the form libFuzzer\ttimeout after 20-26 seconds, matching the symptom in
issue #92282.

Local mechanism reproduction (clickhouse local, debug build, same
input):

SELECT te(((...((SELECT tuple(... (~470 bytes, deeply nested malformed)
  --max_parser_depth=300 --max_parser_backtracks=10000   -> 0.16s (TOO_SLOW_PARSING)
  --max_parser_depth=300 --max_parser_backtracks=1000000 -> 0.92s (~6x slower)

Real select_parser_fuzzer corpus inputs are larger and amplify this ratio
to the 20-26s timeouts observed in CI.

Pre-PR validation gate.

  • Deterministic repro: yes — clickhouse local shows a 6x parse-time
    ratio on the same input as max_parser_backtracks goes from 10000 to
    1000000.
  • Root cause explained: yes — regression date matches commit
    b5a006c49a7 exactly; the .options override that was added for
    create_parser_fuzzer was missed for select_parser_fuzzer.
  • Fix matches root cause: yes — the change restores the 10000-step
    budget previously set in PR Fuzzers: select_parser_fuzzer - change max_parser_backtracks to 10.000 (was 1.000.000) #92325 to fix the timeout class in select_parser_fuzzer times out when parsing deeply nested parentheses #92282.
  • Test intent preserved: yes — same depth (300/150), same AST
    element / depth limits, same corpus and dictionary. Only the per-input
    backtrack budget changes.
  • Both directions demonstrated: yes — local repro shows the
    10000-vs-1000000 time difference; CIDB shows the regression spike
    aligned with the commit.

Refs:

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):

Not required (CI-only fix).

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.5.1.645

Commit b5a006c ("add parameters for select_parser_fuzzer, set default
threshoulds lower", May 11 2026) made the per-input parser limits in
`select_parser_fuzzer` configurable via `-ignore_remaining_args=1` plus
`-max_parser_backtracks=N`. As a side effect it changed the in-source
default for `max_parser_backtracks` from `5000` to
`DBMS_DEFAULT_MAX_PARSER_BACKTRACKS` (= 1,000,000), i.e. a 200x increase.

For sibling `create_parser_fuzzer`, the same author followed up with
commit e9453b7 ("tune up create_parser_fuzzer settings") that
restored a fuzzer-safe budget by adding

    [fuzzer_arguments]
    max_parser_backtracks = 10000

to `tests/fuzz/create_parser_fuzzer.options`. The matching update to
`tests/fuzz/select_parser_fuzzer.options` was missed, so `libFuzzer`
runs of `select_parser_fuzzer` parse each input with a 1,000,000-step
backtrack budget. On pathological inputs (deeply-nested parentheses
with mixed function-call / subquery shapes — exactly the pattern of
closed issue ClickHouse#92282) the parser spends 20-26s before bailing, which is
above the 20s `libFuzzer` timeout.

CIDB confirms the regression:

    day         select_parser_fuzzer FAIL/ERROR     distinct PRs
    2026-04-19  1                                   1 (PR ClickHouse#99740, author's branch)
    ...
    2026-05-11  1                                   1 (PR ClickHouse#99740)
    2026-05-13  24                                  24 (24 unrelated PRs)
    2026-05-14  13                                  13 (13 unrelated PRs)

The spike on 2026-05-13 starts exactly the first day master PRs picked
up commit b5a006c. Every recent failure is a `timeout-*` artefact
of the form `timeout after 20-26 seconds`, matching issue ClickHouse#92282.

The fix is the minimum config change to restore the previously known-
good per-input backtrack budget for `select_parser_fuzzer`, mirroring
the `create_parser_fuzzer.options` fix.

Local mechanism reproduction (clickhouse-local, debug build):

    SELECT te(((...((SELECT tuple(... (~470 bytes, malformed)
      --max_parser_depth=300 --max_parser_backtracks=10000   -> 0.16s (TOO_SLOW_PARSING)
      --max_parser_depth=300 --max_parser_backtracks=1000000 -> 0.92s (~6x slower for the same input)

Pre-PR validation gate:
- Deterministic repro: yes (see above).
- Root cause explained: yes (regression date matches commit b5a006c).
- Fix matches root cause: yes (restore 10k backtrack budget that was
  intentionally set in PR ClickHouse#92325 to fix the timeout class in ClickHouse#92282).
- Test intent preserved: yes — fuzzer still exercises the SELECT parser
  with the same depth (300/150), AST element / depth limits, and corpus.
  Only the per-input backtrack budget changes.
- Both directions demonstrated: yes — local clickhouse-local repro shows
  the 6x time difference; CIDB shows the regression spike exactly aligned
  with the commit.

Refs:
- Tracker issue ClickHouse#93438 ("libFuzzer tests are flaky").
- Originating closed issue ClickHouse#92282 (`select_parser_fuzzer` timeout on
  deeply nested parens).
- Sibling fix: commit e9453b7 (`create_parser_fuzzer.options`).
- Regression: commit b5a006c (`select_parser_fuzzer.cpp`).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @yakov-olkhovskiy @alexey-milovidov — could you review this? CI-only .options change that restores the 10000-step max_parser_backtracks budget for select_parser_fuzzer, mirroring the fix Yakov already applied to create_parser_fuzzer.options in e9453b722ae. Addresses the 24+ unrelated PRs/day timing out in libFuzzer since 2026-05-11, per @alexey-milovidov's directive on PR #100277. Session id: cron:clickhouse-ci-task-worker:20260514-094500.

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label May 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4dd814a]

Summary: ✅


AI Review

Summary

This PR adds a missing [fuzzer_arguments] override in tests/fuzz/select_parser_fuzzer.options so select_parser_fuzzer runs with max_parser_backtracks=10000 instead of inheriting the much higher default. I reviewed the current diff and prior PR discussion/threads, and I do not see unresolved correctness, safety, or CI-reliability issues in the change as it stands.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 14, 2026
@alexey-milovidov alexey-milovidov self-assigned this May 14, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue May 14, 2026
Merged via the queue into ClickHouse:master with commit 62f5a39 May 14, 2026
167 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 14, 2026
pull Bot pushed a commit to Haofei/ClickHouse that referenced this pull request May 18, 2026
The `tests/fuzz/select_parser_fuzzer.options` had `timeout = 20`, the
per-input libFuzzer wall-clock budget. Combined with the
`max_parser_backtracks = 10000` cap from PR ClickHouse#104922, this is fine on
release builds (the parser bails in ~0.16s on pathological deeply-nested
SELECT inputs) but not on ASan ARM CI runners: those exec at ~18-42/s,
so the parser needs >20s of wall time to hit the backtrack cap and abort
with `TOO_SLOW_PARSING`. libFuzzer kills the process first and reports
`timeout-*` artefacts.

Recent CIDB (test_name='select_parser_fuzzer', last 7 days) shows the
fuzzer failing on many unrelated PRs every day with timeouts of 20-29s,
matching this exact pattern. Example artefact from PR ClickHouse#96130:

  https://s3.amazonaws.com/clickhouse-test-reports/PRs/96130/8e0106f5809257b068a61a001f58042689b005ab/libfuzzer_tests/select_parser_fuzzer/timeout-49fccbae556e7a03ed5e64d5c08cb55653bb10ce

(524-byte malformed SELECT with deeply nested parens and WITH/SELECT
chains; reproduces the timeout class from closed issue ClickHouse#92282.)

Raising the per-input timeout to 60s gives the backtrack cap room to
fire on slow sanitizer/cross-arch runners while keeping a hard ceiling.
The cap, not the timeout, is what bounds real worst-case parse work; the
timeout just needs to outlive it.

Refs:
- Open issue ClickHouse#93438 ("libFuzzer tests are flaky").
- Closed issue ClickHouse#92282 (`select_parser_fuzzer` timeout on deeply nested
  parens) — same input class still surfacing on ASan ARM.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
alexey-milovidov pushed a commit to Onyx2406/ClickHouse that referenced this pull request May 19, 2026
…c OOMs

`create_parser_fuzzer` has been failing chronically with `libFuzzer
out-of-memory` for weeks, with the actual usage sitting just above the
hardcoded 6144 Mb limit. CIDB shows 55 OOM hits across 49 unrelated PRs
in the last 30 days (peaking at 17 hits / 17 PRs on 2026-05-17 alone).

The reported `used:` values cluster around 6221-7329 Mb (avg 6554 Mb,
p95 7329 Mb, max 8830 Mb). 54 of 55 observed OOMs (98%) fall under
8192 Mb. The 6144 limit is essentially at the typical working-set
mean for this fuzzer, so any input that triggers even moderate
extra allocations during parsing trips the limit.

Bump `rss_limit_mb` from 6144 to 8192 to match the chronic working set,
following the same precedent as PR ClickHouse#105134 which bumped `clickhouse_fuzzer`
from 2048 to 4096 for the same class of "just-barely-over-the-limit"
chronic OOMs.

The limit is still active (8 GB is not unlimited), so genuine large
memory regressions above 8 GB will still be caught.

Sibling change: PR ClickHouse#104922 (merged) bumped `select_parser_fuzzer`
via `max_parser_backtracks`. This PR addresses the parallel
`create_parser_fuzzer` family.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors 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.

4 participants