Merge pull request #50193 from ClickHouse/fix_for_replicate_delete

Don't replicate delete through DDL worker if there is just 1 shard
This commit is contained in:
Alexander Gololobov 2023-05-24 22:45:00 +02:00 committed by GitHub
commit 8996fcb090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1455,7 +1455,16 @@ bool DatabaseReplicated::shouldReplicateQuery(const ContextPtr & query_context,
} }
if (query_ptr->as<const ASTDeleteQuery>() != nullptr) if (query_ptr->as<const ASTDeleteQuery>() != nullptr)
return !is_keeper_map_table(query_ptr); {
if (is_keeper_map_table(query_ptr))
return false;
/// If there is only 1 shard then there is no need to replicate DELETE query.
auto current_cluster = tryGetCluster();
return
!current_cluster || /// Couldn't get the cluster, so we don't know how many shards there are.
current_cluster->getShardsInfo().size() > 1;
}
return true; return true;
} }