Skip to content

Make system.one and bounded numbers reads serializable for distributed plan fragments - #119862

Merged
devcrafter merged 27 commits into
masterfrom
serialize-read-from-system-one
Oct 19, 2026
Merged

devcrafter merged 27 commits into
masterfrom
serialize-read-from-system-one

Conversation

@devcrafter

@devcrafter devcrafter commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

A plan fragment is serialized before it is sent to a replica, and IQueryPlanStep::isSerializable defaults to false, so one step that does not implement it keeps the whole fragment local. ReadFromSystemOneStep and ReadFromSystemNumbersStep did not implement it, so a join whose broadcast side reads system.one or numbers(...) was never shipped - liftSplitAboveJoin left the split below the join and only the other side's read was distributed:

ApplyParallelReplicas: Keeping the plan fragment local: step 'ReadFromSystemOne' is not serializable for remote execution

Both are now serializable. system.one has no state beyond its header. For numbers(...), numbers_mt(...), system.numbers and generate_series(...) only the table's parameters are serialized (range length if any, offset, step, direction), and max_block_size goes through the step settings. The source filter and the pushed-down LIMIT are not serialized: the replica optimizes the plan it receives and pushes them into the read again from the shipped FilterStep/LimitStep, so the filter's pruning still applies there. An unbounded read is shipped too; it is ended by the plan's own LIMIT or filter, or by cancelling the query, as it is locally.

Both are new step names, so they are registered with since_plan_version = 20 (the 26.10 bump of DBMS_QUERY_PLAN_SERIALIZATION_VERSION): the registry never writes them into a stream for an older peer, and the parallel replicas gate, tied to that constant, keeps replicas on an older version out.

For system.one this is a regression fix in reach: ReadFromStorageStep::isSerializable returns true for SystemOne, but StorageSystemOne has emitted its own step since eb5c15d, so that path stopped being reachable.

Measured with parallel_replicas_plan_based = 1, all answers matching a run without parallel replicas:

broadcast side join shipped
system.one yes
numbers(5), numbers(3, 5) yes
numbers(20) WHERE number % 3 = 0 yes
numbers(1e12) WHERE number = 5 yes, in tens of ms
system.numbers LIMIT 5 (unbounded) yes
generate_series(0, 18, 2) yes

05045_distributed_plan_fallback_to_local used SELECT 1 as its "no distributable source" case, which held only because of this gap; it now uses a Memory table.

This does not unify 04724_parallel_replicas_right_join_* with plan-based: 15 of its 33 assertions check for GLOBAL ALL RIGHT JOIN together with _data_, i.e. that the left side was materialized into a temporary table, which plan-based does not do - it ships the left side's plan.

A broadcast side with a non-deterministic function (rand64() over system.one) is evaluated once per replica, as a MergeTree broadcast side already is today; that is tracked separately.

Related: #112351
Related: #125853

Changelog category (leave one):

  • Improvement

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

Plan-based parallel replicas can now distribute a join whose broadcast side reads system.one, numbers(...), system.numbers or generate_series(...), instead of keeping the join on the initiator.


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

Version info

  • Merged into: 26.11.1.239-master (included in 26.11 and later)

A plan fragment is serialized before it is sent to a replica, and every step in it has to be
serializable: `isSerializable` defaults to `false`, so one step that does not implement it keeps the
whole fragment local. `ReadFromSystemOneStep` did not implement it, so a fragment reading
`system.one` could not be shipped - for instance the broadcast side of a `RIGHT JOIN` whose left
side is `system.one`, where `liftSplitAboveJoin` then leaves the split below the join and only the
right side's read is distributed.

The step has no state beyond its output header - it produces the single dummy row - so a replica
rebuilds it from the header alone.

`ReadFromStorageStep::isSerializable` already returns true for `SystemOne` and its `deserialize`
rebuilds that single-row chunk, but `StorageSystemOne` has had its own reading step since
eb5c15d, so that path stopped being reachable for `system.one`.

