Repository navigation
Parallel replicas support projection - #82807
Conversation
|
Workflow [PR], commit [11eb49c] Summary: ❌
|
c7220dd to
6f968f4
Compare
6f968f4 to
3442cfe
Compare
|
PTAL @alexey-milovidov |
128b892 to
4a0e891
Compare
4a0e891 to
7fff9e3
Compare
|
Stateless tests (amd_binary, ParallelReplicas, s3 storage, parallel) 02941_projections_external_aggregation |
|
PTAL @nickitat |
It means we should fix the test right? |
It has been fixed in this commit 99dceb4, where the issue was resolved and test case was added. |
|
Unfortunately, the flaky check failed in private, because some tests were too slow. You can check out the similar check in public: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=82807&sha=cc237effe453837180de766d261e33bc6c729007&name_0=PR&name_1=Stateless+tests+%28amd_asan%2C+flaky+check%29 (sort by duration). Let's make the new tests ( |
| && query_settings[Setting::parallel_replicas_local_plan] | ||
| && query_settings[Setting::parallel_replicas_support_projection]; | ||
|
|
||
| /// AggregationInOrder may cause local and remote replicas to use different CoordinationModes, which is currently unsupported. |
There was a problem hiding this comment.
Do you have test which demo the case?
There was a problem hiding this comment.
Yes, the following three test cases all cover and validate the scenario:
01710_projection_aggregation_in_order
01710_projections_optimize_aggregation_in_order
01710_projections_partial_optimize_aggregation_in_order
Co-authored-by: Igor Nikonov <[email protected]>
|
Stateless tests (amd_binary, old analyzer, s3 storage, DatabaseReplicated, parallel) |
|
…rder is enabled `canUseProjectionForReadingStep` rejected every projection of a parallel replicas read when `optimize_aggregation_in_order` or `force_aggregation_in_order` was set (added by ClickHouse#82807). It keyed on the setting, so aggregate and normal projections, `_minmax_count_projection` and the exact count were lost for every parallel replicas query of a user who keeps the setting on, and the whole table was read. The check stood in for one asymmetry. With a full aggregate projection the aggregation becomes `only_merge`, and `optimizeAggregationInOrder` may then aggregate in order over the projection read, which is sorted by the projection's keys. The local plan's root aggregation then uses memory-bound merging, so `enableMemoryBoundMerging` enforces aggregation in order on the followers. With `force_aggregation_in_order` the followers' aggregation has a sort description, `AggregatingStep::canUseProjection()` is false there, and they read the base table on the same coordinator stream as the initiator's projection read: a different coordination mode, or parts the initiator never announced. Without the setting check and without the skip below, a `GROUP BY k` over a 1M-group projection of a table `ORDER BY v` fails with `LOGICAL_ERROR` "Got read request from replica N for unknown stream" every time. So instead of rejecting projections, do not aggregate in order over an aggregate projection read when reading with parallel replicas, like the other parallel replicas skips in `optimizeReadInOrder.cpp` (JOIN, LIMIT BY, UNION). The initiator and the followers then build the plan they build with `optimize_aggregation_in_order = 0`; `EXPLAIN PLAN` and `EXPLAIN PIPELINE` are identical. The `!support_projection` half of the check is unchanged. Closes ClickHouse#123061. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ections with parallel replicas The aggregate and normal projection optimizers decided whether a coordinated read is the initiator's own share (and so must return what a projection or a prepared source answers) from `QueryPlanOptimizationSettings::is_parallel_replicas_initiator_with_projection_support`, computed once from the context the whole plan is optimized with. The initiator's local plan is optimized with a copy of the OUTER settings, so when parallel replicas are enabled only in a subquery's SETTINGS the flag is false there: the initiator emitted a NullSource for the `_minmax_count_projection`, `_statistics_projection` and `_exact_count_projection` blocks and skipped the projection read beside parts without the projection, while the followers do the same by design. `min`/`max`/`count` came back as 0 (since ClickHouse#82807), `sum`/`avg` as 0/nan (since ClickHouse#123950), and projection-answered rows were dropped. Use `ReadFromMergeTree::isParallelReplicasLocalPlanForInitiator()`, which reads the read's own context and is already used by the same code for the empty-ranges announcement (and its follower twin for the follower failpoints), and remove the plan-wide field. For a query whose outer and subquery contexts agree the answer is unchanged. 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 to CHANGELOG.md):
Reading from projections is implemented for parallel replicas. A new setting
parallel_replicas_support_projectionhas been added to control whether projection support is enabled. To simplify the implementation, support for projection is only enabled whenparallel_replicas_local_planis active.This PR closes #82659.
Changes Overview
Coordinator + ReadPool Changes
part_info.part_info + projection_name.Query Plan Changes for Projection Optimization
Documentation entry for user-facing changes