Repository navigation
Evaluate followers' read-time skip indexes over the ranges analyzed on the initiator - #126954
Conversation
… on the initiator With `parallel_replicas_index_analysis_only_on_coordinator`, a parallel replicas follower skips its own index analysis and keeps every mark of every part. With `use_skip_indexes_on_data_read`, that whole-part input made `MergeTreeSkipIndexReader::read` evaluate the skip indexes over whole parts. #126145 narrowed the input by running the primary key analysis again on each follower. The coordinator already holds the analyzed ranges: the snapshot announcement of the initiator registers them, and `InitialAllRangesAnnouncementResponse` carries them back for in-order reads. A `Default` mode follower that skipped analysis and has a read-time skip-index reader now asks for that response with a new `wants_analyzed_ranges` field of `InitialAllRangesAnnouncement` (parallel replicas protocol 9), and evaluates the skip indexes over those ranges. In-order followers use the response they already receive. This replaces the primary key step of #126145, so followers do not repeat the analysis, and their input matches the initiator's exactly, partition minmax pruning included. Other `Default` mode reads still neither send nor wait for the response, and the coordinator no longer copies the registered parts into a response that is not sent. With an initiator older than protocol 9 the follower does not ask and evaluates whole parts, as before #126145. The test now runs with the initiator's local replica, the default: without a local plan no replica analyzes, so the coordinator has no analyzed ranges to hand out. Issue reproduction (200 parts, bloom filter, 3 local replicas, caches dropped before each query), `ReadCompressedBytes` per follower: no fix 16-105 MiB (1073 selected marks), #126145 0.25-3.3 MiB, this change 0.17-1.9 MiB (20 selected marks in both). Related: #124628 Related: #126145 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test passed vacuously when the initiator's local replica took all the work before the followers announced. `slowdown_parallel_replicas_local_plan_read` delays every request of the local replica, so the followers get their segments, and the check again requires a finished follower in each mode. The failpoint is server-wide, hence `no-parallel`. Local runs: 30/30 with randomized settings, 30/30 with the server under CPU load (load average 40), and 10/10 failures with the analyzed ranges not applied on followers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
Workflow [PR], commit [0aedd94] Summary: ✅
|
The revert of #126145 is now a separate PR, #126955, which this one is stacked on. This branch already removed the same code, so its tree is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Away from `pk_condition_useful`, which 26.10 does not have, so the change cherry-picks onto 26.10 without conflicts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The `failpoint_tests_are_isolated` style check requires it: a fail point is server-global, so such a test runs alone, and tests that run alone are kept out of the fast test. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=126954&sha=1737e4d26b4cf146e94dda769b195361b1f8cde3&name_0=PR&name_1=Style%20check #126954 Co-Authored-By: Claude Opus 5.5 <[email protected]>
An in-order read on the initiator can split one part between streams, and a local-plan follower creates one pool per stream over a shared `MergeTreeIndexBuildContext`. Each stream's announcement response carries only that stream's ranges, so replacing the part's read-time skip-index input per response left it with the last stream's ranges, and the rows of the other streams were dropped (25 of 100 rows in the new test, ascending and descending). `addAnalyzedReadRanges` now replaces the whole-part ranges once and extends them with every later response. 05401 no longer requires a finished follower in each mode: a follower that got no work before the local replica finished is cancelled, which made the flaky check fail. Flaky check: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=126954&sha=15bbab5edc47d278e052f064e224b14512a20601&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20flaky%20check%29 Review: #126954 (comment) PR: #126954 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes38 object files changed (+32.96 KiB total), 0 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units285 translation units recompiled, 2668 s compile time in total, 285 of them have a recent master baseline. |
The flag is set on a follower that skipped its own index analysis and has a read-time skip-index reader (`use_skip_indexes_on_data_read`, the join runtime filter or the top-K primary key pruning); the comments now say so. In-order announcements carry its real value instead of `false`: ordered modes always get the response, so nothing changes on the wire. `addAnalyzedReadRanges` appends with a range `insert`. PR: #126954 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Plan-based parallel replicas follow the top-level query's settings, so with the `SETTINGS` on the subquery the plan-based query was a plain local read. With them on the outer query, `query_plan_remove_redundant_sorting` drops the inner `ORDER BY` in the plan-based case, so it is disabled there to keep the read in order. Now all three queries run with two followers and fail without the stream union. #126954 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
devcrafter
left a comment
There was a problem hiding this comment.
I'd also check behavior with disabled use_skip_indexes_on_data_read in the tests
…d` disabled Without the read-time skip-index evaluation a follower requests no analyzed ranges and reads only the marks the coordinator assigns. It still accounts the whole parts it planned as `SelectedMarks`, so 05401 compares the rows read for these queries. #126954 (review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…inator-ranges # Conflicts: # src/Processors/QueryPlan/ReadFromMergeTree.cpp
…analysis_skipped` Master added the same flag, set at the same place, with the merge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The previous commit staged the stale submodule checkouts with `git commit -a`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…x-coordinator-ranges
…x-coordinator-ranges
…rallel replicas followers" This reverts ClickHouse#126145 (merge commit 1daec15): source changes and the test `05401_parallel_replicas_follower_skip_index_primary_key`. The declaration of `key_condition_not_applied` in `ReadFromMergeTree.h` was removed by hand, because `pk_condition_useful` was added next to it afterwards. A follower will take the ranges analyzed on the initiator from the coordinator instead of repeating the primary key analysis: ClickHouse#126954 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l plan With `parallel_replicas_index_analysis_only_on_coordinator`, a follower skipped its own index analysis whenever `parallel_replicas_local_plan` was set, relying on the analysis of the initiator's local plan. Inside a `Distributed` subquery and with `parallel_replicas_prefer_local_replica = 0` there is no local plan, so nobody analyzed and every replica read whole parts: 1280000 rows instead of 384 for a primary key range of 3 granules through `Distributed`. The check now uses `ClusterProxy::canUseLocalPlanForParallelReplicas`, which covers both. Review: ClickHouse#126954 (comment) Related: ClickHouse#126954 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):
With parallel replicas and
use_skip_indexes_on_data_read, follower replicas now evaluate skip indexes over the mark ranges analyzed on the initiator, received from the coordinator, instead of repeating the primary key analysis.Related: #124628
Related: #126145
Related: #126955
Stacked on #126955, which reverts #126145; this PR does not contain the revert, so it can be backported to 26.10, which never had #126145.
With
parallel_replicas_index_analysis_only_on_coordinator(the default), a parallel replicas follower skips its own index analysis and keeps every mark of every part. Withuse_skip_indexes_on_data_read(also the default), that whole-part input madeMergeTreeSkipIndexReader::readevaluate the skip indexes over whole parts. #126145 fixed it by running the primary key analysis again on each follower, lazily, per part.The coordinator already holds the ranges the initiator analyzed: the initiator's announcement registers them, and
InitialAllRangesAnnouncementResponsecarries them back to in-order followers. InDefaultmode that response was neither sent nor awaited. This change lets a follower ask for it, and evaluates the skip indexes over those ranges instead of repeating the analysis:InitialAllRangesAnnouncementgets a trailingwants_analyzed_rangesfield (parallel replicas protocol 8 -> 9). A follower sets it only when it skipped its own analysis and has a read-time skip-index reader. The initiator replies inDefaultmode only when the field is set, and the follower waits only when it set it and the initiator speaks version 9. Every otherDefaultmode read keeps today's behaviour: no response, no round trip. The coordinator also stops copying the registered parts into a response that is not sent.MergeTreeIndexBuildContext::addAnalyzedReadRangesreplaces a part's skip-index input with the analyzed ranges before the first task. In-order followers do the same with the response they already receive. The initiator can split one part between in-order streams, and each stream's response carries only its own ranges, so the input of a part is the union over all of a follower's streams.The protocol spec in
docs/resources/develop-contribute/native-protocol/protocol.mdxis updated.Results
Issue #124628 reproduction (200 parts, bloom filter on
mapValues, 3 local replicas, caches dropped before each query, 3 runs),ReadCompressedBytesper follower:Workflow [PR]
Sync PR [sync-upstream/pr/126954]
Version info
26.11.1.546-master(included in26.11and later)26.10.2.80