diff --git a/src/Storages/MergeTree/DataPartsExchange.cpp b/src/Storages/MergeTree/DataPartsExchange.cpp index 166314ab7c2..dd36a45f829 100644 --- a/src/Storages/MergeTree/DataPartsExchange.cpp +++ b/src/Storages/MergeTree/DataPartsExchange.cpp @@ -850,7 +850,7 @@ MergeTreeData::MutableDataPartPtr Fetcher::downloadPartToDiskRemoteMeta( new_data_part->modification_time = time(nullptr); new_data_part->loadColumnsChecksumsIndexes(true, false); - data.lockSharedData(*new_data_part, /* replace_existing_lock = */ true); + data.lockSharedData(*new_data_part, /* replace_existing_lock = */ true, {}); LOG_DEBUG(log, "Download of part {} unique id {} metadata onto disk {} finished.", part_name, part_id, disk->getName()); diff --git a/src/Storages/MergeTree/ReplicatedMergeTreeSink.cpp b/src/Storages/MergeTree/ReplicatedMergeTreeSink.cpp index 96f829ac96c..c96c180b83d 100644 --- a/src/Storages/MergeTree/ReplicatedMergeTreeSink.cpp +++ b/src/Storages/MergeTree/ReplicatedMergeTreeSink.cpp @@ -497,7 +497,7 @@ void ReplicatedMergeTreeSink::commitPart( part->name); } - storage.lockSharedData(*part, false); + storage.lockSharedData(*part, false, {}); Coordination::Responses responses; Coordination::Error multi_code = zookeeper->tryMultiNoThrow(ops, responses); /// 1 RTT diff --git a/src/Storages/StorageReplicatedMergeTree.h b/src/Storages/StorageReplicatedMergeTree.h index 845182445a5..ff389e6f3a3 100644 --- a/src/Storages/StorageReplicatedMergeTree.h +++ b/src/Storages/StorageReplicatedMergeTree.h @@ -236,7 +236,7 @@ public: bool executeFetchShared(const String & source_replica, const String & new_part_name, const DiskPtr & disk, const String & path); /// Lock part in zookeeper for use shared data in several nodes - void lockSharedData(const IMergeTreeDataPart & part, bool replace_existing_lock, std::optional hardlinked_files = {}) const override; + void lockSharedData(const IMergeTreeDataPart & part, bool replace_existing_lock, std::optional hardlinked_files) const override; void lockSharedDataTemporary(const String & part_name, const String & part_id, const DiskPtr & disk) const; diff --git a/tests/queries/0_stateless/02271_replace_partition_many_tables.reference b/tests/queries/0_stateless/02271_replace_partition_many_tables.reference new file mode 100644 index 00000000000..627e1097cda --- /dev/null +++ b/tests/queries/0_stateless/02271_replace_partition_many_tables.reference @@ -0,0 +1,5 @@ +1 +1 +1 +1 +1 diff --git a/tests/queries/0_stateless/02271_replace_partition_many_tables.sql b/tests/queries/0_stateless/02271_replace_partition_many_tables.sql new file mode 100644 index 00000000000..a31a2bee58a --- /dev/null +++ b/tests/queries/0_stateless/02271_replace_partition_many_tables.sql @@ -0,0 +1,82 @@ +DROP TABLE IF EXISTS replace_partition_source; +DROP TABLE IF EXISTS replace_partition_dest1; +DROP TABLE IF EXISTS replace_partition_dest1_2; +DROP TABLE IF EXISTS replace_partition_dest2; +DROP TABLE IF EXISTS replace_partition_dest2_2; + +CREATE TABLE replace_partition_source +( + key UInt64 +) +ENGINE = ReplicatedMergeTree('/test/02271_replace_partition_many/{database}/source', '1') +PARTITION BY key +ORDER BY tuple(); + +INSERT INTO replace_partition_source VALUES (1); + +CREATE TABLE replace_partition_dest1 +( + key UInt64 +) +ENGINE = ReplicatedMergeTree('/test/02271_replace_partition_many/{database}/dest1', '1') +PARTITION BY key +ORDER BY tuple(); + +CREATE TABLE replace_partition_dest1_2 +( + key UInt64 +) +ENGINE = ReplicatedMergeTree('/test/02271_replace_partition_many/{database}/dest1', '2') +PARTITION BY key +ORDER BY tuple(); + + +CREATE TABLE replace_partition_dest2 +( + key UInt64 +) +ENGINE = ReplicatedMergeTree('/test/02271_replace_partition_many/{database}/dest2', '1') +PARTITION BY key +ORDER BY tuple(); + +CREATE TABLE replace_partition_dest2_2 +( + key UInt64 +) +ENGINE = ReplicatedMergeTree('/test/02271_replace_partition_many/{database}/dest2', '2') +PARTITION BY key +ORDER BY tuple(); + + +ALTER TABLE replace_partition_dest1 REPLACE PARTITION 1 FROM replace_partition_source; +ALTER TABLE replace_partition_dest2 REPLACE PARTITION 1 FROM replace_partition_source; + +OPTIMIZE TABLE replace_partition_source FINAL; + +SELECT sleep(3) FORMAT Null; +SELECT sleep(3) FORMAT Null; +SELECT sleep(3) FORMAT Null; +SELECT sleep(3) FORMAT Null; +SELECT sleep(3) FORMAT Null; + +OPTIMIZE TABLE replace_partition_dest1_2 FINAL; +OPTIMIZE TABLE replace_partition_dest2_2 FINAL; + +SELECT sleep(3) FORMAT Null; +SELECT sleep(3) FORMAT Null; +SELECT sleep(3) FORMAT Null; +SELECT sleep(3) FORMAT Null; +SELECT sleep(3) FORMAT Null; + +SELECT * FROM replace_partition_source; +SELECT * FROM replace_partition_dest1; +SELECT * FROM replace_partition_dest2; +SELECT * FROM replace_partition_dest1_2; +SELECT * FROM replace_partition_dest2_2; + + +--DROP TABLE IF EXISTS replace_partition_source; +--DROP TABLE IF EXISTS replace_partition_dest1; +--DROP TABLE IF EXISTS replace_partition_dest1_2; +--DROP TABLE IF EXISTS replace_partition_dest2; +--DROP TABLE IF EXISTS replace_partition_dest2_2;