Check isCanceled before calling eof on the input ReadBuffer in TCPHandler#100666
Merged
alexey-milovidov merged 1 commit intomasterfrom Mar 27, 2026
Merged
Check isCanceled before calling eof on the input ReadBuffer in TCPHandler#100666alexey-milovidov merged 1 commit intomasterfrom
isCanceled before calling eof on the input ReadBuffer in TCPHandler#100666alexey-milovidov merged 1 commit intomasterfrom
Conversation
…`TCPHandler` When waiting for a new query between requests, `TCPHandler::runImpl` calls `in->eof()` at line 495 to detect client disconnection. If the `ReadBuffer` was previously canceled (e.g., due to a failed read during a prior query's callback), calling `eof()` triggers `next()`, which hits `chassert(!isCanceled())` and aborts the server. Add an `in->isCanceled()` check before `in->eof()` in the condition, matching the pattern already used in `receivePacketsExpectCancel`. Also guard the `in->eof()` call in the `LOG_TEST` message to avoid evaluating it on a canceled buffer (function arguments are not short-circuit evaluated unlike `||`). https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=99537&sha=7338429ff8d3349ba147f9ba05558bbd6b84e4b2&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
|
Workflow [PR], commit [1aa7ce7] Summary: ✅ AI ReviewSummaryThis PR fixes a real correctness issue in ClickHouse Rules
Final Verdict
|
Contributor
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 100.00% (9/9, 0 noise lines excluded) |
Member
|
Similar #100536 |
1 task
Desel72
pushed a commit
to Desel72/ClickHouse
that referenced
this pull request
Mar 30, 2026
…anceled-eof-check Check `isCanceled` before calling `eof` on the input `ReadBuffer` in `TCPHandler`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When waiting for a new query between requests,
TCPHandler::runImplcallsin->eof()to detect client disconnection. If theReadBufferwas previously canceled (due to a failed read during a prior query's callback), callingeof()triggersnext(), which hitschassert(!isCanceled())and aborts the server.Add an
in->isCanceled()check beforein->eof()in the condition, matching the pattern already used inreceivePacketsExpectCancel. Also guard thein->eof()call in theLOG_TESTmessage to avoid evaluating it on a canceled buffer (function arguments are not short-circuit evaluated unlike||).This is a follow-up to #98955 and #99272 which fixed similar race conditions in callback paths.
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=99537&sha=7338429ff8d3349ba147f9ba05558bbd6b84e4b2&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29
Closes #100581
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes