Merge pull request #23433 from ClickHouse/tavplubix-patch-1

Fix `Cannot unlink file` in `dropIfEmpty()` with multidisk confuguration
This commit is contained in:
alexey-milovidov 2021-04-24 03:34:06 +03:00 committed by GitHub
commit c66e715f49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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__);
}
}