From 74327e7f4776d38f3d3498ec4471bac4569d49c5 Mon Sep 17 00:00:00 2001 From: nikitamikhaylov Date: Fri, 20 Mar 2020 16:18:26 +0400 Subject: [PATCH] remove settings from query --- dbms/programs/copier/ClusterCopier.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dbms/programs/copier/ClusterCopier.cpp b/dbms/programs/copier/ClusterCopier.cpp index c5266b3e43a..5f4480e6d5c 100644 --- a/dbms/programs/copier/ClusterCopier.cpp +++ b/dbms/programs/copier/ClusterCopier.cpp @@ -603,10 +603,16 @@ TaskStatus ClusterCopier::tryMoveAllPiecesToDestinationTable(const TaskTable & t original_table.second + "_piece_" + toString(current_piece_number)); + Settings settings_push = task_cluster->settings_push; + + /// It is important, ALTER ATTACH PARTITION must be done synchronously + /// And we will execute this ALTER query on each replica of a shard. + /// It is correct, because this query is idempotent. + settings_push.replication_alter_partitions_sync = 2; + query_alter_ast_string += " ALTER TABLE " + getQuotedTable(original_table) + " ATTACH PARTITION " + partition_name + - " FROM " + getQuotedTable(helping_table) + - " SETTINGS replication_alter_partitions_sync=2;"; + " FROM " + getQuotedTable(helping_table); LOG_DEBUG(log, "Executing ALTER query: " << query_alter_ast_string); @@ -616,7 +622,7 @@ TaskStatus ClusterCopier::tryMoveAllPiecesToDestinationTable(const TaskTable & t task_table.cluster_push, query_alter_ast_string, nullptr, - &task_cluster->settings_push, + &settings_push, PoolMode::GET_MANY, ClusterExecutionMode::ON_EACH_NODE);