Skip to content

Fix crash in STREAM read over a multi-partition table with a row policy - #111572

Merged
Michicosun merged 9 commits into
ClickHouse:masterfrom
groeneai:fix-streaming-row-policy-shared-dag
Aug 4, 2026
Merged

Michicosun merged 9 commits into
ClickHouse:masterfrom
groeneai:fix-streaming-row-policy-shared-dag

Conversation

@groeneai

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fixed a crash when running a STREAM read (enable_streaming_queries = 1) over a table with more than one partition and a row policy defined on it. In debug and sanitizer builds it failed with the Filter column ... not found in DAG outputs logical error; in release builds it could segfault.

Description

Found by the AST fuzzer (AST fuzzer (amd_debug), STID 5572-45f9, CI report). This is a pre-existing trunk bug in the experimental streaming-queries feature, unrelated to the PR the fuzzer ran on.

Root cause. MergeTreeCommitOrderSequentialSource reads each partition through its own query-plan sub-plan and calls plan.optimize() on each one. The row-level filter (row policy) is a FilterDAGInfo reached by shared_ptr through the shared query_info, so every partition's ReadFromMergeTree step aliases the same ActionsDAG. Plan optimizations that run during optimize() (removeUnusedColumns, splitFilter) mutate that DAG in place, so a later partition ends up optimizing a DAG an earlier one already rewrote. The corrupted DAG then aborts with Filter column <name> not found in DAG outputs (or a segfault / assertion, depending on which optimization runs first).

The PREWHERE DAG is not affected because the streaming source already clones it per partition; the row-level filter was simply missed.

Fix. Give each partition sub-plan its own deep copy of row_level_filter (via ActionsDAG::clone()) before building its read, mirroring the existing per-partition PREWHERE clone. The shared DAG is never mutated, so successive partitions each optimize a private copy.

The bug only affects the experimental streaming path (enable_streaming_queries is off by default); the regular read path is unchanged.

MergeTreeCommitOrderSequentialSource builds and optimizes a separate read
sub-plan per partition, but the row-level filter (row policy) was a
FilterDAGInfo shared by shared_ptr through query_info. Plan optimizations
(removeUnusedColumns, splitFilter) mutate that ActionsDAG in place, so a later
partition optimized a DAG an earlier one had already rewritten and the server
aborted with 'Filter column ... not found in DAG outputs' (or segfaulted).

Give each partition sub-plan its own deep copy of row_level_filter, mirroring
the existing per-partition PREWHERE clone.

Found by the AST fuzzer (STID 5572-45f9). Affects only the experimental
streaming path (enable_streaming_queries).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Multi-partition table + row policy + query_plan_remove_unused_columns=1 + max_threads>=2 deterministically corrupts the shared DAG; query_plan_remove_unused_columns=0 never crashes (15/15 survived), single partition never crashes (8/8). The crash surfacing is a streaming-subscription race, so the repro loops the query — crashes within <=8 iterations on 5/5 pristine sessions.
b Root cause explained? Yes. MergeTreeCommitOrderSequentialSource optimizes a separate read sub-plan per partition, but the row policy's row_level_filter is a FilterDAGInfo shared by shared_ptr through query_info, so every partition's ReadFromMergeTree aliases the same ActionsDAG. removeUnusedColumns/splitFilter mutate it in place, so a later partition optimizes a DAG an earlier one already rewrote → the filter column is gone from the DAG outputs.
c Fix matches root cause? Yes. Each partition sub-plan gets its own deep copy of row_level_filter (ActionsDAG::clone()) so the per-partition optimize mutates a private DAG. Not a symptom guard — it removes the sharing at its source, mirroring the existing per-partition PREWHERE clone.
d Test intent preserved / new tests added? New stateless test 04545_streaming_row_policy_multi_partition.sh: crashes on pristine (server dies), passes on the fix. Also asserts the row policy is applied (a denied row committed first per partition would leak if the policy were skipped). No existing test weakened.
e Both directions demonstrated? Yes. WITHOUT fix: crashes at loop runs 7,8,5,3,8 across 5 sessions; test exits non-zero. WITH fix: 300+ looped query runs, 0 crash; test prints ok.
f Fix is general across code paths? Yes. row_level_filter was the only unhandled shared mutable filter DAG in this function (PREWHERE already cloned; filter_actions_dag is shared_ptr<const ActionsDAG>, immutable, and reset by makeStreamingSelectQueryInfo). Fixes the whole class in this path.
g Fix generalizes across inputs? Yes. The deep copy is independent of the filter predicate/column type; verified with USING NULL (constant fold), b < 5000, and b < 0xFFFFFFFF. Any partition count >= 2 triggers; the clone applies per partition regardless of type/values.
h Backward compatible? Yes. No setting/format/behavior change. Affects only the experimental streaming path (enable_streaming_queries, off by default); the regular read path is untouched.
i Invariants and contracts preserved? Yes. The deep copy preserves FilterDAGInfo semantics (actions/column_name/do_remove_column all copied); the row policy is still enforced (verified: 0 rows violating b < 5000 leak). Each partition gets a semantically identical but independent DAG — exactly the invariant the in-place mutation violated.