`05045_distributed_plan_fallback_to_local` used `SELECT 1` as its example of a plan with no
distributable source, which held only because of this gap. It now uses a `Memory` table, whose data
lives on a single node, and pins that a plan whose only source is `system.one` does ship.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [29f663d]

Summary: ✅


AI Review

Summary

This PR makes ReadFromSystemOneStep and ReadFromSystemNumbersStep serializable so distributed plans and plan-based parallel replicas can execute these sources remotely. At head 29f663ddd107ab1e5766fdbb48fdd0f8ccaf0c91, the existing compatibility and scoped-limit findings remain unresolved. Two previously dismissed safety/correctness findings also remain applicable and are recorded below without reopening their threads. ❌ Block pending the compatibility and scoped-limit fixes.

Missing context / blind spots
  • ⚠️ No local ClickHouse build or executable was available. The remaining findings were verified by tracing the current source and reviewing CI evidence; the focused reproductions below were not rerun locally.
Findings

❌ Blockers

  • Introduction-version checks are skipped for older streams. QueryPlanStepRegistry.cpp:180: registering the sources with since_plan_version = 20 does not prevent writing them at version 18. Serialization.cpp:162 calls versionToWrite only for plan versions 19 and later. A one-source plan serialized at 18 therefore writes the new name and payload successfully, and an older receiver rejects it with Unknown query plan step. The parallel-replica version gate protects that path, but Connection::sendQueryPlan also serializes at the peer's advertised version. Check introduction versions unconditionally; gate only the per-step version field on 19. Existing thread.

  • Remote reconstruction loses subquery read limits. ReadFromSystemNumbersStep.cpp:562: the original StorageLimitsList accumulates outer and nested limits through Planner::buildPlanForQueryNode and the nested planners in PlannerJoinTree.cpp, but deserialization replaces it with one entry derived from the receiving context. The fragment context comes from the coordinated MergeTree read, so settings belonging only to the broadcast subquery disappear. With the 05397 fixture, move max_bytes_to_read_leaf = 100000 into (SELECT number FROM numbers(100000) SETTINGS ...) and set the outer limit to 0: local execution enforces the nested limit on the 800000-byte read, while the reconstructed source has no leaf-byte limit. Preserve the effective scoped limits, or keep sources local when their limits cannot be reconstructed. Existing thread and complete reproduction.

  • A received header can disagree with the generated column. StorageSystemOne.cpp:81 [dismissed by author -- https://github.com/Make system.one and bounded numbers reads serializable for distributed plan fragments #119862#discussion_r4270261575]. With process_query_plan_packet enabled, an authenticated client can declare dummy Array(Tuple(UInt8)); the source retains that header but emits a ColumnUInt8. A following tupleElement(dummy, 1) then reaches an invalid ColumnArray cast in release builds. The feature's default-off, unhardened status limits exposure but does not make this execution memory-safe. Reject headers other than one UInt8 column before constructing the step.

  • A broadcast subtree can produce different rows on each replica. StorageSystemOne.h:67 [dismissed by author -- https://github.com/Make system.one and bounded numbers reads serializable for distributed plan fragments #119862#discussion_r4271342439]. Making these sources serializable lets liftSplitAboveJoin ship (SELECT dummy AS k, rand64() AS token FROM system.one) or the equivalent over numbers(1). Each active replica evaluates its own token, so joining a zero-key table and selecting uniqExact(token) can return more than 1, unlike local execution. The same defect already exists for a MergeTree broadcast source and is tracked in Plan-based parallel replicas evaluate a non-deterministic broadcast join side once per replica #125853; that shared cause does not preserve correctness for the newly shippable sources. Keep evaluation-sensitive broadcast subtrees local or materialize them once.

Tests

The new 05214, 05215, and 05397 tests pass in the current-head Fast test report, but leave these regression gaps:

  • ⚠️ Exercise both new sources through QueryPlan::serialize at versions 18, 19, and 20; the first two must reject them and 20 must round-trip. Testing the registry helper alone misses the skipped call.
  • ⚠️ Extend limit coverage with a byte limit scoped only to the broadcast subquery, keeping the outer limit unlimited and remote-only execution. 05397 currently tests only an outer-query limit.
Final Verdict

❌ Block. Enforce source introduction versions on every serialization path and preserve effective subquery read limits, with the focused regressions above. The two dismissed findings remain recorded for visibility; they were not reposted or reopened. No distinct new inline finding was identified.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Sep 13, 2026
Same reason as the previous commit: a plan fragment is serialized before it is sent to a replica, so
one non-serializable step keeps the whole fragment local. With `numbers(...)` on the broadcast side
of a join - the shape `04724_parallel_replicas_right_join_*` exercises for the query-based
implementation - `liftSplitAboveJoin` had to leave the split below the join, so only the right
side's read was distributed.

A replica rebuilds the read from the table's parameters, so only a read it can reproduce exactly is
shipped: the step reports itself serializable only when the domain is bounded and no source filter
is attached.

- A filter prunes the generated domain. Shipping the read without it is not wrong - the plan keeps
  its own filtering step - but the replica would generate the whole domain, which for an unbounded
  read never finishes. Both cases stay local instead.
- A LIMIT pushed into the read is carried across, so the replica does not generate rows that are
  then discarded.

`numbers(5)` and `numbers(3, 5)` on the broadcast side now ship the join and answer as they do
without parallel replicas; a filtered read and `system.numbers` still keep the fragment local.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@devcrafter devcrafter changed the title Make ReadFromSystemOneStep serializable Make system.one and bounded numbers reads serializable for distributed plan fragments Sep 13, 2026
@devcrafter
devcrafter marked this pull request as draft September 13, 2026 22:54
…tribute

The previous commit refused to ship a filtered `numbers(...)` read, which was stricter than
necessary: the plan keeps its own filtering step, so a replica that generated the unpruned domain
would still answer correctly. What it would lose is the pruning - `numbers(1e12) WHERE number = 5`
generates one value on the initiator and would generate the whole domain on each replica.

So serialize the filter along with the table's parameters, the way `FilterStep` does, and let a
bounded read ship whether or not it is filtered. An unbounded read still stays local, because
nothing would bound what the replica generates there.

Measured: `numbers(1e12) WHERE number = 5` on the broadcast side of a join now ships and answers in
tens of milliseconds, so the pruning survives the trip. The test pins this with `read_rows` rather
than with a query whose regression would hang.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the comp-parallel-replicas Parallel reading from replicas for query speed (not data replication consistency). label Sep 13, 2026
Comment on lines +125 to +126
registerReadFromSystemOneStep(registry);
registerReadFromSystemNumbersStep(registry);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs the usual query-plan serialization version bump. After this PR, version 18 is no longer enough to safely talk to an older peer: a new initiator can now serialize ReadFromSystemOne / ReadFromSystemNumbers into a remote fragment, an older node still advertises query-plan serialization version 18, and QueryPlanStepRegistry::createStep there will fail with Unknown query plan step because these names were not registered yet. Recent additions like LimitRangeStep and FillingStep handled this by bumping DBMS_QUERY_PLAN_SERIALIZATION_VERSION and gating the new step on the new minimum. Without that, mixed-version clusters fail at execution time instead of being excluded up front.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 868dee8: both steps are registered with since_plan_version = 20 (the 26.10 bump), so the registry never writes them into a stream for an older peer, and the parallel replicas gate excludes replicas below that version.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parallel-replica gate is present, but the claim that the registry never writes these names into an older stream is still not true at src/Processors/QueryPlan/Serialization.cpp:162: versionToWrite is called only when the plan version is at least 19. For a one-node ReadFromSystemOne plan, QueryPlan::serialize(out, 18) skips that check and writes the new step name and payload successfully; a version-18 receiver then rejects it with Unknown query plan step. ReadFromSystemNumbers takes the same path.

Please check the step's introduction version for every stream version, and condition only the writing of the per-step version field on version 19. A regression through QueryPlan::serialize at versions 18, 19, and 20 would cover this; checking versionToWrite directly does not exercise the skipped call.


/// The query info is only read for a pushed-down LIMIT and for storage limits, both of which the
/// replica applies through its own plan, so an empty one is what the read needs here.
SelectQueryInfo query_info;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reconstruction drops the original query_info.storage_limits. The local path stores them in storage_limits and initializePipeline attaches them to every source processor, which is what lets ReadProgressCallback enforce byte limits and per-leaf time / speed limits. Here the worker rebuilds the step from an empty SelectQueryInfo, so the shipped numbers(...) read runs with an empty StorageLimitsList: NumbersLikeUtils::checkLimits() still catches the row-count settings, but max_bytes_to_read*, leaf byte limits, and read-speed / per-leaf timeout checks are silently bypassed on the replica path. Please reconstruct the same storage-limit state (or serialize it explicitly) before creating the step.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mechanism is right, but this is not specific to this step or new in this PR, so I filed it separately: #119953

Every read inside a shipped plan fragment already runs with an empty StorageLimitsList, including the principal one: ReadFromMergeTree::deserialize builds a fresh SelectQueryInfo and fills only the table-expression modifiers, the row-level filter and prewhere (ReadFromMergeTree.cpp:6736), then attaches query_info.storage_limits at :5333. The receiving side (TCPHandler.cpp:2935, QueryPlan::deserialize) attaches nothing, and neither does DistributedPlanExecutor, so make_distributed_plan has the same gap.

Reconstructing the limits here only would make a numbers(...) read stricter than the MergeTree read beside it in the same fragment, and would close none of the real exposure.

The fix also does not belong in per-step serialization: the receiving node already has the settings the limits are computed from, which is how the row-count limit still works on this path today - NumbersLikeUtils::checkLimits(context->getSettingsRef(), ...). Deriving a StorageLimitsList once on the receiving side and attaching it to the deserialized plan's sources covers ReadFromMergeTree, the system-table sources and make_distributed_plan together. That will start enforcing limits that are silently ignored today, so it wants its own PR and tests, which is what the issue tracks.

Worth recording that query-based parallel replicas do not have the gap: the replica re-plans from SQL and derives the limits from its own settings (InterpreterSelectQuery.cpp:2932/:3012, Planner.cpp:2612).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3684e8d: deserialize rebuilds the storage limits from the query settings, as ReadFromMergeTree::deserialize does since #119953 was fixed. 05397_pr_plan_based_numbers_storage_limits covers it with a byte limit on a remote replica.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This restores outer-query limits, but src/Processors/QueryPlan/ReadFromSystemNumbersStep.cpp:562 still replaces the original limit stack with limits from the single receiving ctx.context. Local planning accumulates outer and subquery limits in Planner.cpp:2723 and passes them into the nested planner at PlannerJoinTree.cpp:3127. A nested SETTINGS clause therefore contributes limits that are absent from the replica's context; the fragment context is taken from the coordinated MergeTree read at applyParallelReplicas.cpp:693.

Using the fixture and settings from 05397, put the byte limit inside the broadcast subquery and leave the outer leaf limit at zero:

SELECT count()
FROM
    (SELECT number FROM numbers(100000)
     SETTINGS max_bytes_to_read_leaf = 100000,
              read_overflow_mode_leaf = 'throw') AS l
RIGHT JOIN t_numbers_limits AS r ON l.number = r.key
SETTINGS max_bytes_to_read_leaf = 0;

The local source carries the nested 100000-byte limit for its 800000-byte read. The deserialized source reconstructs a zero leaf-byte limit from the outer context, so that limit is lost. Keep parallel_replicas_local_plan = 0, query_plan_join_swap_table = 0, and enable_join_runtime_filters = 0 as in 05397 when testing this. Please preserve the effective scoped limits, or keep a read local when its limit stack cannot be reconstructed, and cover this nested case as well.

`ReadFromSystemOne` and `ReadFromSystemNumbers` are new step names in the registry, so a peer that
does not know them must never be sent one. Two mechanisms cover that, and both key off the version:

- Parallel replicas serialize the fragment once and reuse the blob for every replica, so a replica
  below `DBMS_MIN_QUERY_PLAN_SERIALIZATION_VERSION_WITH_PARALLEL_REPLICAS` is excluded up front.
  That constant is tied to `DBMS_QUERY_PLAN_SERIALIZATION_VERSION`, so bumping it to 19 is what
  keeps a replica on the previous version out.
- A plan sent over a connection is serialized at the peer's advertised version, so both steps fail
  closed below version 19, the way `WindowStep` does for its own registration version.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 29f663ddd with master 0faaf235d (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 80010618b; 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.

Object file sizes

6 object files changed (+52.95 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Processors/QueryPlan/ReadFromSystemNumbersStep.cpp.o 191.43 KiB 238.29 KiB +46.86 KiB (+24.48%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

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

Job report

devcrafter and others added 3 commits September 22, 2026 16:14
…-system-one

Conflict in `src/Core/ProtocolDefines.h`: master took the query-plan serialization version to 20
(19 for the per-step version, 20 for `legacy_join_size_limits_trigger_spilling`) while this branch
had claimed 19 for the new source steps. Moved this branch's bump to 21 and its
`DBMS_MIN_QUERY_PLAN_SERIALIZATION_VERSION_WITH_SYSTEM_SOURCE_STEPS` with it, keeping master's
entries.

Registering a new step name is not what the per-step version added in master's 19 covers - that
lets a step change its own bytes - so the global bump is still what keeps an older peer, which does
not know the name at all, from being sent one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…able sources

`05185_distributed_plan_fallback_contexts_stress` asserted that every query in
its family falls back to local execution. Three of them now distribute their
outer plan, because that plan reads only `system.one` or `numbers(...)` and
those are exactly the sources this change makes serializable: the scalar
subquery rows `06`/`07` and the `INSERT ... SELECT number FROM numbers(1000)`
of row `27`. The inner query carrying the `max_rows_to_group_by` limit still
falls back, and the row counts the test checks are unchanged.

The task-count column becomes a flag. The count of remote tasks depends on how
many workers the job's cluster has, which was invisible while every row was
zero, and the positive controls of the same test already report `> 0`.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119862&sha=004fee431c75a16e5f8bbefe3f6d89e0309b9e17&name_0=PR&name_1=Fast%20test
#119862

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@KochetovNicolai KochetovNicolai self-assigned this Sep 29, 2026
Comment thread src/Core/ProtocolDefines.h Resolved
Comment thread src/Core/ProtocolDefines.h Resolved
Comment on lines +477 to +479
/// The generated domain has to be reproducible on the replica. The source filter is shipped
/// along with the table's parameters, so a filtered read is fine; an unbounded one is not,
/// because nothing then bounds what the replica generates.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not make sense to me. Why should we care here?
Unbounded read should be allowed. It can make sense. The query should be cancellable if needed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 7e6defb: every numbers read is serializable now; an unbounded one is ended by the plan's own LIMIT/filter or by cancellation, as locally.

const auto & numbers_storage = storage->as<const StorageSystemNumbers &>();
chassert(numbers_storage.limit.has_value());

writeStringBinary(numbers_storage.column_name, ctx.out);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be amy name but number? I think this should not be serialized. Please check.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can also be generate_series (from generate_series(...)). It is not serialized anymore: deserialize takes it from the step's output header (28dd286).

Comment on lines +497 to +515
writeBinaryLittleEndian(*numbers_storage.limit, ctx.out);
writeBinaryLittleEndian(numbers_storage.offset, ctx.out);
writeBinaryLittleEndian(numbers_storage.step, ctx.out);

UInt8 flags = 0;
if (numbers_storage.multithreaded)
flags |= 1;
if (numbers_storage.descending)
flags |= 2;
if (limit.has_value())
flags |= 4;
if (filter_actions_dag)
flags |= 8;
writeIntBinary(flags, ctx.out);

/// A LIMIT pushed into the read is only a hint - the plan keeps its own limiting steps - but
/// carrying it keeps the replica from generating rows that are thrown away.
if (limit.has_value())
writeBinaryLittleEndian(static_cast<UInt64>(*limit), ctx.out);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should not be two limits.
I understand that one is pushed down from optimization, and another one is a table-function property.
However, it does not make sense to serialize both. Choose the minimum if both exist.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are different quantities: the table's is the length of the value range, the pushed-down one is a row count after the filter, so min is wrong with step > 1 or a filter. Neither needs serializing: the replica optimizes the received plan and sets the limit and the source filter again from the shipped LimitStep/FilterStep, so both are dropped (d37bf2f).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can it optimize the one with a value range?

if (limit.has_value())
writeBinaryLittleEndian(static_cast<UInt64>(*limit), ctx.out);

writeBinaryLittleEndian(static_cast<UInt64>(max_block_size), ctx.out);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be serialized via settings (override serializeSettings)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 8b682b7: max_block_size goes through serializeSettings now.

@clickhouse-gh

clickhouse-gh Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 36 queries analysed

This PR lets the ReadFromSystemOne and ReadFromSystemNumbers plan steps be serialized, so plans that read system.one or bounded numbers() can be shipped under make_distributed_plan or plan-based parallel replicas. Single-node ClickBench and TPC-H queries never run this code. The one flagged result, clickbench Q23 at -40.0%, has been downgraded to not sure. Q23 does not read either system source, its baseline was very noisy, and the PR median of 51 ms is inside master's recent 48-87 ms range. CPU time also dropped, but because the changed code is off this query's path, that points to baseline variance rather than an effect of the PR.

clickbench

⚠️ 1 inconclusive

Flagged queries (1 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 23 not_sure 85 51 -40.0% <0.0001 The PR only makes the system.one and numbers() read steps serializable for distributed and parallel-replica plans, and Q23 uses neither. The -40.0% change comes from a noisy baseline and falls inside master's recent range.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 459716cd-bf3d-4c61-802c-d2345e1f860b
  • MIRAI run: 1d9e8544-b889-445d-8ccf-2f7856cadd2c
  • PR check IDs:
    • clickbench_2393286_1790690269
    • clickbench_2393348_1790690272
    • clickbench_2393403_1790690273
    • tpch_adapted_1_official_2393524_1790690276
    • tpch_adapted_1_official_2393575_1790690278
    • tpch_adapted_1_official_2393796_1790690302

devcrafter added a commit that referenced this pull request Sep 30, 2026
`04724_parallel_replicas_right_join_ineligible_right_side` is pinned to the
query-based implementation, because every assertion in it wants one `EXPLAIN`
line carrying both the reading step and the text `RIGHT JOIN`, which is the
shipped SQL. What the file is really about survives the implementation: the
eligibility decision has to look at the side that is read with replicas, and a
shape it rejects has to answer correctly instead of failing on a lookup into
the rewritten tree.

The new test keeps that. A right side holding no eligible table - a table
function, `system.one`, and `RIGHT ANY` / `SEMI` / `ANTI` over a table
function - answers exactly as a run without parallel replicas does. Where the
right side is eligible and the left is not, plan-based distributes only the
right side's read and keeps the join on the initiator, which the counts
record; with both sides eligible the join is shipped.

The counts of the two arms whose left side reads `system.one` or `numbers(...)`
move from 0 to 1 once those sources become serializable
(#119862).

#121839 (comment)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
devcrafter added a commit that referenced this pull request Sep 30, 2026
The arms of `05293_pr_plan_based_right_join_ineligible_right_side` that count
what was shipped had `numbers(...)` and `system.one` as their unshippable left
side, and both become serializable in
#119862, which would move those
counts. A `Memory` read is unshippable in either implementation and stays so,
so the counting arms read one. Their shapes keep their coverage through the
row arms, which the change does not touch.

`parallel_replicas_allow_view_over_mergetree` and
`parallel_replicas_allow_materialized_views` are settings of the query-based
implementation with no plan-based equivalent, so the comment in
`05240_pr_plan_based_right_join_materialized_left` says that rather than
leaving it open.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Comment thread src/Storages/System/StorageSystemOne.h Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-parallel-replicas Parallel reading from replicas for query speed (not data replication consistency). pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants