Skip to content

Fix LOGICAL_ERROR in ReadFromMergeTree::deserialize for empty distributed-read snapshot - #110929

Open
groeneai wants to merge 15 commits into
ClickHouse:masterfrom
groeneai:fix-readfrommergetree-deserialize-empty-snapshot-110927
Open

groeneai wants to merge 15 commits into
ClickHouse:masterfrom
groeneai:fix-readfrommergetree-deserialize-empty-snapshot-110927

Conversation

@groeneai

@groeneai groeneai commented Jul 18, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Experimental Feature

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

Fix a LOGICAL_ERROR in experimental multistage distributed query planning (make_distributed_plan) when a worker deserializes a bucketed ReadFromMergeTree read whose local parts snapshot has become empty (parts merged away or dropped concurrently). The worker now returns the retryable NO_SUCH_DATA_PART error, or an empty result for a genuinely empty bucket.

Description

Fixes the LOGICAL_ERROR ReadFromMergeTree step is expected to be created by readFromParts in ReadFromMergeTree::deserialize, in the multistage distributed queries feature (make_distributed_plan, experimental). Closes #110927.

Surfaced once in 60 days on Stress test (arm_release) (report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110910&sha=51e6b0ddc85e666b2fcfacc3238134aeba30e55c&name_0=PR&name_1=Stress%20test%20%28arm_release%29). Not caused by #110910 (which only touches randomHadamardTransform); it is a pre-existing latent bug in the distributed-read deserialize path.

