Repository navigation
Report the original error instead of CANNOT_WRITE_AFTER_BUFFER_CANCELED after a failed adaptive aggregation spill write - #128016
Conversation
Since ClickHouse#123531 the adaptive aggregator spills its staged records to one temporary stream per partition (`AdaptiveAggregationSession::SpilledPartition`), and every producer thread appends to it under the partition's mutex. When a write to such a stream throws (the temporary data limit, a failed write of the temporary file, a distributed cache write), `WriteBuffer::next` cancels the stream. The next producer that appends to the same partition then writes to a canceled buffer and gets `CANNOT_WRITE_AFTER_BUFFER_CANCELED`, and since `ExecutorTasks::rethrowFirstThreadException` reports the exception of the lowest-numbered executor thread, that secondary error often replaces the real one. The same error was reported for `00284_external_aggregation_2` with temporary data in the distributed cache. Remember the exception of a failed write in the partition and rethrow it to every later append, so the stream takes no more writes after a partial block and the query reports the error that broke it. Only the writes are covered: a failed stream creation leaves no stream behind, and the free space check throws before anything is written. The test makes the temporary data limit fail the writes. Before the change 10 of 10 runs report `CANNOT_WRITE_AFTER_BUFFER_CANCELED`, after it 100 of 100 report only `TOO_MANY_ROWS_OR_BYTES`. 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 review (1 nit).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261028-012500 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261028-005400 |
|
cc @nihalzp @KochetovNicolai, could you review this and add the |
|
Workflow [PR], commit [ca1defc] Summary: ❌
AI ReviewSummaryPR #128016, reviewed at Final VerdictStatus: ✅ Approve. |
CI finish ledger - ca1defcEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
All five stateless flaky check builds passed on this head, and Session id: cron:our-pr-ci-monitor:20261028-163006 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Description
Related: #123531. Reported in #109052 (comment):
00284_external_aggregation_2failed withCANNOT_WRITE_AFTER_BUFFER_CANCELEDwhile executingAggregatingTransforminStateless tests (amd_asan_ubsan, distributed cache, meta in keeper, s3 storage, parallel, 1/2)of the private sync run (https://github.com/ClickHouse/clickhouse-private/actions/runs/40430348969/job/121952004416).Since #123531 the adaptive aggregator spills its staged records to one temporary stream per partition (
SpilledPartition), which all producer threads append to under the partition's mutex. When one write to such a stream throws (the temporary data limit, a failed write of the temporary file),WriteBuffer::nextcancels the stream, and the next producer that appends to it getsCANNOT_WRITE_AFTER_BUFFER_CANCELED. The executor reports the exception of the lowest-numbered thread, so this secondary error often replaces the real one.SpilledPartition::appendnow keeps the exception of a failed write and rethrows it to every later append, so the stream takes no more writes after a partial block and the query reports the error that broke it. A failed stream creation and the free space check are unchanged: neither leaves a written stream behind. The change is master-only (SpilledPartitionis not in 26.10).This does not make that run green: if a failed write broke the stream there, as in the test, its next occurrence reports that error instead of 734.
The new test fails the writes with
max_temporary_data_on_disk_size_for_query: before the change 10 of 10 runs printCANNOT_WRITE_AFTER_BUFFER_CANCELED, after it 100 of 100 print onlyTOO_MANY_ROWS_OR_BYTES.The bucket files of
GraceHashJoinare also written by several threads and have the same masking; that is separate code and not changed here.Workflow [PR]
Sync PR [sync-upstream/pr/128016]