fix possible dataraces in ReplicatedMergeTree

This commit is contained in:
Nikita Mikhaylov 2019-10-02 12:59:44 +03:00 committed by GitHub
parent 0e9cad2276
commit 13e2034084
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5106,19 +5106,20 @@ void StorageReplicatedMergeTree::movePartitionToTable(const StoragePtr & dest_ta
Transaction transaction(*dest_table_storage);
{
auto data_parts_lock = lockParts();
auto dest_data_parts_lock = dest_table_storage->lockParts();
for (MutableDataPartPtr & part : dst_parts)
dest_table_storage->renameTempPartAndReplace(part, nullptr, &transaction, data_parts_lock);
dest_table_storage->renameTempPartAndReplace(part, nullptr, &transaction, dest_data_parts_lock);
}
op_results = zookeeper->multi(ops);
{
auto data_parts_lock = lockParts();
transaction.commit(&data_parts_lock);
parts_to_remove = removePartsInRangeFromWorkingSet(drop_range, true, false, data_parts_lock);
auto src_data_parts_lock = lockParts();
auto dest_data_parts_lock = dest_table_storage->lockParts();
transaction.commit(&src_data_parts_lock);
parts_to_remove = removePartsInRangeFromWorkingSet(drop_range, true, false, src_data_parts_lock);
}
PartLog::addNewParts(global_context, dst_parts, watch.elapsed());