Repository navigation
Do not report progress of server-side AST fuzzer queries to the client - #124526
Conversation
The fuzz context is a `Context::createCopy` of the seed query's context, so it inherited the progress callback that `HTTPHandler` installed on the seed: every fuzzed query added its rows to the seed's `X-ClickHouse-Summary` and, with `send_progress_in_http_headers=1`, wrote `X-ClickHouse-Progress` headers to the seed client's socket. When the client was already gone (end of a stress run), a fuzzed header write failed, `WriteBufferFromHTTPServerResponse::onProgress` cancelled the seed's response and rethrew, the fuzz loop swallowed the exception, and the seed's `finalize()` then hit the cancelled buffer: `Logical error: 'Cannot finalize buffer after cancellation.'` (STID 2341-2d32), Stress test (arm_debug). Reset the progress and file-progress callbacks on the fuzz context, next to the existing `resetInputCallbacks()`, the same way the fuzzer already detaches the seed's ProcessList entry and transaction. 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; 2 findings) plus my own review (1 nit).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261008-000600 |
|
Workflow [PR], commit [ccdfc2b] Summary: ✅
AI ReviewSummaryThe PR isolates server-side AST fuzzer progress from the seed client's response, preserves HTTP disconnect cancellation during fuzzing and oracle checks, and skips secondary queries that inherit transport callbacks. Review of Missing context / blind spots
Final VerdictStatus: ✅ Approve. No new inline findings. Current-head CI should finish successfully before merge. |
Build profile diff (arm_release)Commit See the job log for details. |
|
The AI review is right: clearing the progress callback also drops the The loop stays bounded by the seed's |
|
@groeneai add to this PR |
Fuzz contexts no longer inherit the client's progress callback, and that callback chain is also where `cancel_http_readonly_queries_on_client_close` polls the HTTP peer. Without it a client that disconnects during fuzzing no longer stops the fuzz loop. `HTTPHandler` now also stores its peer check in the query context (`Context::setClientConnectedCallback`), and the fuzz loop polls it before each fuzzed query and from the fuzzed query's executor cancel callback, which are the points where the seed's KILL is checked. Measured with `readonly=2`, `ast_fuzzer_runs=300`, client closes at 0.3 s: the loop stops after 33-53 fuzzed queries (master: 28-42, previous commit: 300). With the client connected or the setting off, all 300 run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Done in 13277f4: |
The oracle's sub-queries run on copies of the fuzz context, which has no progress callback and does not carry the client-liveness callback, so a disconnected client's oracle phase ran to the end. Give the fuzz context a progress callback that only throws `QUERY_WAS_CANCELLED_BY_CLIENT` once the client is gone; every query on a copy of it now stops at its next progress. Oracle mode, `readonly=2`, `cancel_http_readonly_queries_on_client_close=1`, client closes at 3 s: the seed stops 0.02-0.13 s after the close (previous commit: 2.6-5.4 s, master: 5.3-7.6 s). With the client connected or the setting off nothing changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The fuzz context's progress callback throws QUERY_WAS_CANCELLED_BY_CLIENT when the client is gone, but QueryOracleChecker swallowed it like any other oracle execution error, so every remaining oracle of the current candidate still started and failed at its first progress tick. Propagate it from run_oracle and from the DQP variant guard, so the oracle phase stops at once and the fuzz loop exits at its next client check. Measured on a 20M-row DISTINCT seed with ast_fuzzer_oracle=1, readonly=2, cancel_http_readonly_queries_on_client_close=1, client closing at 2..11 s: before, 1-3 remaining oracles started after the close in 7 of 7 runs still fuzzing; after, 0 in 8 of 8. With the setting off, or the client connected, the oracles still run in full. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@groeneai 🕵️ The progress fix looks right to me. The same From reading the code (not run): on a worker of This is the same kind of inheritance this PR fixes for progress. Could the fuzz context drop all of them in one place, e.g. a |
A secondary query's context holds the callbacks its initiator's connection
installed for it (the read-task callback of a cluster function, block
marshalling, the merge tree read callbacks), and `Context::createCopy` hands
all of them to the fuzz context, so a fuzzed copy on a shard can reach back
into the initiator's query, e.g. by requesting a read task when the fuzzer
puts a cluster function into it. Collaborative workers were already skipped;
skip every secondary query in the same place instead of clearing the callbacks
one by one. Clearing them would not be enough: a fuzzed copy on a shard still
runs as a secondary query, so a fuzzed cluster function there would hit the
`LOGICAL_ERROR` in `getClusterFunctionReadTaskCallback()`.
The initiator still fuzzes the client's query. The skip is counted in the new
`ASTFuzzerSkippedSecondaryQuery` profile event.
Measured with `SELECT sum(number) FROM remote('127.0.0.1:<port>', numbers(1000))
SETTINGS ast_fuzzer_runs = 100, prefer_localhost_replica = 0`, 40 seeds: master
ran 88950 fuzzed queries (its shard fuzzes the seed's shard query, and the
fuzzer does not strip `ast_fuzzer_runs` from a copy's `SETTINGS`, so the shard
queries of fuzzed copies are fuzzed too), this change ran 4000 = 40 x 100, all
on the initiator. All 80 results were correct.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Checked. The Other secondary queries were still fuzzed, so I took the second option in ccdfc2b: With |
Backport #124526 to 26.10: Do not report progress of server-side AST fuzzer queries to the client
…-side AST fuzzer queries to the client
…fuzzer queries to the client
The test asserts that a repeated INSERT ... SELECT with the same insert_deduplication_token is deduplicated. The dedup block id depends on how the source read is chunked, so both inserts must produce the same chunks; the test pins the query-level read shape but not parallel replicas, which the ParallelReplicas jobs enable server-side. With a small randomized index_granularity (15 on ClickHouse#94017) the 20000-row source has 1333 marks. On s3-backed parts the replicas read it in 13 or 14 requests depending on timing, and when the two inserts make a different number of requests the chunks differ and the repeat is appended (40000 instead of 20000). Measured locally: 21 of 21 failing pairs had different request counts, 16 of 16 deduplicated pairs had equal ones; a different mark split alone does not break deduplication (local disk: 173 requests per insert, 0 of 400 runs failing). In the automatic parallel replicas runs of ClickHouse#120438 the first insert runs single-node and the second on parallel replicas, so those draws fail every rerun. CI: ClickHouse#94017 arm_binary ParallelReplicas s3 (22/53 reruns), ClickHouse#120438 amd_debug and arm_binary ParallelReplicas s3 (94/94, 50/50), ClickHouse#124526 arm_binary ParallelReplicas s3 (38/38). No master failure. Same fix as 05080_dedup_hash_lazy_replicated_column in ClickHouse#123943: skipped in the ParallelReplicas jobs, enable_parallel_replicas = 0 elsewhere. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Description
Fixes
Logical error: 'Cannot finalize buffer after cancellation.'(STID 2341-2d32) inStress test (arm_debug), e.g. PR #113776. No related open issue found.Root cause: the server-side AST fuzzer builds each fuzzed query's context with
Context::createCopyof the seed query's context, so it inherits the progress callback thatHTTPHandlerinstalled on the seed: fuzzed queries add their rows to the seed'sX-ClickHouse-Summaryand writeX-ClickHouse-Progressheaders to the seed client's socket. In CI the client was gone: a header write failed,WriteBufferFromHTTPServerResponse::onProgresscancelled the seed's response, the fuzz loop swallowed the error, and the seed'sfinalize()hit the cancelled buffer.Change: reset the progress and file-progress callbacks on the fuzz context, next to
resetInputCallbacks(), and do not fuzz secondary queries: their context also holds the callbacks the initiator installed (e.g. the read-task callback of a cluster function). Collaborative workers were already skipped; the initiator still fuzzes the client's query.The
cancel_http_readonly_queries_on_client_closepeer check ran inside that progress callback, soHTTPHandlernow also stores it in the query context (Context::setClientConnectedCallback). The fuzz loop polls it before each fuzzed query and from the executor cancel callback, and the fuzz context gets a progress callback that only throws once the client is gone, which also stops theast_fuzzer_oraclesub-queries;QueryOracleCheckerpropagates that cancellation.Validation: the new test checks that
SELECT number FROM numbers(10)withast_fuzzer_runs=10reportsread_rows10 in the summary and the progress headers (master 20/20 fail, fix 50/50 pass). A client disconnecting after the first progress header aborted a master debug server 3 of 4 times, 0 of 25 with the fix. Withreadonly=2and a client closing during fuzzing, the seed stops within 0.13 s (master withast_fuzzer_oracle=1: 5.3-7.6 s).🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/124526]
Version info
26.11.1.50-master(included in26.11and later)