Root cause: the coordinator serializes a bucketed read (distributed_read_bucket_count > 0) while parts exist. A worker deserializes it, but its local parts snapshot can be empty by then (parts merged away or dropped under stress churn). readFromParts returns a null step for an empty non-stream read, and the bucketed branch then dynamic_casts it to null and throws. A non-bucketed read got the same null step and was dereferenced by QueryPlan::deserialize; master now rebuilds that case as a ReadNothingStep (#114659).

Fix: on the deserialize path only, readFromParts now builds a real (empty) ReadFromMergeTree step for a bucketed read even when the local snapshot is empty. initializePipeline then resolves it as before: a genuinely empty bucket reads nothing, and a bucket whose coordinator-selected part is missing locally raises the existing retryable NO_SUCH_DATA_PART divergence error. A ReadNothingStep here would bypass that check and silently drop rows. Non-bucketed reads keep master's ReadNothingStep, and the other readFromParts callers are unchanged.


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

…uted-read snapshot

A worker deserializing a bucketed distributed read (distributed_read_bucket_count > 0)
can have an empty local parts snapshot if parts merged away or were dropped since the
coordinator planned the read. readFromParts returned a null step for an empty non-stream
read, and the bucketed branch then dynamic_cast-ed it to null and threw a LOGICAL_ERROR
(server abort in debug/sanitizer builds).

Build a real empty ReadFromMergeTree step for a bucketed read on the deserialize path so
the bucket count has a step to attach to; initializePipeline then resolves it exactly as
before at runtime (NullSource for a genuinely empty bucket, retryable NO_SUCH_DATA_PART if
the coordinator-selected part is missing locally). A ReadNothingStep short-circuit would
bypass that divergence check and silently drop rows, so it is not used.

Closes: ClickHouse#110927

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

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

Two Gate B passes were run.

Pass 1 (against an earlier, wrongly-scoped diff) — 1 finding, adjudicated AGREE:

# Severity Finding Verdict Resolution
❌ Blocker major Evidence bundle did not match the diff under review AGREE The fix had been staged on top of an unrelated feature branch, so the reviewer saw that branch's diff. Moved the fix onto a clean branch off master containing only the 6 files of this change, then re-ran the review.

Pass 2 (against the final committed diff a7f4381, 6 files) — 0 findings.

No blockers, majors, or nits outstanding.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. New REGULAR failpoint distributed_plan_read_empty_snapshot_on_deserialize + SELECT sum(x) ... SETTINGS make_distributed_plan=1, distributed_plan_execute_locally=1, distributed_plan_default_reader_bucket_count=3 aborts every time without the fix.
b Root cause explained? Yes. Coordinator serializes a bucketed read (distributed_read_bucket_count > 0) while parts exist; a worker deserializes it with an empty local snapshot (parts merged/dropped); readFromParts returns a null step for an empty non-stream read; the bucketed branch dynamic_casts null and throws at ReadFromMergeTree.cpp:5487.
c Fix matches root cause? Yes. It builds the missing step for exactly that case (empty snapshot + bucketed read), not a guard over the symptom.
d Test intent preserved / new test added? Yes. New test 04371_distributed_plan_read_empty_snapshot asserts the server survives and returns the retryable divergence error rather than a silent 0-row result.
e Both directions demonstrated? Yes. Without fix: LOGICAL_ERROR fatal, server dies (matches CI). With fix: NO_SUCH_DATA_PART retryable, server alive. Verified on distinct Build IDs on both the original and current-master base.
f General, not a narrow patch? Yes. Only one deserialize site does this dynamic_cast + LOGICAL_ERROR. ReadFromObjectStorageStep has setDistributedRead but no deserialize path (no sibling bug).
g Generalizes across inputs? Yes. The guard keys on snapshot emptiness, independent of column types / engines / bucket count; both empty-bucket (NullSource) and diverged-bucket (NO_SUCH_DATA_PART) runtime outcomes are covered.
h Backward compatible? Yes. No setting default change, no on-disk/wire/protocol change (serialized bucket-count format unchanged); only worker-side step reconstruction for an empty snapshot changes. No SettingsChangesHistory entry needed.
i Invariants preserved? Yes. readFromParts' contract for its 5 other callers is unchanged (default false). The deserialize path now always yields a non-null step for a bucketed read, which setDistributedRead requires; the empty/divergence runtime handling in initializePipeline is routed into, not around.

Feature is experimental (make_distributed_plan, default off); the test uses no-parallel because SYSTEM ENABLE FAILPOINT is process-global.

Session id: cron:clickhouse-author-slot-1:20260718-074900

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @davenger @CurtizJ — could you review this? It fixes a LOGICAL_ERROR in ReadFromMergeTree::deserialize: a multistage-distributed worker deserializing a bucketed read whose local parts snapshot became empty (parts merged/dropped) got a null step from readFromParts and then dynamic_cast-threw. The fix builds a real empty read step so initializePipeline resolves it as before (NullSource for an empty bucket, retryable NO_SUCH_DATA_PART on divergence).

@clickhouse-gh

clickhouse-gh Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [398f46e]

Summary: ✅


AI Review

Summary

The PR fixes empty-snapshot deserialization for bucketed ReadFromMergeTree reads in experimental make_distributed_plan, preserving missing-part validation before an empty result is returned. The current code addresses the prior findings, including FINAL validation and the non-bucketed ReadNothingStep fallback. No new actionable findings remain.

Missing context / blind spots
  • ⚠️ The regression was not executed locally. The latest Fast test report skips 04371_distributed_plan_read_empty_snapshot via no-fasttest; runtime evidence comes from the author's recorded validation. A current-head run in a build with failpoints enabled would close this verification gap.
Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 18, 2026
groeneai and others added 2 commits July 18, 2026 15:20
The initial fix built a real empty ReadFromMergeTree step for a bucketed
distributed read with an empty local snapshot so the runtime could tell a
genuinely empty bucket (NullSource) from a diverged one (retryable
NO_SUCH_DATA_PART). That divergence check is eager only for non-FINAL reads
(initializePipeline resolves the bucket marks to local parts up front). FINAL
resolves each lane's marks lazily in spreadMarkRangesAmongStreamsFinal, which is
reached only after the empty-parts_with_ranges short-circuits (NullSource, and
the total_marks == 0 early return). So a FINAL worker whose snapshot went empty
returned zero rows instead of the retryable divergence error, a silent
wrong-results regression.

Add the symmetric eager divergence check for FINAL in initializePipeline: a
coordinator-selected part missing from the local snapshot raises
NO_SUCH_DATA_PART; a genuinely empty bucket (no lane marks) still falls through
to NullSource. Extend 04371 with a ReplacingMergeTree FINAL case.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…y snapshot

ReadFromMergeTree::deserialize gated build_empty_step_for_distributed_read on
distributed_read_bucket_count > 0, so only a bucketed read got a real step when
this replica's local snapshot was empty. A non-bucketed distributed read still
ships in a fragment when the distributed axis is an exchange above the read
(for example a FINAL read under a distributed aggregation). For such a fragment
readFromParts returned a null step on an empty snapshot, and the generic query
plan deserializer then dereferenced it (IQueryPlanStep::hasOutputHeader), which
segfaulted the distributed task thread.

Build a real step unconditionally in the deserialize path. It is reached only
for a fragment that will be executed (the drain path short-circuits to
ReadNothingStep earlier), so a real step is always correct. A non-bucketed read
is not pinned to coordinator-selected parts, so an empty snapshot is zero local
rows via the normal empty-read path, not a divergence; the bucketed divergence
check (NO_SUCH_DATA_PART) is unchanged and still runs for bucket_count > 0.

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

Copy link
Copy Markdown
Collaborator Author

Follow-up fix in b0e4834 (a Fast-test Server died on the previous head 8615114 was PR-caused by the FINAL divergence-check commit).

Root cause: ReadFromMergeTree::deserialize gated build_empty_step_for_distributed_read on distributed_read_bucket_count > 0. A non-bucketed distributed read (bucket count 0) still ships in a fragment when the distributed axis is an exchange above the read, e.g. a FINAL read under a distributed aggregation. On an empty local snapshot readFromParts returned a null step, and the generic plan deserializer then dereferenced it (IQueryPlanStep::hasOutputHeader, Serialization.cpp:234) -> SIGSEGV on the distributed task thread. The failing query was this test's own query 16, SELECT count(), sum(v) FROM ... FINAL (its stage_0 plan is ShuffleSend -> Expression -> ReadFromMergeTree FINAL with no bucket count).

Fix: build a real step unconditionally in the deserialize path. It is reached only for a fragment that will be executed (the drain path short-circuits to ReadNothingStep earlier). A non-bucketed read is not pinned to coordinator-selected parts, so an empty snapshot is zero local rows via the normal empty-read path, not a divergence; the bucketed divergence check (NO_SUCH_DATA_PART) is unchanged and still runs for bucket_count > 0.

Reproduced deterministically and verified both directions locally: without the fix the non-bucketed FINAL global-aggregation under the distributed_plan_read_empty_snapshot_on_deserialize failpoint segfaults (stack identical to CI); with the fix it returns 0 rows and the server stays alive. Extended the regression test with this non-bucketed case.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110929&sha=8615114bbd1fc87fc5af9620288bd873d13e068d&name_0=PR&name_1=Fast%20test

… reads always bucketize

The bucketed-empty-snapshot assertions require the read to actually split into
distributed buckets, which depends on the mark count. Without a pinned
index_granularity, CI randomizes it large, the 100000-row FINAL read produces
too few marks to bucketize, the empty snapshot takes the non-bucketed zero-row
path, and the serverError NO_SUCH_DATA_PART assertion no longer holds. Pin
index_granularity = 256 on the bucketed tables, matching the sibling
distributed-FINAL tests (04356, 04357).

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

Copy link
Copy Markdown
Collaborator Author

Pushed 95a3e5a: stabilize the regression test 04371 (fixes the Fast test failure on b0e48347).

Root cause: the bucketed-empty-snapshot assertions require the read to actually split into distributed buckets, which depends on the mark count. The test did not pin index_granularity, so CI randomized it large, the 100000-row FINAL read produced too few marks to bucketize, the empty snapshot took the non-bucketed zero-row path, and the serverError NO_SUCH_DATA_PART assertion no longer held (line 47 returned 0 0).

Fix: pin index_granularity = 256 on the bucketed tables, matching the sibling distributed-FINAL tests (04356, 04357). No source change.

Verified via the real clickhouse-test runner: original test + forced --merge-tree-settings "--index_granularity 65536" reproduces the failure [ FAIL ]; the fixed test passes both under that forced value and under default randomized settings [ OK ].

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110929&sha=b0e48347a13909967d228786829c019df0c8d9c9&name_0=PR&name_1=Fast%20test

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 95a3e5a

Every failure below has an owner (a fixing PR). The two earlier PR-caused Fast-test failures (server crash on the null distributed-read step, then the fragile bucketed-FINAL index_granularity assertion) were fixed in this PR on this head; Fast test is now green.

Check / test Reason Owner / fixing PR
AST fuzzer (amd_debug, targeted) / Block structure mismatch in MergingAggregated: anyDistinctStateTuple vs any_respect_nullsDistinct (STID 0993-290c) trunk (-Tuple combinator + RESPECT NULLS state-name drop; 5 unrelated PRs + 1 master / 30d; this PR touches only ReadFromMergeTree, not aggregate combinators) #110930 (ours, open)
AST fuzzer (amd_debug, targeted, old_compatibility) / same STID 0993-290c same trunk family #110930 (ours, open)
Integration tests (amd_tsan, 3/6) / test_replicated_database::test_replicated_table_structure_alter flaky (chronic; 447 unrelated PRs + 92 master / 30d) #110030 (ours, open)
Mergeable Check — passed (green; the reds above are non-blocking)

The failed AST-fuzzer builds predate #110930's merge; when it merges, master will be merged into this branch to pick it up. Likewise for #110030.

Session id: cron:our-pr-ci-monitor:20260718-223000

@clickhouse-gh clickhouse-gh Bot added pr-experimental Experimental Feature and removed pr-ci labels Jul 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.30% 86.30% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.50% 78.40% -0.10%

Changed lines: Changed C/C++ lines covered: 39/40 (97.50%) · Uncovered code

Full report · Diff report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 7e78ebd

Every failure below has an owner: a fixing PR (ours 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, targeted) / Cannot serialize FutureSetFromSubquery with no query plan (STID 2678-3c21) prepared-set serialization under plan-based parallel replicas #110874 (ours, open)
Stress test (arm_asan_ubsan) / Hung check failed, possible deadlock found three hasToken text-index queries blocked ~588 s in MergeTreeMarksLoader::loadMarksSync on the marks-cache mutex while a peer thread holds a FileSegment lock inside CachedOnDiskReadBufferFromFile::nextImplStep a fix task is created (investigating at full effort — fixing-PR link to follow here)
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) / 01666_merge_tree_max_query_limit deterministic under parallel replicas (3/3 reruns failed) #112385 (ours, open)
Stateless tests (arm_binary, parallel) / 04367_distributed_plan_merge_scatter_multishard real hang, unbounded condition-variable wait at max_threads = 1 (139/139 same-settings reruns passed) #111762 (external, open)

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

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the Stress test (arm_asan_ubsan) hung check on 7e78ebd7a15ba76b593a2ac7c4ce11ca5e692b2f: #112644.

