mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #30074 from azat/move-partition-race-fix
Fix race between MOVE PARTITION and merges/mutations for MergeTree
This commit is contained in:
commit
108aafcd6d
@ -1447,6 +1447,11 @@ void StorageMergeTree::replacePartitionFrom(const StoragePtr & source_table, con
|
||||
|
||||
void StorageMergeTree::movePartitionToTable(const StoragePtr & dest_table, const ASTPtr & partition, ContextPtr local_context)
|
||||
{
|
||||
/// MOVE PARTITION cannot be run in parallel with merges/mutations,
|
||||
/// since otherwise there can be some merge/mutation in progress,
|
||||
/// that will be created in the source table after MOVE PARTITION.
|
||||
std::unique_lock background_lock(currently_processing_in_background_mutex);
|
||||
|
||||
auto lock1 = lockForShare(local_context->getCurrentQueryId(), local_context->getSettingsRef().lock_acquire_timeout);
|
||||
auto lock2 = dest_table->lockForShare(local_context->getCurrentQueryId(), local_context->getSettingsRef().lock_acquire_timeout);
|
||||
|
||||
@ -1509,7 +1514,6 @@ void StorageMergeTree::movePartitionToTable(const StoragePtr & dest_table, const
|
||||
transaction.commit(&lock);
|
||||
}
|
||||
|
||||
clearOldMutations(true);
|
||||
clearOldPartsFromFilesystem();
|
||||
|
||||
PartLog::addNewParts(getContext(), dst_parts, watch.elapsed());
|
||||
|
Loading…
Reference in New Issue
Block a user