Repository navigation
Conversation
The oracle runs its sub-queries with `executeQuery(istr, ostr, ...)` into a plain `WriteBufferFromOwnString` and compared the result with `MAX_ORACLE_OUTPUT_SIZE` only after the query had finished. The only in-flight cap, `max_result_bytes`, is checked by `LimitsCheckingTransform` against in-memory chunk bytes: a `LowCardinality` or constant 1 MiB `FixedString` holds its value once per chunk, while every row formats to ~2 MiB of TabSeparated (each NUL is escaped as `\0`). The string grows through `operator new`, which never refuses an allocation while `min_allocation_size_to_throw_on_memory_limit` is 0 (ClickHouse#117916), so neither the fuzz context's `max_memory_usage` nor `max_server_memory_usage` stops it, and the kernel memcg kills the server ("OOM in dmesg"). Seen in `AST fuzzer (amd_release, oracle)` on PR ClickHouse#122508 (sha 444c1ee, TLP DISTINCT reference `SELECT DISTINCT i, date, toFixedString(toLowCardinality('0.000065535'), 1048575) FROM t_read_in_order__fuzz_0 ...`, ~53 GB RSS against a 40.33 GiB cap) and on PR ClickHouse#113173 (sha cd98662, TLP WHERE reference). Collect the output in a `WriteBuffer` that throws `TOO_MANY_BYTES` from `nextImpl` as soon as the collected size would exceed the limit. Both callers already map `TOO_MANY_BYTES` to "skipped", so the oracle contract is unchanged and only the moment of detection moves; the post-execution size check is dead and removed. `AutoCanceledWriteBuffer` cancels the buffer when a different exception leaves it unfinalized. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the imprecise '(the output sits at exactly the cap)' parenthetical in makeOracleContext. 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 (3 nits, none blocking).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261012-123000 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20261012-114500 |
|
Workflow [PR], commit [5274e10] Summary: ❌
AI ReviewSummaryThis PR replaces the oracle's unbounded Missing context / blind spots
Final Verdict✅ No blocking issues found. |
CI finish ledger - 5274e10Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
CIDB has no other Session id: cron:our-pr-ci-monitor:20261013-023009 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Related: #122508
Related: #117916
Asked by @ alexey-milovidov on #122508:
AST fuzzer (amd_release, oracle)fails withOOM in dmesg, the server reaching ~53 GB RSS against a 40.33 GiBmax_server_memory_usage:In both runs the only active query was an oracle reference sub-query selecting a 1 MiB
LowCardinalityor constantFixedStringfrom every row of a table.The oracle formats each sub-query into an unbounded
WriteBufferFromOwnStringand checksMAX_ORACLE_OUTPUT_SIZE(10 MiB) only after the query finishes. The in-flightmax_result_bytescounts in-memory chunk bytes, where such a column holds its value once per chunk, while every row formats to ~2 MiB of TabSeparated. The string grows throughoperator new, which is tracked but never refused whilemin_allocation_size_to_throw_on_memory_limitis 0 (#117916), so the memcg kills the server.The oracle now collects the output in a
WriteBufferthat throwsTOO_MANY_BYTESas soon as it would exceedMAX_ORACLE_OUTPUT_SIZE. Both callers already treatTOO_MANY_BYTESas "skip this oracle", so the cap is unchanged and is only detected at 10 MiB instead of after tens of GiB; the dead post-execution check is removed. No test, as this is fuzzer-only code; the jobs above are the reproducer.Validation (debug build, server in a 16 GiB cgroup, seeds such as
SELECT DISTINCT i, d, toFixedString(toLowCardinality('0.000065535'), 1048575) FROM t WHERE d < '2020-01-05'withast_fuzzer_runs = 1, ast_fuzzer_oracle = 1): on master this seed OOM-killed 3 of 3 fresh servers within ~44 s. With the fix the server survived 500 seed runs, in which all 122 such reference sub-queries stopped withTOO_MANY_BYTES, peak memory 2.6 GB; an 8.6 MB reference still passed TLP WHERE, and04658_ast_fuzzer_oracle_tlp_aggregate_counterpassed 20/20 with randomized settings.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/125414]