Skip to content

Attach the pipeline dump only to a logical error from building the executing graph - #125706

Merged
alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
groeneai:fix-executing-graph-build-error-pipeline-dump
Oct 17, 2026
Merged

alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
groeneai:fix-executing-graph-build-error-pipeline-dump

Conversation

@groeneai

@groeneai groeneai commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #121503

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

Found by Stress test (amd_tsan) on #118699 (report): Hung check failed, possible deadlock found. Three cancelled urlCluster secondaries of 04035_url_cluster_callback_cancel_race (25,902 processors each) hit an injected memory limit while their ExecutingGraph was built, then spent about 9 minutes in logProcessorProfile. Meanwhile the server went over its total memory limit, system log flushes and merges failed, and new connections were rejected.

The PipelineExecutor constructor appended a printPipeline dump, about 80 bytes per processor, to any exception from building the graph. The dump is for a LOGICAL_ERROR (a malformed pipeline); the only other error there is a failed allocation, which says nothing about the pipeline. Since #121503 the exception text is copied into every processors_profile_log row of the query, so the copied text is quadratic in the number of processors: 25,902 rows x 2.13 MB, about 55 GB per query here. Not all of it is resident at once, but enough is to get the server OOM-killed: Stress test (amd_debug) on #100377 (report), the same 25,902-processor query.

The dump is now attached only to a LOGICAL_ERROR; that case is unchanged. A new failpoint executing_graph_build_fail raises MEMORY_LIMIT_EXCEEDED from the ExecutingGraph constructor, and the new test checks that the error carries no dump (it fails without the change).

Validation (debug build, a 7,007-processor numbers_mt query with the failpoint): before, each of the 7,007 processors_profile_log rows carried a 565 KB exception, 3.96 GB in total, and the client got a 565 KB error; after, 120 bytes per row, 0.84 MB in total.

In a release build, a real LOGICAL_ERROR from a very large pipeline still copies the dump into every row; keeping the dump for that case is its purpose.


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

Version info

  • Merged into: 26.11.1.126-master (included in 26.11 and later)

groeneai and others added 2 commits October 13, 2026 22:31
…ecuting graph

The `PipelineExecutor` constructor appended a `printPipeline` dump to any
exception thrown while the `ExecutingGraph` was built. Besides a
`LOGICAL_ERROR` (a malformed pipeline, which the dump is for), the only
error there is a failed allocation, which says nothing about the pipeline,
while the dump costs ~80 bytes per processor.

Since ClickHouse#121503 the exception text is also copied into every
`processors_profile_log` row of the query, so the cost became quadratic in
the number of processors. In `Stress test (amd_tsan)` three cancelled
`urlCluster` secondaries with 25,902 processors each hit an injected memory
limit there, then spent ~9 minutes copying ~55 GB per query into the log
queue and pushed the server over its total memory limit.

Attach the dump only to a `LOGICAL_ERROR`. Add the
`executing_graph_build_fail` failpoint, which raises a memory-limit error
from the graph construction, and a test that such an error carries no dump.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the sentence in the PipelineExecutor ctor catch that only explained the new LOGICAL_ERROR guard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Oct 13, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review: my own cold review plus an independent model (engine: codex; 0 findings). 1 nit, no change.

# Sev Finding Verdict Evidence / action
1 💡 The new failpoint is REGULAR, so while enabled every executor fails; BuzzHouse can draw it from system.fail_points AGREE, not changed Errors only, no crash; same type as executing_graph_add_node_fail, and the test does not depend on which executor clickhouse-local builds first

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-48:20261013-223700

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes: SYSTEM ENABLE FAILPOINT executing_graph_build_fail; SELECT number FROM numbers(10) FORMAT Null in clickhouse-local carries Query pipeline: every time without the change.
b Root cause explained? The PipelineExecutor constructor appended a pipeline dump (about 80 B per processor) to any exception from building the ExecutingGraph; #121503 copies it into every processors_profile_log row, so the cost is quadratic in the processor count.
c Fix matches root cause? Yes: the dump is attached only to a LOGICAL_ERROR, the malformed-pipeline case it exists for.
d Test intent preserved / new tests added? New test 05394_executing_graph_build_error_no_pipeline_dump (failpoint positive control plus oracle); the LOGICAL_ERROR dump gtest and 05366 are unchanged and pass.
e Both directions demonstrated? Yes: the test fails without the change and passes with it (50/50); on a server a 7,007-processor query wrote 3.96 GB of exception text to processors_profile_log before and 0.84 MB after.
f Fix is general across code paths? Yes: the PipelineExecutor constructor is the only ExecutingGraph construction site and the only dump site for any code; the others raise only LOGICAL_ERROR.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A for types; every code except LOGICAL_ERROR loses the dump, verified at 7 and 7,007 processors.
h Backward compatible? (maintainer-approved exception only) Yes: no setting or format change; only the text of a non-logical graph-construction error gets shorter.
i Invariants and contracts preserved? Yes: the exception is still rethrown unchanged and the error path is the same.