That ledger line owes a correction as well as a link. Its stated reason (three queries blocked on the marks-cache mutex behind a FileSegment lock) is wrong. There was no deadlock: CacheBase::getOrSet releases the cache mutex before acquiring the per-key insert token, so the waiting threads were behaving as designed, and each query burned 8 s of CPU and issued tens of thousands of read syscalls, which a blocked thread does not do.

The real defect is read amplification on the packed-archive member read path. A packed part keeps every column file inside one archive; when the marks loader asks for a member it clamps the read buffer to that member but the remote seek threshold keeps its session value, so the archive prefix ahead of the member is judged too short to seek and is transferred through a member-sized buffer instead. In the artifact, three marks loads each moved 1.1 to 3.1 MB to obtain 96 to 144 bytes of marks.

#112644 removes that amplification. It does not by itself close this hung-check class: a slow but uncancellable marks load can still exceed the window, and that half is filed separately (marks loading does not observe QueryStatus::is_killed), along with the harness busy-poll.

This PR remains not-pr-caused for that failure: its only MergeTreeDataSelectExecutor.cpp hunk is in readFromParts, while every hung stack sits in filterPartsByPrimaryKeyAndSkipIndexes.

@groeneai groeneai added the groeneai-origin-unknown PR origin: unclassified (legacy task) label Aug 19, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. label Sep 4, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