Session id: cron:clickhouse-author-slot-4:20260723-065000

@groeneai

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

Pre-publication review by an independent model (engine: codex; 2 rounds, 5 findings; bounded: 1 full pass + 1 fix round + 1 delta recheck).

# Sev Finding Verdict Evidence / action
1 ⚠️ Test ignored client errors and used an all-pass policy, so a non-crash exception or a skipped policy could still print ok AGREE Added set -e, selective policy b < 5000, and a per-iteration assertion returning 1.
2 ⚠️ Test did not pin the optimizer setting whose in-place DAG mutation triggers the bug; suggested also pinning max_threads = 1 AGREE (setting) / DISAGREE (max_threads=1) Pinned query_plan_remove_unused_columns = 1 (verified essential: ruc=0 survived 30/30). DISAGREE on max_threads = 1 with evidence: it SUPPRESSES the bug (max_threads=1 survived 40/40 twice); the race needs >= 2. Pinned max_threads = 4 instead.
3 💡 Comment called the Filter column ... not found in DAG outputs logical error an unconditional server termination AGREE Reworded: logical error (an exception, caught in release builds) in debug/sanitizer, or a segfault.
4 ⚠️ With 500 allowed rows/partition and LIMIT 400, a policy-free read could still return 400 allowed-looking rows and pass AGREE Commit one denied row (b = 9000) per partition FIRST so it heads each partition's commit-order stream; verified a policy-free read now returns 0.
5 ⚠️ max_threads = 4 can be collapsed to 1 by the memory limiter under CI load, suppressing the race AGREE Pinned max_threads_min_free_memory_per_thread = 0 (verified: = 0 disables the limiter, MemoryTrackerUtils.cpp early return).

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-author-slot-4:20260723-065000

@Michicosun Michicosun self-assigned this Jul 23, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @Michicosun @azat — could you review? A STREAM read over a multi-partition table with a row policy crashed because each partition's read sub-plan shared and re-optimized the same row_level_filter ActionsDAG; the fix deep-copies it per partition, matching the existing per-partition PREWHERE clone.

@Michicosun Michicosun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do a combined plan soon with a single optimization point.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Agreed, a single optimization point is the better fix at the root. I'll hold while you draft the combined plan, and I'm happy to implement it instead if you'd prefer.