Session id: cron:clickhouse-impl-slot-6:20261013-221300

@clickhouse-gh

clickhouse-gh Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9f112f7]

Summary: ✅


AI Review

Summary

PR #125706, reviewed at 9f112f7492e05b5768b99fdcfab505e554a22135, limits graph-construction pipeline dumps to LOGICAL_ERROR exceptions. This prevents allocation failures from producing large exception strings that are copied into every processors_profile_log row. No actionable findings.

Missing context / blind spots
  • ⚠️ Current-head CI is still running; completion will establish the final post-merge test result. The new regression test passed all 50 runs in the preceding revision's ARM ASan/UBSan targeted job. No local ClickHouse binary was available for an independent rerun.
Final Verdict

Status: ✅ Approve

@groeneai
groeneai requested review from novikd and vdimir October 13, 2026 23:02
@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Oct 13, 2026
@Michicosun

Copy link
Copy Markdown
Member

it can't be 55 gib, provide the proof

@groeneai

Copy link
Copy Markdown
Collaborator Author

55 GB (51.5 GiB) is the exception text copied into processors_profile_log rows for one query, N rows x L bytes. It is not memory held at one moment, and the query's tracker does not count it. The description did not say that; I fixed it.

L and N, from the CI query_log of the three secondaries (report); the last column is countSubstrings(exception, '[label='):

query_id                              type                      exception_code  length(exception)  dump_nodes
87bbfb6e-de61-4837-a939-f39e046aebdd  ExceptionWhileProcessing  241             2132896            25902
eb4329cd-5d96-41f0-8df8-6ab93814cdfd  ExceptionWhileProcessing  241             2132896            25902
28130575-4947-4701-8add-5729c21e7d53  ExceptionWhileProcessing  241             2132896            25902

