Skip to content

Commit a163571

Browse files
Backport #69264 to 24.8: Fix: Not-ready Set with parallel replicas
1 parent eb0a0ba commit a163571

File tree

8 files changed

+28
-4
lines changed

8 files changed

+28
-4
lines changed

src/Planner/Planner.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ FiltersForTableExpressionMap collectFiltersForAnalysis(const QueryTreeNodePtr &
198198
auto & result_query_plan = planner.getQueryPlan();
199199

200200
auto optimization_settings = QueryPlanOptimizationSettings::fromContext(query_context);
201+
optimization_settings.build_sets = false; // no need to build sets to collect filters
201202
result_query_plan.optimize(optimization_settings);
202203

203204
FiltersForTableExpressionMap res;

src/Processors/QueryPlan/Optimizations/Optimizations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void optimizeTreeFirstPass(const QueryPlanOptimizationSettings & settings, Query
1616
void optimizeTreeSecondPass(const QueryPlanOptimizationSettings & optimization_settings, QueryPlan::Node & root, QueryPlan::Nodes & nodes);
1717
/// Third pass is used to apply filters such as key conditions and skip indexes to the storages that support them.
1818
/// After that it add CreateSetsStep for the subqueries that has not be used in the filters.
19-
void optimizeTreeThirdPass(QueryPlan & plan, QueryPlan::Node & root, QueryPlan::Nodes & nodes);
19+
void addStepsToBuildSets(QueryPlan & plan, QueryPlan::Node & root, QueryPlan::Nodes & nodes);
2020

2121
/// Optimization (first pass) is a function applied to QueryPlan::Node.
2222
/// It can read and update subtree of specified node.

src/Processors/QueryPlan/Optimizations/QueryPlanOptimizationSettings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ struct QueryPlanOptimizationSettings
7575
String force_projection_name;
7676
bool optimize_use_implicit_projections = false;
7777

78+
bool build_sets = true;
79+
7880
static QueryPlanOptimizationSettings fromSettings(const Settings & from);
7981
static QueryPlanOptimizationSettings fromContext(ContextPtr from);
8082
};

src/Processors/QueryPlan/Optimizations/optimizeTree.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void optimizeTreeSecondPass(const QueryPlanOptimizationSettings & optimization_s
216216
optimization_settings.force_projection_name);
217217
}
218218

219-
void optimizeTreeThirdPass(QueryPlan & plan, QueryPlan::Node & root, QueryPlan::Nodes & nodes)
219+
void addStepsToBuildSets(QueryPlan & plan, QueryPlan::Node & root, QueryPlan::Nodes & nodes)
220220
{
221221
Stack stack;
222222
stack.push_back({.node = &root});

src/Processors/QueryPlan/QueryPlan.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,8 @@ void QueryPlan::optimize(const QueryPlanOptimizationSettings & optimization_sett
504504

505505
QueryPlanOptimizations::optimizeTreeFirstPass(optimization_settings, *root, nodes);
506506
QueryPlanOptimizations::optimizeTreeSecondPass(optimization_settings, *root, nodes);
507-
QueryPlanOptimizations::optimizeTreeThirdPass(*this, *root, nodes);
507+
if (optimization_settings.build_sets)
508+
QueryPlanOptimizations::addStepsToBuildSets(*this, *root, nodes);
508509

509510
updateDataStreams(*root);
510511
}

tests/ci/ci_config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,9 @@ class CI:
407407
num_batches=6,
408408
),
409409
JobNames.INTEGRATION_TEST_TSAN: CommonJobConfigs.INTEGRATION_TEST.with_properties(
410-
required_builds=[BuildNames.PACKAGE_TSAN], num_batches=6
410+
required_builds=[BuildNames.PACKAGE_TSAN],
411+
num_batches=6,
412+
timeout=9000, # the job timed out with default value (7200)
411413
),
412414
JobNames.INTEGRATION_TEST_ARM: CommonJobConfigs.INTEGRATION_TEST.with_properties(
413415
required_builds=[BuildNames.PACKAGE_AARCH64],

tests/queries/0_stateless/03232_pr_not_ready_set.reference

Whitespace-only changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
SELECT
2+
is_initial_query,
3+
count() AS c,
4+
replaceRegexpAll(query, '_data_(\\d+)_(\\d+)', '_data_') AS query
5+
FROM system.query_log
6+
WHERE (event_date >= yesterday()) AND (type = 'QueryFinish') AND (ignore(54, 0, ignore('QueryFinish', 11, toLowCardinality(toLowCardinality(11)), 11, 11, 11), 'QueryFinish', materialize(11), toUInt128(11)) IN (
7+
SELECT query_id
8+
FROM system.query_log
9+
WHERE (current_database = currentDatabase()) AND (event_date >= yesterday()) AND (type = 'QueryFinish') AND (query LIKE '-- Parallel inner query alone%')
10+
))
11+
GROUP BY
12+
is_initial_query,
13+
query
14+
ORDER BY
15+
is_initial_query ASC,
16+
c ASC,
17+
query ASC
18+
SETTINGS allow_experimental_parallel_reading_from_replicas=1, max_parallel_replicas=3, cluster_for_parallel_replicas='test_cluster_one_shard_three_replicas_localhost', parallel_replicas_for_non_replicated_merge_tree=1, parallel_replicas_min_number_of_rows_per_replica=10;

0 commit comments

Comments
 (0)