New sighting of this bug on master: 2026-09-18, Stress test (amd_asan_ubsan) on an unrelated PR's head 8589333436. Report.

Both symptoms fired in that single job, from the same empty local snapshot:

  • the bucketed half, Logical error: 'ReadFromMergeTree step is expected to be created by readFromParts' at ReadFromMergeTree.cpp:6879, aborting the server (core artifact core.DistQueryTask.3607-7212);
  • the non-bucketed half, UndefinedBehaviorSanitizer: member call on null pointer of type 'DB::IQueryPlanStep' at Serialization.cpp:297 (step->hasOutputHeader()), which is the SIGSEGV described above, this time caught as UB rather than as a crash.

The query, from test 04040_cascades_semi_join_broadcast_correctness.sql:

SELECT count() FROM test_orders
WHERE exists((SELECT 1 FROM test_lineitem__fuzz_3 WHERE l_orderkey = o_orderkey))
GROUP BY toNullable(toUInt256(1))
SETTINGS distributed_plan_execute_locally = 1

with make_distributed_plan = 1, enable_cascades_optimizer = 1, and
enable_shared_storage_snapshot_in_query at its default, so the deserialize side does take a fresh
snapshot. test_lineitem__fuzz_3 is a fuzzer-created table, which supplies exactly the drop/recreate
churn the divergence needs.

