Repository navigation
Reimplement reading in order for parallel replicas - #101434
Conversation
|
Workflow [PR], commit [e759052] Summary: ❌
AI ReviewSummaryThis PR reworks in-order parallel-replica reads to use split streams, adds the announcement-response protocol needed to align followers with the initiator's topology, and updates the protocol spec/tests accordingly. The main correctness issues from earlier rounds look addressed, but one follower-side scalability problem is still present in the current code, and the PR's current benchmark signal is still negative on the path it claims to improve, so I would not approve it yet. Findings
Tests
Final VerdictStatus: Minimum required actions:
|
|
The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix. |
…packet 14 - Feature table `VERSIONED_PARALLEL_REPLICAS_PROTOCOL`: current value bumped from `7` to `8`, with a paragraph describing what version `8` adds (`MergeTreeAllRangesAnnouncementResponse` and the initiator-replies-to-followers contract). - `ServerHello.parallel_replicas_protocol_version` and `Addendum.parallel_replicas_protocol_version`: current value bumped `7` → `8` so the canonical-value column matches `DBMS_PARALLEL_REPLICAS_PROTOCOL_VERSION`. - Client → Server packet table: add packet `14` `MergeTreeAllRangesAnnouncementResponse`, body `not specified` to match the convention used by sibling parallel-replicas packets, with a description that explains the version gate and that it's inter-server only. Co-Authored-By: Claude Opus 4.7 <[email protected]>
Add a dedicated `MergeTreeAllRangesAnnouncementResponse` section under
"Message reference" describing:
- When the packet flies (`parallel_replicas_protocol_version ≥ 8` AND
the originating announcement's `mode` is non-`Default`; `Default`
mode stays fire-and-forget).
- The three top-level body fields (`version`, `parts`, `stream_id`)
and how `version` falls back below the
`DBMS_MIN_REVISION_WITH_VERSIONED_PARALLEL_REPLICAS_PROTOCOL` TCP
revision.
- The `RangesInDataPartsDescription` and `RangesInDataPartDescription`
wire formats with their gates (`MIN_VERSION_WITH_PROJECTION` v5,
`MIN_VERSION_WITH_MIN_MARKS_PER_TASK` v6).
- The `MergeTreePartInfo` and `MarkRanges` byte layouts including the
little-endian / VarUInt / boolean-text quirks.
Link the Client → Server packet-table row and the feature-table entry to
the new body section so the canonical spec covers everything needed to
implement or validate the v8 inter-server packet.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
…up packet direction The response-flow narrative incorrectly said the follower issues `MergeTreeReadTaskResponse` (client packet `10`) after the announcement-response, which is the response side — i.e. the initiator's reply, on the wrong endpoint. The follower actually sends `MergeTreeReadTaskRequest` (server packet `16`, follower→initiator) and the initiator replies with `MergeTreeReadTaskResponse` (client packet `10`). Correct the wording and spell out both packet roles so third-party native clients don't implement the response side on the wrong endpoint. Co-Authored-By: Claude Opus 4.7 <[email protected]>
…egisteredParts The two comments around `getRegisteredParts` / `stream_to_registered_parts` suggested that `InOrderCoordinator` drops covered/covering parts during normalization of a single announcement, making the captured working set a subset of the announcement payload. That's wrong: within a single MergeTree replica's announcement parts are non-overlapping by construction, and the cover/covered branches in `doHandleInitialAllRangesAnnouncement` only ever deduplicate across replicas (which, in the snapshot-pinned topology this PR adds, is moot because the snapshot replica is the first announcer). Rewrite both comments to describe what's actually happening: the working set equals the first announcement one-to-one, and we capture it via `getRegisteredParts` (rather than from the announcement directly) only to keep the lookup independent of any future per-stream coordinator that may post-process its input. Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
|
||
| MergeTreeReadPoolPtr pool; | ||
|
|
||
| /// Authoritative set of (parent_info, projection_name) reported by the coordinator for this |
There was a problem hiding this comment.
Could we simplify the comment? AI makes it harder to perceive.
Under some CI configs the loop-insert pattern (one `INSERT` per node into a `ReplicatedMergeTree`) ended up with more than 1M rows in `ts` because replication timing left the table somewhere between 1M and 3M rows when queries started. `sum()` and `LIMIT` queries survived that (parallel replicas dedupes reads, so `sum` looks correct at 1x and `LIMIT 10` is idempotent), but the new `count()` assertion caught the extra rows and failed on amd_msan / amd_asan_ubsan / arm_binary variants with `count=20` instead of `10` per group. Insert exactly once from `split_topology_nodes[0]` and `SYSTEM SYNC REPLICA` the other two, then `OPTIMIZE FINAL` everywhere, so every replica sees the same 1M rows regardless of scheduler timing. Fixes: 4x reports on https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101434&sha=489aca864d0395f291e59e15f93d7a36e7986338&name_0=PR Co-Authored-By: Claude Opus 4.7 <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 392/421 (93.11%) · Uncovered code |
…o-read-setting
The branch was ~11.7k commits behind (last merge 2026-06-20) and red. The
diff vs. `master` is still the single randomizer line — no functional change:
"parallel_replicas_min_number_of_rows_per_replica": lambda: random.randint(0, 1),
Reason to re-merge now: the parallel-replicas owners have landed several
directly relevant fixes since 2026-06-20, so refreshing CI on today's
`master` will narrow the remaining set of genuine product bugs this PR is
meant to surface:
- #108451 (`Fix NOT_FOUND_COLUMN_IN_BLOCK for virtual columns under parallel
replicas`, closes #106561) — should clear the tracked
`04098_asterisk_include_virtual_columns_mergetree` failure.
- #101434 (`Reimplement reading in order for parallel replicas`) — bears
directly on the `max_rows_to_read`-not-honored class
(`02155_read_in_order_max_rows_to_read`, `00945_bloom_filter_index`).
- #109003 (`Fix server abort on GROUPING SETS in a set operation with
parallel replicas`) — a "Server died" class fix.
- Flaky-test fix for `04051_pk_analysis_stats`.
Conflicts were all in files the branch does not intentionally change (its
only intended change is the one `tests/clickhouse-test` line); they were
resolved by taking `master`'s version. No pinning/blacklisting of the
affected parallel-replicas tests — that would mask the very signal this PR
exists to produce.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
In `executeQueryWithParallelReplicas`, the local-plan branch is skipped when the parallel-replicas read sits inside a Distributed sub-query (`_shard_num != 0`) or when `parallel_replicas_prefer_local_replica` is off. In those cases the coordinator is never pinned via `setSnapshotReplicaNum` and no replica slices the parts, but followers were still consulting only the per-replica settings in `isParallelReplicasLocalPlanForFollower`, so they took the over-announce "`num_streams` pools, each over all parts" path. Each per-split coordinator then registered the full part from the first follower's announcement and the work amplified by `num_streams` — measured at 32× for `00177_memory_bound_merging` in the flaky check. Extract the gate into `ClusterProxy::canUseLocalPlanForParallelReplicas` and call it from both `executeQueryWithParallelReplicas` and `ReadFromMergeTree`, so followers honour the same topology decision as the initiator and fall back to the single-pool path when no local plan exists. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101434&sha=latest&name_0=PR&name_1=Stateless+tests+%28amd_asan_ubsan%2C+flaky+check%29 PR: ClickHouse#101434 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Reimplement reading in order for parallel replicas
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reading in-order with Parallel Replicas now uses the same logic of splitting the table into
max_threadsparts as the local reading for better parallelism.Private test results.
Claude PR summary
Version info
26.7.1.426(included in26.7and later)