Repository navigation
Marshall blocks in parallel for plan-based parallel replicas - #121642
Conversation
The replica executes a shipped plan fragment and never runs the planner, so `BlocksMarshalling` was never added. Put it on the fragment on the initiator, and register the step so a serialized plan carrying it can be deserialized at all. Closes: #118274 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [100b3c9] Summary: ✅
AI ReviewSummaryThis PR fixes the plan-based parallel-replicas path by injecting Findings❌ Blockers
Final VerdictStatus: Minimum required actions:
LLVM Coverage ReportMeasured on commit 100b3c9.
Changed lines: Changed C/C++ lines covered: 29/32 (90.62%) · Uncovered code |
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Copilot review overview
Review effort: Lite
Findings: 1
Open (3)
If the root isBlocksMarshallingStep, the code assumes the node has at least one child and… · New This duplicates the planner-side gate (noted in the comment) inline. To prevent drift if the… · New The test creates a fixed table name (tab) without cleanup. In stateless test suites this can fail… · New
What changed in this PR
Adds plan-fragment-level BlocksMarshalling for plan-based parallel replicas so replicas marshal result blocks in parallel (when enabled) even though they don’t run the planner, and fixes deserialization/step-introspection fallout from introducing the step into serialized fragments.
Changes:
- Add
BlocksMarshallingStepto remote parallel-replica plan fragments under the same gate as the planner path. - Register
BlocksMarshallinginQueryPlanStepRegistryand bump query plan serialization version. - Adjust
ReadFromParallelReplicasStepto detect partial aggregation through aBlocksMarshallingSteproot; add a stateless test covering the behavior.
| File | Description |
|---|---|
| tests/queries/0_stateless/05238_pr_plan_based_blocks_marshalling.sh | New stateless test validating step placement/counting and that shipped fragments execute correctly. |
| tests/queries/0_stateless/05238_pr_plan_based_blocks_marshalling.reference | Expected output for the new stateless test. |
| tests/queries/0_stateless/04647_no_blocks_marshalling_for_local_shard_plan.sh | Update comments now that BlocksMarshalling is registered and serialized plans can execute. |
| src/Processors/QueryPlan/ReadFromParallelReplicas.cpp | Look through BlocksMarshallingStep to preserve AggregatedChunkInfo detection. |
| src/Processors/QueryPlan/QueryPlanStepRegistry.cpp | Register BlocksMarshalling step so serialized fragments can be deserialized. |
| src/Processors/QueryPlan/ParallelReplicasLocalPlan.cpp | Add marshalling step to remote parallel-replica fragments when gating conditions match. |
| src/Processors/QueryPlan/BlocksMarshallingStep.cpp | Provide step-registration hook for QueryPlanStepRegistry. |
| src/Core/ProtocolDefines.h | Bump plan serialization version due to new registered step. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units262 translation units recompiled, 2390 s compile time in total, 262 of them have a recent master baseline. |
Register the step with the version that introduced it, and fall back to SQL for a peer below it, so a shard that cannot parse the name never gets the plan. Share the context-side part of the gate with the planner. Fix the new test under the randomized settings of the flaky check: with `optimize_read_in_order = 0` the top-N read is picked for the Top-K filter optimization and stays local, so the query it asserts on cannot use a LIMIT. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`chassert` is compiled out in release, where `children.front()` on an empty node would be undefined behaviour. Silently skipping the step instead would drop `AggregatedChunkInfo` and give wrong results, so let the error propagate. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
It is the ordinary `serialize_query_plan` fan-out to shards, not parallel replicas; the old comment led with the parallel-replicas case, which is exactly the one that cannot reach the check. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Initiator in plan-based parallel replicas don't work with older remote nodes
…based-blocks-marshalling
The comment on the step's introduction version still promised a SQL fallback, and two includes were only needed by the removed plan walk. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
| { | ||
| } | ||
|
|
||
| void registerBlocksMarshallingStep(QueryPlanStepRegistry & registry); |
There was a problem hiding this comment.
| void registerBlocksMarshallingStep(QueryPlanStepRegistry & registry); |
…based-blocks-marshalling
| static constexpr auto DBMS_QUERY_PLAN_SERIALIZATION_VERSION = 20; | ||
| /// Version 21 registers the `BlocksMarshalling` step, so a plan fragment that pre-serializes its | ||
| /// result blocks can be shipped. A peer below it does not know the name and rejects the whole plan. | ||
| static constexpr auto DBMS_QUERY_PLAN_SERIALIZATION_VERSION = 21; |
There was a problem hiding this comment.
DBMS_QUERY_PLAN_SERIALIZATION_VERSION is part of the inter-server QueryPlan packet contract, and this bump to 21 is paired with a new versioned BlocksMarshalling step becoming serializable.
The matching docs/reference/interfaces/specs/NativeProtocol.mdx entry still documents only the version-10 QueryPlan change, so the spec no longer describes the current wire behavior. Please update the QUERY_PLAN_SERIALIZATION / QueryPlan sections in the same change.
…based-blocks-marshalling
| static constexpr auto DBMS_QUERY_PLAN_SERIALIZATION_VERSION = 20; | ||
| /// Version 21 registers the `BlocksMarshalling` step, so a plan fragment that pre-serializes its | ||
| /// result blocks can be shipped. A peer below it does not know the name and rejects the whole plan. | ||
| static constexpr auto DBMS_QUERY_PLAN_SERIALIZATION_VERSION = 21; |
There was a problem hiding this comment.
Because DBMS_MIN_QUERY_PLAN_SERIALIZATION_VERSION_WITH_PARALLEL_REPLICAS still aliases the global DBMS_QUERY_PLAN_SERIALIZATION_VERSION, this bump to 21 now disconnects every version-20 replica from the older ReadFromParallelRemoteReplicasStep path as well. That path still builds a serialized plan without BlocksMarshalling (tests/queries/0_stateless/03303_distributed_explain.reference still shows the serialize_query_plan = 1 branch under ReadFromRemoteParallelReplicas ending at Aggregating), so those peers could execute the plan before this change and are now dropped during a rolling upgrade for no query-local reason.
The plan-based fragment does need a 21 gate, but it needs to be separated from the query-based parallel-replicas path, or that older path needs per-peer serialization or fallback instead of inheriting the stricter global minimum.
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|


Closes: #118274
With
parallel_replicas_plan_based = 1the replica runs a shipped plan fragment and never runs the planner, so the gate inPlanner::buildPlanForQueryNodenever fired andBlocksMarshallingwas never added — blocks came back marshalled single-threaded inTCPHandler. The initiator now adds the step to the fragment increateRemotePlanFragmentForParallelReplicas; the local fragment deliberately does not get it, since nothing unmarshals it in this process. The context-dependent part of the planner gate is shared ascontextAllowsBlocksMarshalling.Two supporting changes:
BlocksMarshallingStepwas serializable but not registered inQueryPlanStepRegistry, so a serialized plan carrying it failed withUnknown query plan step: BlocksMarshalling. Now registered with21as its introduction version;DBMS_QUERY_PLAN_SERIALIZATION_VERSIONis bumped to21, which also excludes older replicas from plan-based parallel replicas.ReadFromParallelReplicasStepsetsadd_agg_infoby checking the fragment root for a partialAggregatingStep; it now looks through the marshalling step.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Blocks sent back by remote replicas are now marshalled in parallel (
enable_parallel_blocks_marshalling) whenparallel_replicas_plan_basedis enabled.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/121642]
Version info
26.10.1.1179-master(included in26.10and later)