I re-checked current master: readFromParts still returns {} for an empty non-stream read,
ReadFromMergeTree::deserialize still returns that pointer unchecked, and QueryPlan::deserialize
still dereferences it. This fix is not superseded. The branch has gone stale, so I will merge master
and refresh CI.

…apshot-110927

Conflict: src/Common/FailPoint.cpp -- both sides appended to the failpoint
list after distributed_plan_status_check_reenqueue_fault; kept both.
deserialize has passed the flag unconditionally since b0e4834 (a read shipped in a
distributed fragment is not always the bucketed one: the distributed axis can be an
exchange above it, e.g. FINAL under a distributed aggregation), but the header and the
readFromParts guard still described the option as bucketed-only.

The surrounding blocks are also cut back to the local invariant. The motivation belongs
here, not in the source: a null step from readFromParts is dereferenced unchecked by
QueryPlan::deserialize (Serialization.cpp:297), which is the UBSan/SIGSEGV half of the
defect, while the bucketed half hits the dynamic_cast assertion; and a ReadNothingStep
short-circuit was rejected because it would bypass the divergence check and return zero
rows instead of the retryable NO_SUCH_DATA_PART.

No functional change.
@groeneai

Copy link
Copy Markdown
Collaborator Author

Merged master (this branch was 28341 commits behind and conflicting; it is mergeable again). The only conflict was in src/Common/FailPoint.cpp, where master and this branch both appended to the failpoint list; both sides kept.

