diff --git a/src/Storages/MergeTree/MergeTreeData.cpp b/src/Storages/MergeTree/MergeTreeData.cpp index 3649065e3c2..a156c4fe220 100644 --- a/src/Storages/MergeTree/MergeTreeData.cpp +++ b/src/Storages/MergeTree/MergeTreeData.cpp @@ -1391,12 +1391,20 @@ void MergeTreeData::dropIfEmpty() if (!data_parts_by_info.empty()) return; - for (const auto & [path, disk] : getRelativeDataPathsWithDisks()) + try { - /// Non recursive, exception is thrown if there are more files. - disk->removeFile(path + MergeTreeData::FORMAT_VERSION_FILE_NAME); - disk->removeDirectory(path + MergeTreeData::DETACHED_DIR_NAME); - disk->removeDirectory(path); + for (const auto & [path, disk] : getRelativeDataPathsWithDisks()) + { + /// Non recursive, exception is thrown if there are more files. + disk->removeFileIfExists(path + MergeTreeData::FORMAT_VERSION_FILE_NAME); + disk->removeDirectory(path + MergeTreeData::DETACHED_DIR_NAME); + disk->removeDirectory(path); + } + } + catch (...) + { + // On unsuccessful creation of ReplicatedMergeTree table with multidisk configuration some files may not exist. + tryLogCurrentException(__PRETTY_FUNCTION__); } }