diff --git a/dbms/src/Storages/MergeTree/MergeList.cpp b/dbms/src/Storages/MergeTree/MergeList.cpp index 9fd0b5fa2aa..6c79dc5ed67 100644 --- a/dbms/src/Storages/MergeTree/MergeList.cpp +++ b/dbms/src/Storages/MergeTree/MergeList.cpp @@ -17,6 +17,7 @@ namespace DB MergeListElement::MergeListElement(const std::string & database_, const std::string & table_, const FutureMergedMutatedPart & future_part) : database{database_}, table{table_}, partition_id{future_part.part_info.partition_id} , result_part_name{future_part.name} + , result_part_path{future_part.path} , result_data_version{future_part.part_info.getDataVersion()} , num_parts{future_part.parts.size()} , thread_number{getThreadNumber()} diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp b/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp index 4b16eab67e6..e1b9ee656a3 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp @@ -960,7 +960,6 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataMergerMutator::mutatePartToTempor new_data_part->index_granularity_info = source_part->index_granularity_info; String new_part_tmp_path = new_data_part->getFullPath(); - merge_entry->result_part_path = new_part_tmp_path; /// Note: this is done before creating input streams, because otherwise data.data_parts_mutex /// (which is locked in data.getTotalActiveSizeInBytes()) is locked after part->columns_lock diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.h b/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.h index 4d87cfe35ff..48e4232b8fa 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.h +++ b/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.h @@ -17,6 +17,7 @@ class MergeProgressCallback; struct FutureMergedMutatedPart { String name; + String path; MergeTreePartInfo part_info; MergeTreeData::DataPartsVector parts; diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataPart.cpp b/dbms/src/Storages/MergeTree/MergeTreeDataPart.cpp index 14e0191d6d4..3747a39e637 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataPart.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeDataPart.cpp @@ -289,6 +289,12 @@ String MergeTreeDataPart::getNewName(const MergeTreePartInfo & new_part_info) co return new_part_info.getPartName(); } +String MergeTreeDataPart::getNewPath(const MergeTreePartInfo & new_part_info, + const DiskSpace::ReservationPtr & reservation) const +{ + return storage.getFullPathOnDisk(reservation->getDisk()) + "/" + getNewName(new_part_info) + "/"; +} + DayNum MergeTreeDataPart::getMinDate() const { if (storage.minmax_idx_date_column_pos != -1 && minmax_idx.initialized) diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataPart.h b/dbms/src/Storages/MergeTree/MergeTreeDataPart.h index d684b2de276..60b92c82b18 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataPart.h +++ b/dbms/src/Storages/MergeTree/MergeTreeDataPart.h @@ -58,6 +58,9 @@ struct MergeTreeDataPart /// This is useful when you want to change e.g. block numbers or the mutation version of the part. String getNewName(const MergeTreePartInfo & new_part_info) const; + /// Generate the new path for this part + String getNewPath(const MergeTreePartInfo & new_part_info, const DiskSpace::ReservationPtr & reservation) const; + bool contains(const MergeTreeDataPart & other) const { return info.contains(other.info); } /// If the partition key includes date column (a common case), these functions will return min and max values for this column. diff --git a/dbms/src/Storages/StorageMergeTree.cpp b/dbms/src/Storages/StorageMergeTree.cpp index d3ff30d2d95..9c04ee1cb54 100644 --- a/dbms/src/Storages/StorageMergeTree.cpp +++ b/dbms/src/Storages/StorageMergeTree.cpp @@ -706,6 +706,7 @@ bool StorageMergeTree::tryMutatePart() future_part.parts.push_back(part); future_part.part_info = new_part_info; future_part.name = part->getNewName(new_part_info); + future_part.path = part->getNewPath(new_part_info, tagger->reserved_space); tagger.emplace(future_part, MergeTreeDataMergerMutator::estimateNeededDiskSpace({part}), *this, true); break; diff --git a/dbms/src/Storages/StorageReplicatedMergeTree.cpp b/dbms/src/Storages/StorageReplicatedMergeTree.cpp index 76b6c40126a..c93bab27037 100644 --- a/dbms/src/Storages/StorageReplicatedMergeTree.cpp +++ b/dbms/src/Storages/StorageReplicatedMergeTree.cpp @@ -1156,6 +1156,7 @@ bool StorageReplicatedMergeTree::tryExecutePartMutation(const StorageReplicatedM future_mutated_part.parts.push_back(source_part); future_mutated_part.part_info = new_part_info; future_mutated_part.name = entry.new_part_name; + future_mutated_part.path = source_part->getNewPath(new_part_info, reserved_space); MergeList::EntryPtr merge_entry = global_context.getMergeList().insert( database_name, table_name, future_mutated_part);