Skip to content

Revert "Make Ctrl+C terminate the output of a result set in the client promptly" - #107845

Merged
Algunenano merged 1 commit into
masterfrom
revert-106430-fix-22426-client-cancel-output
Jun 19, 2026
Merged

Algunenano merged 1 commit into
masterfrom
revert-106430-fix-22426-client-cancel-output

Conversation

@Algunenano

@Algunenano Algunenano commented Jun 18, 2026 •

Copy link
Copy Markdown
Member

@clickhouse-gh

clickhouse-gh Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3498571]

Summary: ❌

job_name test_name status info comment
Stress test (arm_debug) FAIL
Cannot start clickhouse-server FAIL cidb IGNORED
Logical error: 'Unexpected exception in refresh scheduling' (STID: 2508-34af) FAIL cidb IGNORED
Check failed FAIL cidb IGNORED

AI Review

Summary

This PR reverts ClickHouse/ClickHouse#106430, removing the WriteBufferFromFileDescriptor cancellation hook and the client call sites that installed it, and deleting the stateless test added for that reverted behavior. The revert matches the referenced TSAN failure surface: the data-racing std::function hook is gone and no setCancellationHook caller remains. I did not find any correctness, safety, or performance issue that needs an inline review comment.

Missing context / blind spots
  • ⚠️ The PR CI S3 summary for commit 3498571e7302defbd81c04828c69d6905d22623d currently reports 0 completed test rows, so I could not validate the revert with PR CI results; completed PR CI would close this gap.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jun 18, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.20% 85.30% +0.10%
Functions 92.30% 92.30% +0.00%
Branches 77.40% 77.50% +0.10%

Changed lines: Changed C/C++ lines covered by tests: 21/22 (95.45%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@Algunenano
Algunenano enabled auto-merge June 19, 2026 13:01
@Algunenano
Algunenano added this pull request to the merge queue Jun 19, 2026
Merged via the queue into master with commit 2e0f7f2 Jun 19, 2026
164 of 166 checks passed
@Algunenano
Algunenano deleted the revert-106430-fix-22426-client-cancel-output branch June 19, 2026 13:33
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 19, 2026
alexey-milovidov added a commit that referenced this pull request Jun 30, 2026
Addresses the AI review finding on #108078: `ClientBase::resetOutput`
calls `output_format->finalize()` before the output cancellation hooks
installed on `std_out`, the pager stdin and the
`INTO OUTFILE ... AND STDOUT` stdout buffer can be safely re-pointed.
That re-pointing has to wait until the parallel-formatting collector
that also reads the hook is joined - re-pointing the `std::function`
while that thread reads it is exactly the data race that reverted the
feature in #107845 - so it runs only after `output_format.reset()`. On
an exception path the interrupt handler is already stopped by then, and
the live hook returned `query_interrupt_handler.cancelled()`, which is
unconditionally true once the handler is stopped. So that `finalize()`
flush discarded the already-produced output even though the query was
never cancelled, truncating it on paths such as a `NetException` after
some result blocks but before `EndOfStream`.

Make the live hook lifetime-safe instead of re-pointing it: add
`QueryInterruptHandler::isRunning` (armed between `start` and `stop`)
and gate the hook on `isRunning() && cancelled()`. While the query runs
the handler is armed, so prompt Ctrl+C cancellation is unchanged; once
it is stopped during teardown the hook reports no cancellation, so the
`finalize()` flush preserves the output. The hook only reads atomics, so
it does not reintroduce the collector data race that re-pointing the
`std::function` would.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants