From 1f3701d4851fd19c5fee2c61f155ec23d461bf7b Mon Sep 17 00:00:00 2001 From: Mike Kot Date: Wed, 25 Aug 2021 21:18:12 +0200 Subject: [PATCH] Disk empty name fix --- src/Storages/MergeTree/MergeTreeData.cpp | 8 +++++--- src/Storages/MergeTree/MergeTreePartInfo.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Storages/MergeTree/MergeTreeData.cpp b/src/Storages/MergeTree/MergeTreeData.cpp index d461d55d161..6cfa6ab70d7 100644 --- a/src/Storages/MergeTree/MergeTreeData.cpp +++ b/src/Storages/MergeTree/MergeTreeData.cpp @@ -895,7 +895,7 @@ void MergeTreeData::loadDataParts(bool skip_sanity_checks) for (const auto it = disk->iterateDirectory(relative_data_path); it->isValid(); it->next()) { if (MergeTreePartInfo::tryParsePartName(it->name(), format_version)) - throw Exception(ErrorCodes::UNKNOWN_DISK, + throw Exception(ErrorCodes::UNKNOWN_DISK, "Part {} was found on disk {} which is not defined in the storage policy", backQuote(it->name()), backQuote(disk_name)); } @@ -3569,8 +3569,10 @@ std::vector MergeTreeData::getDetachedParts() const { for (auto it = disk->iterateDirectory(detached_path); it->isValid(); it->next()) { - auto res_it = res.emplace_back(DetachedPartInfo::parseDetachedPartName(it->name(), format_version)); - res_it.disk = disk->getName(); + auto part = DetachedPartInfo::parseDetachedPartName(it->name(), format_version); + part.disk = disk->getName(); + + res.push_back(std::move(part)); } } } diff --git a/src/Storages/MergeTree/MergeTreePartInfo.h b/src/Storages/MergeTree/MergeTreePartInfo.h index 58707b4dca3..bda7c24bab8 100644 --- a/src/Storages/MergeTree/MergeTreePartInfo.h +++ b/src/Storages/MergeTree/MergeTreePartInfo.h @@ -125,7 +125,7 @@ struct DetachedPartInfo : public MergeTreePartInfo /// If false, MergeTreePartInfo is in invalid state (directory name was not successfully parsed). bool valid_name; - static constexpr auto DETACH_REASONS = std::to_array({ + static constexpr auto DETACH_REASONS = std::to_array({ "broken", "unexpected", "noquorum", "ignored", "broken-on-start", "clone", "attaching", "deleting", "tmp-fetch"