Repository navigation
Automatically adjust settings when make_distributed_plan is enabled - #112463
Conversation
When `make_distributed_plan = 1`, several features are not supported by distributed query plans yet. Instead of failing during planning or execution, automatically adjust the settings that control them: - `enable_parallel_replicas = 0` and `automatic_parallel_replicas_mode = 0` (previously the combination was rejected with `SUPPORT_IS_DISABLED`) - `rewrite_in_to_join = 1`, which makes `IN (subquery)` distributable (only when `allow_experimental_correlated_subqueries` is enabled) - `correlated_subqueries_use_in_memory_buffer = 0` (its steps are not serializable for remote execution) - `use_skip_indexes_on_data_read = 0` - `compile_expressions = 0` - `query_plan_direct_read_from_text_index = 0`, which fixes `NOT_FOUND_COLUMN_IN_BLOCK` on full-text search queries The switch is applied on the initiator in `InterpreterSelectQueryAnalyzer::buildContext` and re-applied on worker task contexts in `doExecuteTask`, because task contexts are rebuilt from the initiator's user-level settings changes and do not see the initiator-side overrides. Closes: #109476 Closes: #109329 Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [48b17e1] Summary: ✅
AI ReviewSummaryThis PR makes Findings❌ Blockers
Final Verdict❌ Changes requested. The PR’s core contract is still violated by |
| @@ -8469,6 +8469,14 @@ Method to compress `.metadata.json` file. | |||
| )", EXPERIMENTAL) \ | |||
There was a problem hiding this comment.
The server-side help string is updated here, but the published docs are still stale: docs/reference/settings/session-settings/other.mdx#make_distributed_plan currently only says “Make distributed query plan.” After this PR, enabling make_distributed_plan also silently flips several other session settings (enable_parallel_replicas, automatic_parallel_replicas_mode, rewrite_in_to_join, compile_expressions, etc.), so users need that behavior documented in the settings page too, not only in the in-server description.
A per-SELECT SETTINGS clause is re-applied onto the query's own context during query tree building, which restored the unsupported settings and made the CI settings randomizer reach the parallel replicas rejection through a plan with a local parallel replica read. Move the auto-switch from InterpreterSelectQueryAnalyzer::buildContext and doExecuteTask into adjustSettingsForMakeDistributedPlan, applied in Context::applySettingsChangesWithLock next to applySettingsQuirks. Every context that drives analysis, planning or task execution goes through it: the initiator query context, per-SELECT settings re-application, session-level SET, EXPLAIN's inner settings, and the worker's context rebuilt from the initiator's settings changes. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112463&sha=1c1b45372a46c1d07830635edff9a9ca0742eac4&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29 PR: #112463 Co-Authored-By: Claude Fable 5 <[email protected]>
| for (const SettingChange & change : changes) | ||
| applySettingChangeWithLock(change, lock); | ||
| applySettingsQuirks(*settings); | ||
| adjustSettingsForMakeDistributedPlan(*settings); |
There was a problem hiding this comment.
adjustSettingsForMakeDistributedPlan only runs after applySettingsChanges, but SQL ... = DEFAULT takes a different path: InterpreterSetQuery::executeForCurrentContext applies ast.changes first and then calls resetSettingsToDefaultValue(ast.default_settings), and Context::resetSettingsToDefaultValue just does settings->setDefaultValue(name) without re-running this hook. That means SELECT ... SETTINGS query_plan_direct_read_from_text_index = DEFAULT (or SET compile_expressions = DEFAULT, etc.) under make_distributed_plan = 1 restores the default-true settings that this PR is trying to force off, so the old unsupported distributed-plan paths are still reachable through DEFAULT.
This needs the same post-processing after default resets too, or a shared helper that all settings mutations (applySettingsChanges, setSetting, default resets) go through. A focused stateless regression on one ... = DEFAULT case would keep this covered.
The correlated scalar aggregate over 100k rows ran for up to 645 seconds under TSan with randomized max_threads = 1 and exceeded the 180-second limit of the flaky check (also slow with make_distributed_plan = 0, so it is the data volume, not the settings switch). 10k rows exercise the same in-memory buffer path. CI reports: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112463&sha=e98490a1352694e836bd761c2a23669edd94de20&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20flaky%20check%29 https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112463&sha=e98490a1352694e836bd761c2a23669edd94de20&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20flaky%20check%29 PR: #112463 Co-Authored-By: Claude Fable 5 <[email protected]>
…query test The randomizer disables it in 5% of runs; the decorrelated correlation condition then stays a filter above a CROSS JOIN and the scalar aggregate queries become quadratic (10k x 10k = 100M join rows, JoinResultRowCount confirmed in query_log), running for 140-235 seconds under TSan with make_distributed_plan both 0 and 1 and exceeding the 180-second limit of the flaky check. 03734_correlated_subqueries_reorder pins the same setting for the same reason. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112463&sha=eeec1ed63d302174d68deb799222c937410a1ba9&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20flaky%20check%29 PR: #112463 Co-Authored-By: Claude Fable 5 <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 53/53 (100.00%) · Uncovered code |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Now
make_distributed_plan=1will disable not yet supported features. Fixes #109476.Version info
26.8.1.506(included in26.8and later)