Re-verified both directions on the merged tree with my own debug builds:

  • restoring the old distributed_read_bucket_count > 0 condition on build_empty_step_for_distributed_read (build C2F36D6A) reproduces the abort, with the CI stack: ReadFromMergeTree::deserialize <- Serialization.cpp:295 <- DistributedPlanExecutor.cpp:857;
  • dropping the eager FINAL divergence check (build 41601BD8) makes the bucketed FINAL empty-snapshot query return 0 0 instead of NO_SUCH_DATA_PART;
  • with both in place (build 0330B4CF), 04371_distributed_plan_read_empty_snapshot passes 4/4 through the test runner, including a forced index_granularity=65536 run, and the server stays up.

The last commit is comment-only: the build_empty_step_for_distributed_read comments still described the option as bucketed-only, although deserialize has passed it unconditionally since b0e4834.

@clickhouse-gh

clickhouse-gh Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 398f46eb8 with master e720b7367 (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

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

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

Median compile-time ratio to the baselines is ×1.08 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +71.3 s (+8%) in total before that adjustment.

Job report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 419d752

Every failure below has an owner. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) / 01414_push_predicate_when_contains_with_clause master-side regression, not from this PR: #120477 dropped the entry from tests/parallel_replicas_blacklist.txt, so the test now runs under parallel replicas and reads 768 rows against a max_rows_to_read of 8 (TOO_MANY_ROWS) #120763 (external, merged 2026-09-18T09:15:34Z), merged master @ 6d838ef6e72a to pick it up
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) / 03174_exact_rows_before_aggregation same master-side regression, same removed blacklist entry (rows_before_aggregation diverges under parallel replicas) #120763 (external, merged), merged master @ 6d838ef6e72a to pick it up
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) / 03262_filter_push_down_view same master-side regression, same removed blacklist entry (index analysis loses a KeyCondition term, granules 1/3 to 3/3) #120763 (external, merged), merged master @ 6d838ef6e72a to pick it up
CH Inc sync - CH Inc sync (private, not actionable by me)
Mergeable Check, PR aggregate roll-ups of the three rows above, no independent failure of their own #120763 (external, merged), merged master @ 6d838ef6e72a to pick it up

My branch was 28341 commits behind and I merged master at 08:47Z, 28 minutes before #120763 landed, so this run tested a tree that still lacked the restored blacklist entries. All three tests fail identically on true master and across 112 other pull requests in the same lane since 2026-09-17T19:36Z, so none of them is attributable to my diff. The new head restores all three entries.

Session id: cron:our-pr-ci-monitor:20260918-143348

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 6d838ef

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
Build profile diff infra, repo-wide, and not reachable from this diff: the job's only work is reading binary_sizes on the CI logs cluster, and it neither builds nor runs the server. The read raises RuntimeError: CI logs cluster query failed and the job then prints its own SQL instead of the cluster's error. Measured over the last 48 hours: 309 error rows across 300 distinct heads and 285 distinct pull requests, and 0 rows on master in 14 days, since the job runs on pull requests only #118708 (mine, open)
Performance Comparison (arm_release, master_head, 5/6) harness reporting defect, with no measured regression on this head: of the shard's per-query rows 1356 are success and 4 are unstable, with 0 slower and 0 error rows, yet the shard still reds. The errors term is the only one that reds a shard, and its count comes from compare.sh writing its selective error patterns in GNU basic-regex syntax while running them under ripgrep, so the whole error log falls through to head -10 and its first ten lines are counted as ten error rows. Measured over the last 48 hours: 170 job-level reds across 170 distinct heads and 148 distinct pull requests #116491 (mine, open)
CH Inc sync - CH Inc sync (private, not actionable by me)

Mergeable Check and PR are rollups of the rows above and carry no independent failure. The rest of
the head is green: 151 checks succeeded and 20 were skipped, with no cancellations and nothing queued.

Session id: cron:our-pr-ci-monitor:20260919-010626

alexey-milovidov and others added 4 commits September 19, 2026 20:45
The test arms the server-global fail point
`distributed_plan_read_empty_snapshot_on_deserialize`. Master's Style check
leg `failpoint_tests_are_isolated` requires every stateless test that enables
a fail point to be tagged both `no-parallel` and `no-fasttest`, because tests
that must run alone are kept out of the fast test. The test already had
`no-parallel`; add `no-fasttest`. Test-only, no behaviour change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Pipeline

