diff --git a/dbms/include/DB/Core/ErrorCodes.h b/dbms/include/DB/Core/ErrorCodes.h index 34f66132dcc..7d3a86bd64a 100644 --- a/dbms/include/DB/Core/ErrorCodes.h +++ b/dbms/include/DB/Core/ErrorCodes.h @@ -264,6 +264,7 @@ namespace ErrorCodes NO_ACTIVE_REPLICAS, TOO_MUCH_RETRIES_TO_FETCH_PARTS, PARTITION_ALREADY_EXISTS, + PARTITION_DOESNT_EXIST, POCO_EXCEPTION = 1000, STD_EXCEPTION, diff --git a/dbms/src/Storages/MergeTree/ReplicatedMergeTreePartsExchange.cpp b/dbms/src/Storages/MergeTree/ReplicatedMergeTreePartsExchange.cpp index 45c8dff4189..b6eac826cdc 100644 --- a/dbms/src/Storages/MergeTree/ReplicatedMergeTreePartsExchange.cpp +++ b/dbms/src/Storages/MergeTree/ReplicatedMergeTreePartsExchange.cpp @@ -73,7 +73,8 @@ MergeTreeData::MutableDataPartPtr ReplicatedMergeTreePartsFetcher::fetchPart( std::make_pair("compress", "false")}; ReadBufferFromHTTP in(host, port, params); - String part_path = data.getFullPath() + (to_detached ? "detached/" : "") + "tmp_" + part_name + "/"; + String full_part_name = String(to_detached ? "detached/" : "") + "tmp_" + part_name; + String part_path = data.getFullPath() + full_part_name + "/"; Poco::File part_file(part_path); if (part_file.exists()) @@ -85,7 +86,7 @@ MergeTreeData::MutableDataPartPtr ReplicatedMergeTreePartsFetcher::fetchPart( part_file.createDirectory(); MergeTreeData::MutableDataPartPtr new_data_part = std::make_shared(data); - new_data_part->name = "tmp_" + part_name; + new_data_part->name = full_part_name; new_data_part->is_temp = true; size_t files; diff --git a/dbms/src/Storages/StorageReplicatedMergeTree.cpp b/dbms/src/Storages/StorageReplicatedMergeTree.cpp index eb8ae5746c4..070a4916c5f 100644 --- a/dbms/src/Storages/StorageReplicatedMergeTree.cpp +++ b/dbms/src/Storages/StorageReplicatedMergeTree.cpp @@ -2945,6 +2945,9 @@ void StorageReplicatedMergeTree::fetchPartition(const Field & partition, bool un parts_to_fetch_partition.push_back(part); parts_to_fetch = std::move(parts_to_fetch_partition); + + if (parts_to_fetch.empty()) + throw Exception("Partition " + partition_str + " on " + best_replica_path + " doesn't exist", ErrorCodes::PARTITION_DOESNT_EXIST); } else {