Repository navigation
PR: use serialized query plan - part 2 - #97261
devcrafter wants to merge 67 commits into
Conversation
This reverts commit 8a38f22.
|
Workflow [PR], commit [d678744] Summary: ❌
AI ReviewSummaryThis PR continues the serialized-query-plan rollout for parallel replicas by transporting logical Findings❌ Blockers
Tests
Final VerdictChanges requested. The serialized-plan rollout still has blocking wire-format and remote-plan correctness issues, and the new LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 80/91 (87.91%) · Uncovered code |
…-serialize-query-plan-part2
- fixes 03926_pr_function_marshaling and others
ef195af to
93a8b89
Compare
Move `amd_binary, distributed plan, ParallelReplicas` functional tests from the general functional tests list to a new PR-specific job list `functional_tests_distributed_plan_pr_jobs`. These tests will now run only in pull requests, not on master branch, to reduce CI load while still validating the functionality in PRs. The `--distributed-plan` flag remains enabled for fast tests. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
The new `distributed plan, ParallelReplicas` job has the random-settings
generator pick `parallel_replicas_local_plan` from {0, 1}. Picking 0
takes the path that builds the remote plan first and trips not-yet-
implemented execution on the initiator. Force it to 1 in
`adjust_settings_for_autopr` whenever both `--distributed-plan` and
`--no-parallel-replicas` are set on the test runner.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…plan-part2 # Conflicts: # .github/workflows/pull_request.yml
`Config Workflow` check on CI flagged 5 YAMLs as outdated vs what `python3 -m praktika yaml` produces. Bring them in sync; only `pull_request.yml` actually differs from master (carries the new `distributed plan, ParallelReplicas` jobs), the rest just catch up master's drift. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
| SET enable_analyzer = 1; | ||
| SET serialize_query_plan = 1; | ||
| SET enable_parallel_replicas = 1, max_parallel_replicas = 2, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', parallel_replicas_for_non_replicated_merge_tree = 1; | ||
| SET parallel_replicas_local_plan=0; -- to ensure plan serialization/deserialization will happen |
There was a problem hiding this comment.
This setting does not exercise the serialized-plan path the test is meant to cover. With parallel_replicas_local_plan = 0, executeQueryWithParallelReplicas takes the remote-only branch, and that branch still constructs ReadFromParallelRemoteReplicasStep without a remote_query_plan. ReadFromParallelRemoteReplicasStep::createPipeForSingeReplica then sends the formatted AST at the original stage instead of QueryProcessingStage::QueryPlan, so the new ReadFromTableStep row_policy_filter serialization/deserialization can be broken while this test still passes. Please either run this case through the branch that passes a non-null remote_query_plan, or enable serialized-plan transport in the remote-only branch before relying on this as coverage.
| || typeid_cast<const ReadNothingStep *>(children_step) | ||
| || typeid_cast<const ReadFromPreparedSource *>(children_step); | ||
| || typeid_cast<const ReadFromPreparedSource *>(children_step) | ||
| || (read_from_table_step && read_from_table_step->isMergeTree()); |
There was a problem hiding this comment.
Allowing ReadFromTableStep here makes the serialized-plan path choose JoinStepLogicalLookup for join_algorithm = direct, but JoinStepLogicalLookup does not implement serialize or isSerializable and inherits the default non-serializable behavior. createRemotePlanForParallelReplicas immediately calls ensureSerialized, so a query that previously serialized as a normal join can now fail during planning once the right side is a MergeTree represented by ReadFromTableStep.
Please either keep this direct-join optimization disabled while select_query_options.build_logical_plan or serialize_query_plan is active, or add serialization support for JoinStepLogicalLookup together with a regression test for join_algorithm = direct plus serialize_query_plan = 1.
`createRemotePlanForParallelReplicas` re-ran the analyzer on the AST, which produced a `TableNode` for a materialized CTE without its subquery, crashing the planner with `LOGICAL_ERROR: CTE '...' does not have query tree, but was not planned yet`. Switching to the pre-analyzed query tree (mirroring `createLocalPlanForParallelReplicas`) preserves the shared `MaterializedCTE` so `hasPlanOrBuilt()` short-circuits the check. Regression test `04227_pr_materialized_cte_set_subquery` pins `parallel_replicas_local_plan = 1` because the remote builder otherwise pollutes `MaterializedCTE::plan` with a serialize-only step that the initiator later tries to execute. See TODO in the test. CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97261&sha=0537180f689f5e8f09d034af910c5b6800f9d739&name_0=PR&name_1=Stateless+tests+%28amd_binary%2C+distributed+plan%2C+ParallelReplicas%2C+s3+storage%2C+parallel%29 PR: ClickHouse#97261 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…plan-part2 # Conflicts: # .github/workflows/pull_request.yml # src/Processors/QueryPlan/ParallelReplicasLocalPlan.cpp
|
|
||
| auto new_context = Context::createCopy(context); | ||
|
|
||
| /// Build from the pre-analyzed query tree (not AST): re-analysis from AST loses |
There was a problem hiding this comment.
createRemotePlanForParallelReplicas now builds the remote logical plan, but below this point it still marks only the first ReadFromTableStep as useParallelReplicas. The local-plan path uses findReadingSteps so views with UNION can parallelize every underlying MergeTree read; the serialized remote plan leaves later ReadFromTableSteps unmarked, so resolveStorages will make those branches read normally on every remote replica. With parallel_replicas_allow_view_over_mergetree = 1 that can duplicate data or make the local and remote halves use different read modes. Please use the same multi-read traversal for logical ReadFromTableSteps and set useParallelReplicas on every eligible read.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 81/92 (88.04%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 3 line(s) · Uncovered code |
|
Dear @devcrafter, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message. |
Three resolutions: - `PlannerJoinTree`: keep master's refined `can_push_down_filter` condition (which also excludes remote storages and unsupported PREWHERE columns) while assigning to `table_expression_query_info.row_level_filter`, the destination this branch moved the filter to. Master's line still assigned to the local `row_level_filter`, which this branch removed. - `ci/workflows/pull_request.py`: master renamed `FUNCTIONAL_TESTS_PARALLEL_BLOCKING_JOB_NAMES` to `CORE_BLOCKING_JOB_NAMES`. The textual merge left one stale reference on this branch's `functional_tests_distributed_plan_pr_jobs` block, which made the workflow generator fail with a `NameError`. - Regenerate the praktika workflow YAML from the merged `ci/` sources.
| QueryPlanStepPtr ReadFromTableStep::clone() const | ||
| { | ||
| return std::make_unique<ReadFromTableStep>(getOutputHeader(), table_name, table_expression_modifiers, use_parallel_replicas); | ||
| return std::make_unique<ReadFromTableStep>( |
There was a problem hiding this comment.
row_policy_filter is a mutable FilterDAGInfo, but clone keeps reusing the same shared_ptr between plan copies. That becomes observable with the new logical direct-join path: tryMakeDirectJoinWithMergeTree now does lookup_plan = right_query_plan.clone() while the right side can still be a ReadFromTableStep, so the lookup plan and the main right-side plan end up sharing one filter DAG.
ReadFromMergeTree::clone already deep-copies query_info.row_level_filter because optimizations mutate these DAGs. Keeping the shared pointer here means those mutations can bleed across plan copies (or race if two clones are optimized/executed independently). Please deep-copy row_policy_filter in ReadFromTableStep::clone the same way ReadFromMergeTree::clone copies row-level filters.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units14 translation units recompiled, 91 s compile time in total, 14 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.09 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
The test exercises a very specific configuration (parallel replicas + `parallel_replicas_local_plan = 0` + `join_algorithm = direct` + `serialize_query_plan = 1`) to assert that serialization of `JoinStepLogicalLookup` raises `NOT_IMPLEMENTED`. Random settings in the flaky check can change the plan so the lookup step is not reached remotely, the query succeeds, and the test fails with "query succeeded but server error '48' was expected". CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97261&sha=0537180f689f5e8f09d034af910c5b6800f9d739&name_0=PR&name_1=Stateless+tests+%28amd_asan_ubsan%2C+flaky+check%29 PR: ClickHouse#97261 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
`createRemotePlanForParallelReplicas` re-ran the analyzer on the AST, which produced a `TableNode` for a materialized CTE without its subquery, crashing the planner with `LOGICAL_ERROR: CTE '...' does not have query tree, but was not planned yet`. Switching to the pre-analyzed query tree (mirroring `createLocalPlanForParallelReplicas`) preserves the shared `MaterializedCTE` so `hasPlanOrBuilt()` short-circuits the check. Regression test `04227_pr_materialized_cte_set_subquery` pins `parallel_replicas_local_plan = 1` because the remote builder otherwise pollutes `MaterializedCTE::plan` with a serialize-only step that the initiator later tries to execute. See TODO in the test. CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97261&sha=0537180f689f5e8f09d034af910c5b6800f9d739&name_0=PR&name_1=Stateless+tests+%28amd_binary%2C+distributed+plan%2C+ParallelReplicas%2C+s3+storage%2C+parallel%29 PR: ClickHouse#97261 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The test exercises a very specific configuration (parallel replicas + `parallel_replicas_local_plan = 0` + `join_algorithm = direct` + `serialize_query_plan = 1`) to assert that serialization of `JoinStepLogicalLookup` raises `NOT_IMPLEMENTED`. Random settings in the flaky check can change the plan so the lookup step is not reached remotely, the query succeeds, and the test fails with "query succeeded but server error '48' was expected". CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97261&sha=0537180f689f5e8f09d034af910c5b6800f9d739&name_0=PR&name_1=Stateless+tests+%28amd_asan_ubsan%2C+flaky+check%29 PR: ClickHouse#97261 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Dear @devcrafter, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message. |
Continuation of #88696
#100226 should be merged first
Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/97261]