Master now validates every bucket's coordinator-selected parts for FINAL and
non-FINAL reads alike, before the FINAL/non-FINAL split: a part that is
missing from the local snapshot raises NO_SUCH_DATA_PART, and a part that is
present but pruned by this replica's index analysis is dropped from the
bucket. Every mark that survives is therefore already in
`result.parts_with_ranges`, so the FINAL `else` branch added here could
never throw.

Verified on this tree: with the branch removed, the bucketed FINAL
empty-snapshot query in 04371 still raises NO_SUCH_DATA_PART (the test passes
through tests/clickhouse-test with random settings and with a forced
`index_granularity = 65536`). With the deserialize fix reverted, the same
test reproduces the original LOGICAL_ERROR abort, so the test still catches
the bug.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai and others added 2 commits October 6, 2026 04:48
…ted read

`ReadFromMergeTree::deserialize` passed `build_empty_step_for_distributed_read = true` for every
read, so a non-bucketed read on an empty snapshot became a real empty `ReadFromMergeTree`.
Master now handles that case itself (3034d31, ClickHouse#114659): a null step from `readFromParts` for a
non-bucketed read is rebuilt as a `ReadNothingStep`, which
`ReadFromMergeTreeQueryConditionCacheFlag.DeserializationOnEmptyTableIsEmptyRead` asserts. The
unconditional flag bypassed that fallback and failed the test for both cache variants.

Pass the flag only for a bucketed read (`distributed_read_bucket_count > 0`). That read is pinned to
the coordinator's marks, so it still needs a real step for `initializePipeline` to check it
(`NO_SUCH_DATA_PART` on divergence, an empty read otherwise) instead of hitting the
`LOGICAL_ERROR`. A non-bucketed read falls through to master's `ReadNothingStep`. The comments that
described the flag as covering every read, and master's note that a bucketed read keeps failing,
are updated to match.

04371 now also sets `distributed_plan_prefer_replicas_over_workers = 1`: its failpoint lives in the
replica deserializer, and in a Cloud build an eligible read is otherwise replaced by
`ReadFromMergeTreeAtWorker` (makeDistributed.cpp), so the failpoint would never fire there. The
setting is read only by Cloud code, so open-source runs are unaffected.

Verified on the master merge f47d9f0:
- flag `true` (previous head): DeserializationOnEmptyTableIsEmptyRead fails (2 failures).
- flag `false`: 04371 aborts the server, `Logical error: 'ReadFromMergeTree step is expected to be
  created by readFromParts'`, signal 6 from `ReadFromMergeTree::deserialize`.
- this commit: the 5 ReadFromMergeTreeQueryConditionCacheFlag tests and 157 related query-plan
  gtests pass; 04371 passes under random settings and with forced `index_granularity = 65536`.

Addresses ClickHouse#110929 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The last CI run on this branch is from 2026-10-06. No code change.

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

Copy link
Copy Markdown
Collaborator Author

Correction to the fixing-PR link above: #112644 is closed as superseded, and the Stress test (arm_asan_ubsan) hung check on 7e78ebd7a15ba76b593a2ac7c4ce11ca5e692b2f is fixed by #118483 (merged).

@clickhouse-gh clickhouse-gh Bot added comp-distributed-query-exchange Distributed Query Execution with Exchange operators: cloud-native query distribution using stream... and removed comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. labels Nov 19, 2026

This branch has not been deployed

No deployments
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-distributed-query-exchange Distributed Query Execution with Exchange operators: cloud-native query distribution using stream... groeneai-origin-unknown PR origin: unclassified (legacy task) pr-experimental Experimental Feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LOGICAL_ERROR "ReadFromMergeTree step is expected to be created by readFromParts" in ReadFromMergeTree::deserialize (multistage distributed queries)

3 participants