logProcessorProfile sets processor_elem.exception = exception and then calls add(... element = processor_elem ...) once per processor (ProcessorsProfileLog.cpp#L139-L164). Every row gets its own copy: 25,902 x 2,132,896 B = 55,246,272,192 B per query. SystemLogQueue::add runs under MemoryTrackerBlockerInThread (SystemLogBase.h#L146-L153), which is why these queries report Query peak memory usage of 14.86-16.59 MiB.

The same path, measured locally (debug build of this branch with the PipelineExecutor.cpp hunk reverted, SYSTEM ENABLE FAILPOINT executing_graph_build_fail, a 7,007-processor numbers_mt query, processors_profile_log flush interval 600 s):

count()  max(length(exception))  sum(length(exception))
7007     565409                  3961820863

3,961,820,863 = 7,007 x 565,409. MemoryTracking grew by 3,835 MiB while those rows were queued. With the fix: 7007 / 120 / 840840.

In CI the 55 GB was never resident at once. The queue flushes every ~8 s, those flushes failed and dropped their rows, and RSS stayed at 40-50 GiB. Raw lines from clickhouse-server.stress.log:

processors_profile_log flushes, 22:50-22:59
2026.10.13 22:50:23.868833 [ 3864 ] {} <Trace> SystemLog (system.processors_profile_log): Flushing system log, 236 entries to flush up to offset 94902
2026.10.13 22:50:24.372004 [ 3864 ] {} <Trace> SystemLog (system.processors_profile_log): Flushed system log up to offset 94902. Entries 236. Timings: Prepare=0ms, Block=29ms, Insert=467ms, Confirm=5ms
2026.10.13 22:52:19.858719 [ 3864 ] {} <Error> ... Failed to flush system log system.processors_profile_log with 1116 entries up to offset 96018: Code: 241. DB::Exception: (total) memory limit exceeded: would use 31.16 GiB (attempt to allocate chunk of 16.00 MiB), current RSS: 44.42 GiB, maximum: 43.02 GiB. ...
2026.10.13 22:52:38.034852 [ 3864 ] {} <Error> ... Failed to flush system log system.processors_profile_log with 17744 entries up to offset 113762: Code: 241. DB::Exception: (total) memory limit exceeded: would use 32.99 GiB (attempt to allocate chunk of 1.00 GiB), current RSS: 44.95 GiB, maximum: 43.02 GiB. ...
2026.10.13 22:53:35.013085 [ 3864 ] {} <Error> ... Failed to flush system log system.processors_profile_log with 6679 entries up to offset 120441: Code: 241. DB::Exception: (total) memory limit exceeded: would use 30.04 GiB (attempt to allocate chunk of 4.00 GiB), current RSS: 40.06 GiB, maximum: 43.02 GiB. ...
2026.10.13 22:54:14.040784 [ 3864 ] {} <Error> ... Failed to flush system log system.processors_profile_log with 9002 entries up to offset 129443: Code: 241. DB::Exception: (total) memory limit exceeded: would use 34.76 GiB (attempt to allocate chunk of 4.00 GiB), current RSS: 50.16 GiB, maximum: 43.02 GiB. ...
2026.10.13 22:58:34.677112 [ 3864 ] {} <Error> ... Failed to flush system log system.processors_profile_log with 6221 entries up to offset 166283: Code: 241. DB::Exception: (total) memory limit exceeded: would use 30.28 GiB (attempt to allocate chunk of 4.00 GiB), current RSS: 50.49 GiB, maximum: 43.02 GiB. ...
2026.10.13 22:58:52.842695 [ 3864 ] {} <Trace> SystemLog (system.processors_profile_log): Flushing system log, 3850 entries to flush up to offset 176798
2026.10.13 22:59:07.416471 [ 4651 ] {eb4329cd-5d96-41f0-8df8-6ab93814cdfd} <Debug> MemoryTracker: Query peak memory usage: 14.86 MiB.

Ten flushes failed between 22:52:19 and 22:58:48; five are shown. Between the last good flush (offset 94902) and 22:58:52 (offset 176798), 81,896 rows were queued, consistent with 3 x 25,902 = 77,706 rows from the three secondaries plus other queries.

@clickhouse-gh clickhouse-gh Bot added the comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. label Oct 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit 9f112f7492e05b5768b99fdcfab505e554a22135 was not compared: the CI logs cluster did not answer (every POST attempt failed with an exception; stopped retrying after the 1250 s read budget).

See the job log for details.

@alexey-milovidov alexey-milovidov self-assigned this Oct 15, 2026
# Conflicts:
#	src/Common/FailPoint.cpp
#	src/Processors/Executors/Runtime/V1/ExecutingGraph.cpp
…-build-error-pipeline-dump

Resolve the conflict with ClickHouse#126029 in the `PipelineExecutor` constructor's
catch: keep the `LOGICAL_ERROR` guard and take master's `printPipeline` call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 17, 2026
Merged via the queue into ClickHouse:master with commit b4901fe Oct 17, 2026
178 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 17, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

26.10 is missing this fix. The 26.10 branch was cut on 2026-10-15 with #121503 in it, and this PR merged on 2026-10-17 with no backport. So 26.10.2.103 still adds the full pipeline dump to every exception thrown while the executing graph is built, and copies that text into processors_profile_log rows.

That now kills the server in Upgrade check, because the stress phase runs the previous release (26.10.2.103): report on an unrelated PR. A fault-injected Code: 241 in an 04035_url_cluster_callback_cancel_race secondary query carried a 1,670,548-byte Query pipeline: dump. Two seconds later the processors_profile_log thread began flushing 43,578 entries, and while it ran it logged the global tracker at 14.05, 21.69, 29.05 and 43.06 GiB in 4 s. dmesg then shows a memcg OOM kill of the server (anon-rss:53806184kB), and every later probe got Connection refused.

The diff applies cleanly to 26.10 with a 3-way apply, and every symbol it uses exists there. 26.9 and older do not have #121503, so 26.10 is the only branch that needs it. Could v26.10-must-backport be added?

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-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding 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