Whichever plan lands, could we keep the regression test here (04545_streaming_row_policy_multi_partition.sh)? It reproduces the AST-fuzzer crash (STID 5572-45f9) deterministically, so it would guard your fix too. I can rebase it onto your PR if that helps.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jul 23, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c06ea0e]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_debug, distributed plan, s3 storage, parallel) FAIL
02015_async_inserts_5 FAIL cidb
AST fuzzer (amd_debug) FAIL
Assertion `px != 0' failed (STID: 2982-48f0) FAIL cidb

AI Review

Summary

This PR fixes the shared row_level_filter DAG aliasing in MergeTreeCommitOrderSequentialSource by cloning the filter into each per-partition SelectQueryInfo before building the ReadFromMergeTree steps, and the new regression test exercises the reported multi-partition STREAM + row-policy failure mode. I did not find a remaining correctness issue in the current head; the only follow-up is a small changelog-metadata cleanup.

PR Metadata
  • Changelog category is not semantically correct for this change. The bug is in the experimental STREAM path behind enable_streaming_queries, so this should be Experimental Feature rather than Bug Fix (user-visible misbehavior in an official stable release).
  • Changelog entry is required for Experimental Feature, and the current entry is specific enough, but it should be rewritten in present tense to match the changelog guidelines.
  • Exact replacement text:
### Changelog category (leave one):
- Experimental Feature

### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md):
Fixes a crash when running a `STREAM` read (`enable_streaming_queries = 1`) over a table with more than one partition and a row policy defined on it.
Final Verdict
  • Status: ✅ Approve
  • Optional follow-up: switch the changelog category to Experimental Feature and rewrite the entry in present tense.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.70% 78.70% +0.00%

Changed lines: Changed C/C++ lines covered: 11/15 (73.33%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jul 23, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 32239a2

CI fully finished (Config + Finish Workflow SUCCESS, >3h buffer). Both Fast tests passed -> no PR-caused failure (the fix is a streaming-path row-policy deep-copy, unrelated to any red below). Every failed check has an owner; only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stress test (arm_msan) / Cannot start clickhouse-server (t_plt_rb_contains Code 246 CORRUPTED_DATA) flaky - chronic part-loading-tree-rollback family (0 master after the fix merged; unrelated to this streaming PR) #111055 (merged 2026-07-23T17:29Z) - not yet on this branch (head predates it); merging master to pick it up
Integration tests (amd_tsan, 3/6) / test_replicated_database::test_replicated_table_structure_alter flaky (chronic trunk flake, 670 PRs / 142 master in 30d; issue #110036) a fix task is being worked (issue #110036 investigation; fixing-PR link to follow here)
Upgrade check (amd_release) / Error message in clickhouse-server.log (Unknown setting allow_experimental_text_index_positions) flaky/infra (27 PRs / 0 master in 14d; upgrade loads an attach with a removed experimental text-index setting) #110865 (ours, open)
Sync - CH Inc sync (private, not actionable)

Session id: cron:our-pr-ci-monitor:20260724-063000

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 3852cff

Every failure below has an owner. None are caused by this PR's diff (the streaming per-partition row_level_filter deep-copy fix + test 04545). The previous head's arm_msan Stress t_plt_rb_contains CORRUPTED_DATA red cleared after merging master to pick up #111055.

Check / test Reason Owner / fixing PR
Upgrade check (amd_release) / New + Changed settings not in settings changes history (join_runtime_filter_min_probe_rows) trunk regression #111671 (ours, merged 2026-07-24) - not yet on this branch (the master-merge that produced this head predates the 08:08Z merge); merging master again to pick it up
Upgrade check (amd_release) / Error message in server.log (system.metric_log rotation metadata exceeds max_query_size) trunk regression #111703 (external, open)
Mergeable Check / PR rollup of the above resolved via the owners above

Session id: cron:our-pr-ci-monitor:20260724-133000

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 43ca40c

Every failure below has an owner. None is caused by this PR's diff (streaming per-partition row_level_filter deep-copy in MergeTreeCommitOrderSequentialSource + stateless test 04545). The prior head's join_runtime_filter_min_probe_rows settings-history lines cleared here (merged #111671 picked up).

Check / test Reason Owner
Integration tests (amd_tsan, 4/6) / test_kafka_bad_messages::test_bad_messages_parsing_stream flaky (2 unrelated PRs / 0 master, 30d) a fix task is created (investigating at full effort; fixing-PR link to follow here)
Stateless tests (amd_tsan, s3 storage, parallel, 2/3) / 04509_hash_table_sizes_stats_table_functions flaky (7 unrelated PRs / 1 master, 30d) fixing PR #111502 (external, open)
Upgrade check (amd_release) / Error message in server.log (system.metric_log rotation metadata > max_query_size, Code 229 QUERY_IS_TOO_LARGE) trunk regression fixing PR #111703 (external, merged 2026-07-24 17:24Z); build predates the merge, merging master to pick it up

Session id: cron:our-pr-ci-monitor:20260724-200000

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 43ca40c

CI finished (Finish Workflow green, CH Inc sync green). AST fuzzer (amd_debug, the STID 5572-45f9 target) and all fuzzer/build/stateless-core jobs are green, so the prewhere/planner fix holds. The three red checks below are flaky/trunk, none caused by this PR (diff = MergeTreeCommitOrderSequentialSource per-partition row-level filter + 04545_streaming_row_policy_multi_partition). The join_runtime_filter_min_probe_rows settings-history lines from the previous ledger are now cleared (picked up #111671). Each red has an owner:

Check Test Reason Owner
Upgrade check (amd_release) Error message in clickhouse-server.log (system.metric_log metadata exceeds max_query_size) trunk regression, not PR-caused (0 master hits, 30+ unrelated PRs) fixed by #111703 (merged); this head predates it, clears on next master merge
Integration tests (amd_tsan, 4/6) test_kafka_bad_messages/test.py::test_bad_messages_parsing_stream flaky, not PR-caused (0 master, unrelated to this diff) a fix task is tracking it (fixing PR link to follow)
Stateless tests (amd_tsan, s3 storage, parallel, 2/3) 04509_hash_table_sizes_stats_table_functions flaky/trunk, not PR-caused (fires on master and several unrelated PRs) a fix task is tracking it; see #109454

Session id: cron:our-pr-ci-monitor:20260725-000000

@groeneai

Copy link
Copy Markdown
Collaborator Author

Discharging the ledger line above: the fixing PR for test_kafka_bad_messages/test.py::test_bad_messages_parsing_stream is #112039.

It is a teardown-helper bug, not a Kafka parsing issue, which is why it lands on unrelated PRs. kafka_delete_topic treated UnknownTopicOrPartitionError (error code 3) on a DeleteTopicsRequest as a failure and retried it. That code means the topic does not exist, which for a delete is the requested end state, so once a delete's response is lost to the client request timeout while the delete itself landed broker-side, every retry returns error 3 and the helper raises out of teardown after exhausting its retries. The fix treats error 3 as the absent-topic path and lets the helper's existing list_topics post-verification loop decide, leaving the transient-error retry untouched.

pull Bot pushed a commit to Lobinson1/ClickHouse that referenced this pull request Jul 27, 2026
kafka_delete_topic, the shared single-topic teardown helper for the whole Kafka
integration family, retried a *successful* delete as if it had failed and could
never converge, so an otherwise fully passing test was reported FAILED from
teardown.

UnknownTopicOrPartitionError (error code 3) on a DeleteTopicsRequest means "that
topic does not exist", which for a delete is exactly the requested end state. It
landed in the helper's generic `except Exception: retry`, so the helper asked the
broker 49 more times to delete something already gone, burned ~23 s, and then
raised.

Read off the failing job's kafka-python client log (2026-07-24, topic
Native_stream_err_1784918653): attempt 1's request was sent at 18:44:18.560; at
18:44:48.570 the client gave up on the response after its 30 s request timeout
(the shard runs three xdist workers under TSan); the reconnect's metadata refresh
at 18:44:49.077 reported ClusterMetadata(brokers: 1, topics: 3, groups: 0), i.e.
only the three internal topics, proving the delete had in fact landed broker-side
and only its response was lost; every attempt from 18:44:49.078 on returned
error_code 3, which kafka/admin/client.py:409 raises on.

So this is a classification bug, not a missing retry. More retries provably
cannot help: each error-3 response came back in 1-4 ms, and the condition is
permanent. Rather than adding a guard, remove the incorrect classification, which
makes the teardown operation idempotent - the correct property for a delete.
UnknownTopicOrPartitionError is now caught ahead of the generic handler and
treated as the absent-topic path. It is not a blind return: it falls through to
the helper's existing post-verification loop, which independently confirms the
topic is no longer listed and still raises otherwise. The generic retry is
untouched, since it is load-bearing for the transient RequestTimedOutError.

kafka.errors marks UnknownTopicOrPartitionError retriable, but that describes
stale-client-metadata semantics on the produce/fetch paths, where a later
metadata refresh can make the topic appear. On the delete path the same code
means the opposite, so keying the retry on that flag would preserve the bug.

Not a single-test flake: since the retry loop was added (ClickHouse#108635, 2026-06-27) the
signature accounts for 4 CI hits across 4 unrelated PRs, 3 test modules and 3
sanitizer flavours, all through this one frame. It also makes a routine operation
of tests/casa_del_dolor/catalogs/kafkatest.py, which deletes randomly chosen
topic names, stop burning the full 50-attempt loop.

The regression test drives the helper with a stub admin client replaying that
exact RPC sequence. A broker cannot be made to drop exactly one
DeleteTopicsResponse on demand, and the passing path is byte-identical to today's,
so a broker-driven test of this interleaving could only be non-deterministic -
which is the property this change removes.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111572&sha=43ca40c8c0beb217e3edc66236a546332bb3c000&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%204%2F6%29
Related: ClickHouse#111572

Co-Authored-By: Claude Opus 4.8 <[email protected]>
scanhex12 pushed a commit to scanhex12/ClickHouse that referenced this pull request Jul 29, 2026
kafka_delete_topic, the shared single-topic teardown helper for the whole Kafka
integration family, retried a *successful* delete as if it had failed and could
never converge, so an otherwise fully passing test was reported FAILED from
teardown.

UnknownTopicOrPartitionError (error code 3) on a DeleteTopicsRequest means "that
topic does not exist", which for a delete is exactly the requested end state. It
landed in the helper's generic `except Exception: retry`, so the helper asked the
broker 49 more times to delete something already gone, burned ~23 s, and then
raised.

Read off the failing job's kafka-python client log (2026-07-24, topic
Native_stream_err_1784918653): attempt 1's request was sent at 18:44:18.560; at
18:44:48.570 the client gave up on the response after its 30 s request timeout
(the shard runs three xdist workers under TSan); the reconnect's metadata refresh
at 18:44:49.077 reported ClusterMetadata(brokers: 1, topics: 3, groups: 0), i.e.
only the three internal topics, proving the delete had in fact landed broker-side
and only its response was lost; every attempt from 18:44:49.078 on returned
error_code 3, which kafka/admin/client.py:409 raises on.

So this is a classification bug, not a missing retry. More retries provably
cannot help: each error-3 response came back in 1-4 ms, and the condition is
permanent. Rather than adding a guard, remove the incorrect classification, which
makes the teardown operation idempotent - the correct property for a delete.
UnknownTopicOrPartitionError is now caught ahead of the generic handler and
treated as the absent-topic path. It is not a blind return: it falls through to
the helper's existing post-verification loop, which independently confirms the
topic is no longer listed and still raises otherwise. The generic retry is
untouched, since it is load-bearing for the transient RequestTimedOutError.

kafka.errors marks UnknownTopicOrPartitionError retriable, but that describes
stale-client-metadata semantics on the produce/fetch paths, where a later
metadata refresh can make the topic appear. On the delete path the same code
means the opposite, so keying the retry on that flag would preserve the bug.

Not a single-test flake: since the retry loop was added (ClickHouse#108635, 2026-06-27) the
signature accounts for 4 CI hits across 4 unrelated PRs, 3 test modules and 3
sanitizer flavours, all through this one frame. It also makes a routine operation
of tests/casa_del_dolor/catalogs/kafkatest.py, which deletes randomly chosen
topic names, stop burning the full 50-attempt loop.

The regression test drives the helper with a stub admin client replaying that
exact RPC sequence. A broker cannot be made to drop exactly one
DeleteTopicsResponse on demand, and the passing path is byte-identical to today's,
so a broker-driven test of this interleaving could only be non-deterministic -
which is the property this change removes.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111572&sha=43ca40c8c0beb217e3edc66236a546332bb3c000&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%204%2F6%29
Related: ClickHouse#111572

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…olicy-shared-dag

Master restructured the streaming snapshot reader: buildPartitionReadingPipeline
was replaced by buildPartitionReadingPlan, and the per-partition plans are now
united into one QueryPlan that is optimized a single time
(28f018c, 3ede227).

The per-partition row_level_filter deep copy is kept and re-anchored onto that
structure. Uniting the plans does not remove the aliasing: every partition still
gets its own read step, all of them holding the same FilterDAGInfoPtr, so one
optimize() pass over the unified plan still rewrites that shared ActionsDAG once
per partition.
@clickhouse-gh

clickhouse-gh Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.60% 78.70% +0.10%

Changed lines: Changed C/C++ lines covered: 9/15 (60.00%) · Uncovered code

Full report · Diff report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 3c32069

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
AST fuzzer (arm_asan_ubsan) / AddressSanitizer: heap-use-after-free (STID 2837-40ba) read of 8 bytes in ExecutingGraph::updateNode from PipelineExecutor::executeStepImpl, on a graph node freed by a concurrent runtime node removal #111017 (mine, open)

All 174 check-runs on this commit are completed and this is the only failing check. Not caused by
this PR: the diff fixes a shared-DAG clone in the STREAM read path over a row-policy table and does
not touch the pipeline executor. This same signature hit 3 other unrelated pull requests in the last
24 hours and 4 since 2026-07-19, and #111017 is not an ancestor of this head, so recurrence here is
expected until it lands.

Session id: cron:our-pr-ci-monitor:20260730-233000

@Michicosun
Michicosun enabled auto-merge August 3, 2026 16:40
@groeneai

groeneai commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - c06ea0e

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
AST fuzzer (amd_debug) / Assertion 'px != 0' failed (STID 2982-48f0) Null AST assertion in TreeRewriter::analyzeSelect reached via ReadFromMerge::createChildrenPlans; a trunk assertion the fuzzer surfaces. Not caused by this diff, which touches only MergeTreeCommitOrderSequentialSource.cpp and one streaming test. 8 distinct PRs in 30 days, 0 on master. #109139 (mine, open)
Stateless tests (amd_debug, distributed plan, s3 storage, parallel) / 02015_async_inserts_5 Code: 252 Too many parts at parts_to_throw_insert = 1: the INSERT counts the part it wrote itself. The runner's own randomized-settings diagnosis re-ran it 10/10 green. 6 rows / 6 distinct PRs / 0 master in 30 days. #113045 (external, open)
Build (arm_release) / Post Hooks build_profile_hook telemetry INSERT rejected with LogCluster query failed with code 500; job-level status is success (the hook carries allow_failure). 816 rows / 284 distinct PRs / 463 master hits in 7 days. a fix task is created (investigating at full effort - fixing PR link to follow on this PR)
Sync - CH Inc sync (private, not actionable)

Session id: cron:our-pr-ci-monitor:20260804-043000

@Michicosun
Michicosun added this pull request to the merge queue Aug 4, 2026
Merged via the queue into ClickHouse:master with commit 3d5cb29 Aug 4, 2026
177 of 180 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 4, 2026
pull Bot pushed a commit to sjoerd2025/ClickHouse that referenced this pull request Sep 15, 2026
The test loops its STREAM query 30 times with --max_execution_time=20. That
limit cannot catch anything the test looks for: the test asserts the query
SUCCEEDS (the oracle is throwIf(max(b) >= 5000 OR count() = 0), and the file
carries no serverError expectation), and the read is bounded by
STREAM LIMIT 400 over 10,010 pre-inserted rows, so it terminates on its own.
The limit can therefore only convert a slow-but-correct run into
Code: 159 TIMEOUT_EXCEEDED, which happened once on an unrelated PR (ClickHouse#113400).

What makes an iteration slow: a STREAM read re-runs full per-partition
planning on every snapshot iteration. Measured on this 10-partition table,
a single query logs 3 "Building new snapshot", 10 "Loading statistics",
10 "Moved conditions to PREWHERE" and 11 partition-key prunings while
reading about 1000 rows. That cost is left alone here, since
buildPartitionReadingPlan and buildNextSnapshotReadingPipeline are being
rewritten in ClickHouse#106169.

The sibling 04619_streaming_queries_shared_snapshot_strip_race.sql keeps its
max_execution_time = 2, because there the limit is the oracle
({ serverError TIMEOUT_EXCEEDED }). It is the only other streaming test that
sets the setting and is deliberately untouched.

The limit also never bought headroom: 30 iterations x 20s is a 600s ceiling,
exactly the harness's own --timeout 600. The installed test overlay does not
re-impose max_execution_time: the server default is 0, limits.yaml does not
set it, and the 60 second limits_fast.yaml is linked only under
FAST_TEST==1 && is_fast_build while Fast test passes --no-long and this test
is tagged long. Verified live on the installed stateless overlay:
system.settings reports max_execution_time 0, changed 0, while limits.yaml's
own values read changed 1. limits.yaml does set max_estimated_execution_time:
600, and that path is armed rather than inert, but the guard that reaches it
is a conjunction: the estimate is computed only once a query's own elapsed
time exceeds timeout_before_checking_execution_speed, which limits.yaml
raises to 300s, against a measured server-side 12ms per query
(system.query_log, n=30, min 10ms, max 72ms). It cannot substitute for the
removed cap.

One job adds a further cap on top of that overlay, and it is worth naming
because grep -rn max_execution_time tests/docker_scripts/ finds it. The Stress
test job runs the same install.sh, then configure_limits in
tests/docker_scripts/stress_tests.lib writes max_execution_time 60 into the
default profile, and stress_runner.sh calls that before starting the server
which runs the functional suite. The Stress test job passes neither --no-long
nor --no-parallel-replicas, and both skips are opt-in, so this test does run
there. That cap is looser than the one being removed, not tighter: a client
setting wins over the profile value, so the test's own --max_execution_time=20
was the effective limit there and it becomes 60s. Measured against that
profile: with no client flag system.settings reads 60, with the test's flag it
reads 20. Upgrade check never calls configure_limits, and the fuzzer and
performance profiles that also set the setting do not run clickhouse-test.

Runaway protection stays with the harness, which gives each file
--timeout 600 plus an int(600*1.1)+60 = 720s alarm and reports a hang as
"Timeout!". The flaky check's 180 second slow-test verdict
is gated on "long" not in tags and cannot fire here. This trades a fast false
failure for a slower true one.

Validation: the modified test passes 50/50 randomized and 50/50
non-randomized runs (--long-test-runs-ratio 1.0 is required, since the long
tag otherwise reduces 50 requested runs to 5). Removing the cap does not
measurably slow the test. Two runs of the same 21-test streaming suite on the
same binary give 7.70s with the cap (suite-base.log) and 7.96s without it
(suite-fix2.log). They are separate clickhouse-test invocations 131s apart,
so the comparison rests on a load control rather than on co-scheduling: the
20 unmodified tests in those same two runs move +0.50% in total (27.97s to
28.11s, per-test deltas -0.07s to +0.15s), and both logs carry identical
21-test name sets and the same server sha. The +0.26s difference is
therefore inside this test's own run-to-run spread of 7.46s to 9.47s across
the 50 randomized runs.
system.query_log confirms 30 oracle queries per run with zero timeouts, so
the pass is not a skipped loop. Reverting the ClickHouse#111572 source fix makes the
modified test fail with Code: 10 "Not found column less(b, 5000_UInt16) in
block" while executing MergeTreeCommitOrderSequentialSource, so the
regression oracle is still armed. The whole streaming family is 21/21 on
both arms.
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 pr-bugfix Pull request with bugfix, not backported by default 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