Repository navigation
Conversation
…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]>
Internal second-model review (codex) — click to expandTwo Gate B passes were run. Pass 1 (against an earlier, wrongly-scoped diff) — 1 finding, adjudicated AGREE:
Pass 2 (against the final committed diff No blockers, majors, or nits outstanding. |
Pre-PR validation gate (click to expand)
Feature is experimental ( Session id: cron:clickhouse-author-slot-1:20260718-074900 |
|
cc @davenger @CurtizJ — could you review this? It fixes a LOGICAL_ERROR in |
|
Workflow [PR], commit [398f46e] Summary: ✅
AI ReviewSummaryThe PR fixes empty-snapshot deserialization for bucketed Missing context / blind spots
Final VerdictStatus: ✅ Approve. |
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]>
|
Follow-up fix in b0e4834 (a Fast-test Root cause: 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 Reproduced deterministically and verified both directions locally: without the fix the non-bucketed |
… 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]>
|
Pushed 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 Fix: pin Verified via the real |
CI finish ledger — 95a3e5aEvery 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
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 |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 39/40 (97.50%) · Uncovered code |
CI finish ledger — 7e78ebdEvery failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20260729-043000 |
|
Fixing PR for the That ledger line owes a correction as well as a link. Its stated reason (three queries blocked on the marks-cache mutex behind a 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 This PR remains |
|
New sighting of this bug on master: 2026-09-18, Both symptoms fired in that single job, from the same empty local snapshot:
The query, from test 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 = 1with I re-checked current master: |
…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.
|
Merged master (this branch was 28341 commits behind and conflicting; it is mergeable again). The only conflict was in Re-verified both directions on the merged tree with my own debug builds:
The last commit is comment-only: the |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units74 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. |
CI finish ledger - 419d752Every failure below has an owner. Only
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 |
CI finish ledger - 6d838efEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20260919-010626 |
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]>
…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]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a
LOGICAL_ERRORin experimental multistage distributed query planning (make_distributed_plan) when a worker deserializes a bucketedReadFromMergeTreeread whose local parts snapshot has become empty (parts merged away or dropped concurrently). The worker now returns the retryableNO_SUCH_DATA_PARTerror, or an empty result for a genuinely empty bucket.Description
Fixes the LOGICAL_ERROR
ReadFromMergeTree step is expected to be created by readFromPartsinReadFromMergeTree::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 touchesrandomHadamardTransform); 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).readFromPartsreturns a null step for an empty non-stream read, and the bucketed branch thendynamic_casts it to null and throws. A non-bucketed read got the same null step and was dereferenced byQueryPlan::deserialize; master now rebuilds that case as aReadNothingStep(#114659).Fix: on the deserialize path only,
readFromPartsnow builds a real (empty)ReadFromMergeTreestep for a bucketed read even when the local snapshot is empty.initializePipelinethen resolves it as before: a genuinely empty bucket reads nothing, and a bucket whose coordinator-selected part is missing locally raises the existing retryableNO_SUCH_DATA_PARTdivergence error. AReadNothingStephere would bypass that check and silently drop rows. Non-bucketed reads keep master'sReadNothingStep, and the otherreadFromPartscallers are unchanged.Workflow [PR]
Sync PR [sync-upstream/pr/110929]