From 0193a9d08775789f00d0d6c34495faa48aee7e24 Mon Sep 17 00:00:00 2001 From: alesapin Date: Wed, 30 Jun 2021 22:41:25 +0300 Subject: [PATCH] Fix locking --- src/Storages/StorageReplicatedMergeTree.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Storages/StorageReplicatedMergeTree.cpp b/src/Storages/StorageReplicatedMergeTree.cpp index a04ec5c6532..ee4abb38c10 100644 --- a/src/Storages/StorageReplicatedMergeTree.cpp +++ b/src/Storages/StorageReplicatedMergeTree.cpp @@ -7428,14 +7428,18 @@ bool StorageReplicatedMergeTree::createEmptyPartInsteadOfLost(zkutil::ZooKeeperP new_data_part->setColumns(columns); new_data_part->rows_count = block.rows(); - auto parts_in_partition = getDataPartsPartitionRange(new_part_info.partition_id); - if (parts_in_partition.empty()) { - LOG_WARNING(log, "Empty part {} is not created instead of lost part because there are no parts in partition {} (it's empty), resolve this manually using DROP PARTITION.", lost_part_name, new_part_info.partition_id); - return false; + auto lock = lockParts(); + auto parts_in_partition = getDataPartsPartitionRange(new_part_info.partition_id); + if (parts_in_partition.empty()) + { + LOG_WARNING(log, "Empty part {} is not created instead of lost part because there are no parts in partition {} (it's empty), resolve this manually using DROP PARTITION.", lost_part_name, new_part_info.partition_id); + return false; + } + + new_data_part->partition = (*parts_in_partition.begin())->partition; } - new_data_part->partition = (*parts_in_partition.begin())->partition; new_data_part->minmax_idx = std::move(minmax_idx); new_data_part->is_temp = true;