Repository navigation
Only drain the rest of the result after a local format error in the client - #128238
Conversation
…lient After a `LocalFormatError` (the client failed to create or write its output format), `receiveResult` sends `Cancel` but kept passing every remaining `Data` / `Totals` / `Extremes` packet to `onData` / `onTotals` / `onExtremes`. When the error came from `initOutputFormat`, `output_format` is null afterwards, so every remaining block built the output again: the pager was started again, the `INTO OUTFILE` file was opened again, and a failure that went away mid-result left an output with a gap while the client still exited with the first error. Since ClickHouse#127912 the binary-format question is asked again too, reading the stdin the first failed answer canceled (`LOGICAL_ERROR 'ReadBuffer is canceled'`, STID 2508-2bbd on master). A per-query flag is set where a `LocalFormatError` is created (the three sites: `initOutputFormat`, the write in `onData`, the background error check in `receiveResult`), checked at the top of the three result callbacks, and reset in `processParsedSingleQuery`. Setting it at the origins instead of in `receiveResult` also covers the `INSERT ... RETURNING` drain (`receiveEndOfQueryForInsert` calls the callbacks directly). `cancelled` is not reused: it would disable the receive timeout and Ctrl+C handling in the drain loop, skip waiting for the pager and print "Query was cancelled.". Requested by @PedroTadim in ClickHouse#128090 (comment) 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; 1 finding; plus my own review, 2 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261030-133300 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261030-122900 |
|
cc @azat @Avogar, could you review this and add the |
|
Workflow [PR], commit [181c8a7] Summary: ✅
AI ReviewSummaryThe client now skips further result formatting after a Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes26 object files changed (+268.75 KiB total), 3 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units21 translation units recompiled, 134 s compile time in total, 21 of them have a recent master baseline. |
958c7e7
Related: #128090
Related: #127912
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Follow-up requested in #128090 (comment).
After a
LocalFormatError(the client failed to create or write its output),receiveResultsentCancelbut still passed every remainingData/Totals/Extremespacket toonData/onTotals/onExtremes. When the error came frominitOutputFormat,output_formatwas null afterwards, so every remaining block built the output again:INTO OUTFILEfile was opened again for every block, and the pager was started again;Logical error: 'ReadBuffer is canceled. Can't read from it.'fromask<-initOutputFormat, which aborts debug builds: failing master job.A per-query flag is now set where a
LocalFormatErroris created (initOutputFormat, the write inonData, the background error check inreceiveResult), checked at the top of the three callbacks, and reset inprocessParsedSingleQuery. Setting it at these three sites rather than inreceiveResultalso covers theINSERT ... RETURNINGdrain, which calls the callbacks directly.cancelledis not reused: it would turn off the receive timeout and Ctrl+C handling while draining, skip waiting for the pager and print "Query was cancelled.". Theaskguard of #128090 is kept.The new test counts pager starts for a failing
FORMAT Templateover three one-row blocks: 1 with the fix, 4 without. Without the fix, #128090's scenario asks twice and aborts; with it, once.Not for changelog: the abort needs #127912, which is only on master; in 26.10 the rebuild only repeats work after an error the client already reports.
Workflow [PR]
Sync PR [sync-upstream/pr/128238]
Version info
26.11.1.1023-master(included in26.11and later)