Skip to content

Do not log a killed query's unused prefetch failure as an error in AsynchronousBoundedReadBuffer - #129275

Closed
groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:fix-abrb-killed-query-prefetch-log
Closed

groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:fix-abrb-killed-query-prefetch-log

Conversation

@groeneai

@groeneai groeneai commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #127149
Related: #113939

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Description

Since #127149, a TCP client's Cancel kills the query in the process list. Under parallel replicas the initiator sends Cancel as soon as LIMIT is satisfied, so this is routine in the ParallelReplicas, s3 storage jobs. An S3 GET of an in-flight prefetch that fails after the kill makes ReadBufferFromS3::processException rethrow the query's stored cancellation (CurrentThread::checkIfNotCancelled, #113939). Nothing consumes that prefetch, so ~AsynchronousBoundedReadBuffer drains it in finalize and logged it at Error. With send_logs_level the line reaches the client, and 03312_squashing_with_low_card_mem_usage failed with having stderror on two unrelated PRs (#128995, #128413):

<Error> AsynchronousBoundedReadBuffer: Code: 735. DB::Exception: Received 'Cancel' packet from the client, canceling the query: Cache info: ... (QUERY_WAS_CANCELLED_BY_CLIENT)

The destructor now logs at debug when the current thread's query is killed, as AsyncInsertQueueTransform already does since #127149. A failed unused prefetch of a live query is still logged at Error.

Not for changelog: #127149 and #113939 are only in master, not in 26.10.

Validation (debug build, MergeTree on an s3 disk with cache, a prefetching read): while it runs, I SIGSTOP a private MinIO, then SIGINT the client (the CI path, code 735) or run KILL QUERY (394), then SIGCONT. On master every valid trial logs such <Error> lines: 10/10 with SIGINT (2 to 82 lines), 5/5 with KILL QUERY, 5/5 with parallel replicas. With the fix, all 20 trials have no <Error> line from this logger, and the same exception appears at debug in each. No new test: the window needs a stalled object store, which a stateless test cannot produce.


Workflow [PR]
Sync PR [sync-upstream/pr/129275]

…ynchronousBoundedReadBuffer

When a query reading object storage with prefetch is killed (or its TCP client cancels it), an
in-flight prefetch can fail with the query's own stored cancellation: a failed S3 GET attempt makes
`ReadBufferFromS3::processException` rethrow it via `CurrentThread::checkIfNotCancelled`. The future of
that prefetch is never consumed, so `~AsynchronousBoundedReadBuffer` drains it in `finalize` and logged
it at error level; with `send_logs_level` the line also reached the client, which failed
`03312_squashing_with_low_card_mem_usage` with `having stderror` in the ParallelReplicas s3 jobs, where
the initiator cancels its replicas once `LIMIT` is satisfied. Log it at debug level when the current
thread's query is cancelled, as `AsyncInsertQueueTransform` already does for the same case.

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

groeneai commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

cc @CheSema @antonio2368, could you review this and add the can be tested label so CI runs? Since #127149 a client Cancel kills the query, so an unused in-flight S3 prefetch fails with the stored cancellation, which ~AsynchronousBoundedReadBuffer logged at Error (having stderror in the ParallelReplicas s3 jobs); it now logs at debug when the query is killed.

@clickhouse-gh

clickhouse-gh Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4acda13]


AI Review

Summary

AsynchronousBoundedReadBuffer now logs unused prefetch failures at debug when the current query is killed, retaining error for live queries and reads outside a query. Reviewed commit 4acda138540680bd59f450d26d7fac2ce294b823, the full modified file, cancellation propagation, and teardown lifetimes. No actionable findings. The documented before/after reproductions cover client cancellation, KILL QUERY, and parallel replicas; no local tests were run.

Final Verdict

✅ Approve.

@clickhouse-gh clickhouse-gh Bot added pr-not-for-changelog This PR should not be mentioned in the changelog can be tested Allows running workflows for external contributors comp-multidisk Multiple disks/volumes storage policies, disk abstractions. labels Nov 4, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 4acda1385 with master e0f4bac26 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 8 s compile time in total, 7 of them have a recent master baseline.

Job report

@Algunenano

Copy link
Copy Markdown
Member

@groeneai Let's add this patch to #129275 and close this one

@groeneai

groeneai commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Moved: the commit is on my fork branch for #129311, https://github.com/groeneai/ClickHouse/commits/reland-127149-ci-fixes (groeneai@213a5d0, same diff as this PR). Closing this one.

@groeneai groeneai closed this Nov 4, 2026
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 comp-multidisk Multiple disks/volumes storage policies, disk abstractions. pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants