Repository navigation
Add parallel_replicas_prefer_local_replica setting - #100139
Conversation
When disabled, replicas for parallel reading are selected purely by the load balancing algorithm without forcing the local replica into the set. This allows queries with `max_parallel_replicas = 1` to be directed to another host, which can improve cache locality when many short queries are distributed across a cluster. Closes #79335 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Workflow [PR], commit [d8994ea] Summary: ✅ AI ReviewSummaryThis PR adds the ClickHouse Rules
Final Verdict
|
| -- With prefer_local_replica = 0 and max_parallel_replicas = 1, the query should | ||
| -- use the parallel replicas path (i.e., the query is sent to a replica selected | ||
| -- by load balancing, not necessarily the local one). | ||
| SELECT count() |
There was a problem hiding this comment.
The new test does not actually verify the behavior this PR introduces.
This query only asserts count() = 1000, which is identical whether parallel_replicas_prefer_local_replica = 0 is respected or ignored. So CI can stay green even if local-replica preference is still enforced for max_parallel_replicas = 1.
Please add an assertion that observes replica selection/path directly (for example via system.query_log / ProfileEvents / trace-level evidence), and keep the existing result check as a secondary correctness assertion.
…o_local_preference
Move `parallel_replicas_prefer_local_replica` to version 26.4 in `SettingsChangesHistory.cpp` to fix the `02995_new_settings_history` test. Strengthen the stateless test to verify actual parallel replica usage via `system.query_log` ProfileEvents, not just query result correctness. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100139&sha=latest&name_0=PR Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…tion The trivial count optimization (`optimize_trivial_count_query`) intercepts bare `SELECT count()` and returns the answer from metadata, completely bypassing the parallel replicas code path. This caused `ParallelReplicasUsedCount` to be 0 in all test cases. Adding a second aggregate (`min(key)`) prevents the optimization from triggering, ensuring the query goes through the parallel replicas path. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
When `parallel_replicas_prefer_local_replica` is disabled, the INSERT SELECT code path in `InterpreterInsertQuery` was still forcing local pipeline participation, creating inconsistent behavior with regular SELECT queries. Skip the local pipeline when the setting is disabled, and add a test case for INSERT SELECT with parallel replicas. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…o_local_preference
…o_local_preference
…nt_proj` interference The `minmax_count_proj` projection optimization on the parallel replicas follower interferes with the coordinator-based reading path, causing 0 rows to be returned. Switch from `min(key)` to `sum(key)` (which cannot be satisfied by projections) and add `optimize_use_projections = 0` for safety. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…o_local_preference
…mized settings interference The test was failing because randomized CI settings could set `automatic_parallel_replicas_mode = 2`, which causes `canUseTaskBasedParallelReplicas` to return false, preventing the parallel replicas path from being taken regardless of the `parallel_replicas_prefer_local_replica` setting under test. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…o_local_preference
…yzer CI In CI configurations where `allow_experimental_analyzer` = 0, the default `parallel_replicas_only_with_analyzer` = 1 causes `canUseTaskBasedParallelReplicas` to return false, making `ParallelReplicasUsedCount` checks produce false negatives. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…o_local_preference
…o_local_preference
`InterpreterInsertQuery::buildInsertSelectPipelineParallelReplicas` has a hard `allow_experimental_analyzer` gate independent of `parallel_replicas_only_with_analyzer`, so in analyzer-disabled CI runs the assertion `ProfileEvents['ParallelReplicasUsedCount'] > 0` for the INSERT SELECT case could fail for reasons unrelated to this PR. Force `allow_experimental_analyzer = 1` in the INSERT SELECT `SETTINGS` to keep the assertion deterministic. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…o_local_preference
…o_local_preference
…o_local_preference
…r merge The 26.4 branch already diverged; place the new setting in the currently in-progress 26.5 version block.
…s_no_local_preference
LLVM Coverage Report
Changed lines: 100.00% (30/30) · Uncovered code |
Add
parallel_replicas_prefer_local_replicasetting that, when disabled, allows replicas for parallel reading to be selected purely by the load balancing algorithm without forcing the local replica into the set. This enables queries withmax_parallel_replicas = 1to be directed to another host, which can improve cache locality when many short queries are distributed across a cluster.Closes #79335
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add
parallel_replicas_prefer_local_replicasetting: when disabled, parallel replicas are selected purely by the load balancing algorithm, allowing evenmax_parallel_replicas = 1queries to be directed to another host.Documentation entry for user-facing changes
New setting
parallel_replicas_prefer_local_replica(Bool, defaulttrue):load_balancingalgorithm. This allows queries withmax_parallel_replicas = 1to be directed to another host, which can improve cache locality when many different short queries are distributed across a cluster.The setting is documented in the auto-generated session settings reference via its
DECLAREblock insrc/Core/Settings.cpp, which populatesdocs/en/operations/settings/settings.md.Example:
Version info
26.5.1.92