Fix locking

This commit is contained in:
alesapin 2021-06-30 22:41:25 +03:00
parent 45edc8c861
commit 0193a9d087

View File

@ -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;