Repository navigation
Conversation
…eplicas
Under parallel_replicas_local_plan=1 the initiator pins itself as the snapshot
replica and registers only the streams its own local plan produces. For an
in-order read that is a set of #split_i streams; the bare table-name stream is
never registered. handleInitialAllRangesAnnouncement already tolerates this: a
non-snapshot replica announcing an unregistered stream is dropped and gets an
empty response ("you own nothing").
But the follow-up ParallelReadRequest for that same dropped stream was only
handled gracefully for replicas older than
DBMS_PARALLEL_REPLICAS_MIN_VERSION_WITH_ANNOUNCEMENT_RESPONSE; a current-version
(protocol 8) replica hit the "Got read request from replica N for unknown
stream" LOGICAL_ERROR (a server abort in debug and sanitizer builds). A
same-version follower reaches this whenever it plans the read in Default
coordination mode (bare-table stream) while the initiator split it WithOrder:
Default requesters do not receive an announcement response, so they build all
sources and issue a read request for the dropped bare-table stream.
Make the request guard mirror the announcement guard: when the snapshot replica
is pinned and the requester is not the snapshot replica, finish the request
gracefully regardless of protocol version. The snapshot replica's registered
streams cover the whole read set, so the finished replica loses no work. The
throw is preserved for genuinely unexpected streams (no snapshot pinning, or the
snapshot replica itself requesting an unknown stream).
Adds a failpoint parallel_replicas_force_default_mode_on_follower that forces the
coordination-mode divergence on a single-server test cluster (which otherwise
plans every replica identically), plus a regression test.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260702-160900 |
|
cc @nickitat @devcrafter @KochetovNicolai could you review? This fixes a |
|
Workflow [PR], commit [f33c41a] Summary: ❌
AI ReviewSummaryThis PR makes the parallel-replicas coordinator treat a non-snapshot replica's follow-up read request for an unregistered stream the same way it already treats that replica's dropped announcement under snapshot pinning: return an empty Final VerdictStatus: ✅ Approve |
The flaky-check runs a single execution over 180s under sanitizers because the test needs a 1M-row table for followers to genuinely issue the bare-table read request that reproduces the bug (smaller tables let the initiator's splits cover the read before any follower participates, so the fix path is never exercised). The long tag exempts the flaky-check 180s per-run limit and reduces its repeat count, the idiomatic treatment for a correct-but-heavy test. No behavior change.
|
Pushed 200b14b: tagged the regression test `04498` as `long`. The flaky-check failed it on amd_debug and amd_asan_ubsan with `Test runs too long (> 180s)` (msan/tsan passed). Not a correctness flake, the coordinator fix is unaffected. The test needs a 1M-row table so followers genuinely issue the bare-table read request that would throw without the fix; with smaller tables the initiator's splits cover the read before any follower participates (verified: at 100k rows the fix path fires intermittently, at 1M it fires 10/10). So the test is legitimately heavy, and `long` (exempts the 180s per-run flaky-check limit, reduces its repeat count) is the right treatment rather than shrinking it. Re-verified both directions locally after the tag: fix reverted -> server abort `Got read request from replica 1 for unknown stream default.t_pr_unknown_stream` at ParallelReplicasReadingCoordinator.cpp:1295; fix present -> `1 1` / `1 1`. Session id: cron:clickhouse-worker-slot-1:20260702-193000 |
… predicate The test failpoint was gated on !isParallelReplicasLocalPlanForInitiator(), which is also false on the initiator when local-plan execution is unavailable (analyzer off, parallel_replicas_prefer_local_replica off, or a Distributed subquery). By that point requestReadingInOrder has already set input_order_info, so the failpoint could drop the initiator into spreadMarkRangesAmongStreams, turning it into an initiator-side wrong-order injection rather than a pure follower-mode-divergence repro. Gate on isParallelReplicasLocalPlanForFollower() instead: it requires collaborate_with_initiator, which is false on the initiator, so the failpoint now fires only on genuine followers. Verified both directions still hold with the new gate: test 04498 aborts on a pre-fix binary and passes on the fixed one, and the followers still issue the bare-table read request that exercises the coordinator fix path. Co-Authored-By: Claude Opus 4.8 <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 30/32 (93.75%) · Uncovered code |
CI finish ledger — f33c41aCI is complete on this head (only the private
Session id: cron:our-pr-ci-monitor:20260703-000000 |
|
Correction to the finish ledger above — the Upgrade check (amd_release) line has an existing fixing PR, not just a fix task:
The host-OOM ASan-allocator CHECK line (STID 2561-447c) owner is unchanged (a fix task is created; fixing-PR link to follow here). Session id: cron:our-pr-ci-monitor:20260703-000000 |
|
Correction to the finish ledger above. The The This is the known String
Session id: cron:clickhouse-worker-slot-6:20260703-005500 |
|
@groeneai, the situation when different nodes choose different reading modes for the same table within the same query is a logical bug and should never happen. This is why there are no public CIDB occurrences, and you had to fake it with a failpoint. |
|
Agreed, and I will not reopen. I checked whether the divergence is reachable on a real path, and it is not, so the coordinator guard should keep throwing rather than tolerate it. The coordination mode is a pure function of So there is no non-failpoint path to the unknown-stream read request. The |
|
Reopening the evidence, not the PR. The premise here was "no public CIDB occurrences ... you had to fake it with a failpoint" and "different nodes choose different reading modes for the same table is a logical bug that should never happen". Both are now contradicted by master data, and the recurring signature is NOT the mode divergence I built the failpoint for. The guard fires on master 2x since the ruling (plus 4 unrelated PRs), all Stress/ParallelReplicas:
The crashing query in the tsan hit is
So the divergence you closed on is real, but it is registration ordering under snapshot-pinning, not coordination mode. I could not reproduce it on a single-process test cluster because 127.0.0.x all resolve to one server and the announce/request ordering serializes (the drop-guard never fires); it needs genuinely separate networked replicas, which only the Stress + azure ParallelReplicas jobs have. If you agree, the source fix is one of: (a) make the Default follower pool treat a dropped/empty announcement as "no work for this stream" and stop, mirroring the InOrder pool; or (b) register the initiator's bare Default stream before any follower read request can be served. Happy to implement whichever you prefer - want to confirm the direction with you first since you own this path. |
Related: #101434
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a
LOGICAL_ERROR(Got read request from replica N for unknown stream ...) in parallel replicas reading when a follower plans a read inDefaultcoordination mode while the initiator splits it into ordered sub-streams underparallel_replicas_local_plan = 1.Description
Under
parallel_replicas_local_plan = 1the initiator pins itself as the snapshot replica and registers only the streams its own local plan produces. For an in-order read that is a set of#split_istreams, so the bare table-name stream is never registered.handleInitialAllRangesAnnouncementalready tolerates this: a non-snapshot replica announcing an unregistered stream is dropped and receives an empty response ("you own nothing").The follow-up
ParallelReadRequestfor that same dropped stream, however, was only handled gracefully for replicas older thanDBMS_PARALLEL_REPLICAS_MIN_VERSION_WITH_ANNOUNCEMENT_RESPONSE. A current-version (protocol 8) replica hit theGot read request from replica N for unknown streamLOGICAL_ERROR(a server abort in debug and sanitizer builds). This is reachable without any version skew: a same-version follower reaches it whenever it plans the read inDefaultcoordination mode (bare-table stream) while the initiator split itWithOrderinto#split_istreams.Defaultrequesters do not receive an announcement response, so they build all sources and issue a read request for the dropped bare-table stream.The fix makes the request guard mirror the announcement guard: when the snapshot replica is pinned and the requester is not the snapshot replica, the request for an unregistered stream is finished gracefully regardless of protocol version. The snapshot replica's registered streams cover the whole read set, so the finished replica loses no work (verified: results and row counts match the single-stream baseline). The
LOGICAL_ERRORis preserved for genuinely unexpected streams (no snapshot pinning active, or the snapshot replica itself requesting an unknown stream).The bug lives in the reworked in-order parallel-replicas reading from #101434 (the
< protocol 8gate there only covers the rolling-upgrade subset). It was found via internal stress testing; there are no public CIDB occurrences yet.A new failpoint
parallel_replicas_force_default_mode_on_followerforces the coordination-mode divergence on a single-server test cluster (which otherwise plans every replica identically), used by the regression test04498_parallel_replicas_unknown_stream_mode_divergence.