Repository navigation
Conversation
…that added them `MergeTreeCommitOrderSource` retires a finished read round of a `STREAM` query by returning the round's `Pipe` processors in `to_remove`. When the round's commit-order sort spills, `MergeSortingTransform::updatePipeline` adds merging and temporary-file processors connected to new ports of the `MergeSortingTransform` itself. They are recorded only in the executor graph and the shared processors list, never in the round's `Pipe`, so the round teardown destroyed the sort and left them in the pipeline, still connected to its freed ports. The processors profile log, which runs for failed queries too since ClickHouse#121503, then read freed memory through `Port::getProcessor` (heap-use-after-free found by the AST fuzzer). `ExecutingGraph` now records which node added each runtime processor and extends every removal group with the processors added (transitively) by its members, including ones added after the group was created. `removePendingGroup` throws `LOGICAL_ERROR` when a removed processor is still connected to a processor that stays, so a remover that leaves a dangling connection fails at removal instead of at a later reader. 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; 2 findings) plus my own cold review (3 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-10:20261011-051000 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20261011-040700 |
|
Workflow [PR], commit [acd3f55] Summary: ✅
AI ReviewSummaryPR #125158 removes runtime-expanded processors with their owning processor, preventing dangling port references when a spilled Final Verdict✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 15 s compile time in total, 8 of them have a recent master baseline. |
CI finish ledger - 476f865Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
All 165 check runs completed and Session id: cron:our-pr-ci-monitor:20261011-100007 |
Michicosun
left a comment
There was a problem hiding this comment.
That is too complex, we just need to increment not_finished in the removal group of the expanded processor.
Drop the removal-time connection check and the separate group-node set. When a processor that is already pending removal expands, its new processors join its removal group and increment `not_finished`. When a removal group is created, the processors its members added earlier join it as well: a spilling sort in a `STREAM` read round expands while it consumes, before `MergeTreeCommitOrderSource` queues the finished round for removal, so the increment alone does not cover this case (the new test still fails 10/10 with only the increment). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Simplified in acd3f55: the The increment alone does not cover this case: the sort spills while it consumes, so it expands before the round is queued for removal, when it has no removal group yet. Log of the test query on a build with only the increment: With only the increment the new test fails 10/10, so a new removal group also takes in the processors its members added earlier ( |
|
Will wait till executors v2 lands so we can fix in both places. |
|
OK, I'll leave it open until then. One data point for the timing: AST fuzzer keeps failing on this dangling-port read in |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Description
Related: #112320. Found by the AST fuzzer (amd_tsan): https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120758&sha=6829c431b4a3e2819e0f270d0ed168e8851ec545&name_0=PR&name_1=AST%20fuzzer%20%28amd_tsan%29
MergeTreeCommitOrderSourceretires a finishedSTREAMread round by returning the round'sPipeprocessors into_remove. When the round's commit-order sort spills,MergeSortingTransform::updatePipelineadds a merging transform and temporary-file source/sink connected to new ports of theMergeSortingTransformitself. Those are not in thePipe, so the executor destroyed the sort and kept them in the pipeline, still connected to its freed ports. Any later reader that follows a peer reads freed memory; the fuzzer hit it throughprocessors_profile_logof a cancelled query (failed queries are logged there since #121503).The V1
ExecutingGraphnow records which node added each runtime processor. A new removal group takes in the processors its members added earlier, and when a processor pending removal expands, its new processors join its group and incrementnot_finished.Validation: on master the new test gives the CI heap-use-after-free under ASan (freed by
~SortingTransformfrom the round teardown) and fails 17/17 randomized debug runs. With only the increment it still fails 10/10: the sort spills while it consumes, before the round is queued for removal. With the fix it passes 50/50 (debug), and theProcessors.*gtests pass.Raw timed log of the failing query (CI server log)
The read round that spilled was retired before the second round (
04:36:44) started; the exception callback then logged the processors profile and read the freed port.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/125158]