Skip to content

Allow Unfinished Processor Removal in Query Runtime - #115625

Merged
Michicosun merged 3 commits into
masterfrom
allow_unfinished_processor_removal
Aug 21, 2026
Merged

Michicosun merged 3 commits into
masterfrom
allow_unfinished_processor_removal

Conversation

@Michicosun

@Michicosun Michicosun commented Aug 20, 2026 •

Copy link
Copy Markdown
Member

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):

This patch allows us to remove the pipeline subtree where not every processor has finished. In this case, the processor tree will not be removed until all processors have finished. This is needed for short FilterTransform circuit handling when this transform was not inlined into the streaming read round subpipeline's read step.


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

Version info

  • Merged into: 26.8.1.1854 (included in 26.8 and later)

@clickhouse-gh

clickhouse-gh Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c78b532]

Summary: ❌

job_name test_name status info comment
AST fuzzer (amd_debug, targeted, old_compatibility) FAIL
Logical error: Reading from materialized CTE 'A' before its materialization completed - DelayedPortsProcessor gate is missing in the query plan (STID: 2467-2c2d) FAIL cidb

AI Review

Summary

This PR teaches ExecutingGraph to defer physical removal of updatePipeline().to_remove processors until every processor in the detached subtree reaches Finished. The direction makes sense, but the runtime now accepts detached unfinished processors that stock prepare() implementations still assume are connected. I do not think this is safe to merge as-is.

Findings

❌ Blockers

  • [src/Processors/Executors/ExecutingGraph.cpp:219] to_remove is no longer limited to already-finished processors, but the rest of the processor contract still assumes detached boundary ports are never touched again. IProcessor::updatePipeline still documents to_remove as "disconnected finished processors" (src/Processors/IProcessor.h:250), and stock implementations rely on that: ISource::prepare() immediately calls output.isFinished() (src/Processors/ISource.cpp:31-44), which raises Port is not connected after the source has been detached. An unfinished source or transform that is still Ready/Executing when its subtree is parked will therefore raise an exception on the next prepare() instead of draining to Finished.
    Suggested fix: either keep the external ports logically closed/finished until the parked subtree drains, or restrict unfinished removal to processors whose prepare() is explicitly disconnect-safe and enforce that precondition in the executor.
Tests
  • ⚠️ The new gtest only exercises a custom transform that finishes from an internal downstream closure. Please add a regression that detaches an unfinished stock processor (ISource is the minimal case) so this path is proven not to hit Port is not connected on re-prepare.
Final Verdict

Not ready: the new runtime contract is broader than what existing processors support, so the first unfinished detached source/transform can turn this into a LOGICAL_ERROR.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 81.60% 87.00% +5.40%
Functions 91.40% 91.90% +0.50%
Branches 73.60% 79.30% +5.70%

Changed lines: Changed C/C++ lines covered: 157/164 (95.73%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Aug 20, 2026
@yariks5s yariks5s self-assigned this Aug 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing c78b53291 with master bddae8d72 (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
Binary Master PR Δ
programs/clickhouse-stripped 704.40 MiB 701.36 MiB -3.05 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Object file sizes

23 object files changed (+22.95 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Processors/Executors/ExecutingGraph.cpp.o 138.75 KiB 158.22 KiB +19.47 KiB (+14.03%)

737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

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

Job report

@Michicosun
Michicosun added this pull request to the merge queue Aug 21, 2026
Merged via the queue into master with commit b16561c Aug 21, 2026
349 of 352 checks passed
@Michicosun
Michicosun deleted the allow_unfinished_processor_removal branch August 21, 2026 12:52
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 21, 2026
alexey-milovidov added a commit that referenced this pull request Aug 21, 2026


Brings in #115800, which the
re-landed change needs: processors queued for removal were left in the graph
when `updatePipeline` returned `Cancelled`, or when more than one group became
removable between two prepared nodes.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov alexey-milovidov added the post-rejected Should've been rejected, but got merged. label Aug 21, 2026
valerypetrov pushed a commit to valerypetrov/ClickHouse that referenced this pull request Aug 21, 2026
Processor removal became deferred: `updatePipeline` only records
`update.to_remove` into a pending group and `updateNode` retires the group
once every processor in it reports `Finished`. Two paths leave a recorded
group behind, so the processors stay in the pipeline until the whole query
is destroyed:

- `updatePipeline` records the group and then returns `Cancelled`, which
  makes `updateNode` return before it reaches the code that retires groups;
- the retiring code handles a single group per prepared node, so a backlog
  can outlive the last `updateNode` call.

Retire every group that is ready instead of one, and also do it on the way
out when `updatePipeline` does not return `Done`.

This is what `Processors.UpdatePipelineMultipleCoordinatorsMultithreaded`
caught on master: it cancels the executor while 16 coordinators are cycling,
so one of them gets its removal stranded and an extra source is still alive
at the end of the test.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=b16561cc816cf56cadd0c35ed9ad48964ad7758d&name_0=MasterCI&name_1=Unit%20tests%20%28amd_llvm_coverage%29

Caused by: ClickHouse#115625

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

post-rejected Should've been rejected, but got merged. 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.

4 participants