Delete temporary fetch directory if it already exists

It could be left there after a network timeout, a system crash, or
checksum issues.

The downside of this PR is that it would be harder to debug checksum
issues if replication will continuously delete and try to fetch the same
part.
This commit is contained in:
Nicolae Vartolomei 2021-03-31 14:14:46 +01:00
parent 6c1e2a0d87
commit 5cd1dc485f

View File

@ -547,7 +547,11 @@ MergeTreeData::MutableDataPartPtr Fetcher::downloadPartToDisk(
String part_download_path = data.getRelativeDataPath() + part_relative_path + "/"; String part_download_path = data.getRelativeDataPath() + part_relative_path + "/";
if (disk->exists(part_download_path)) if (disk->exists(part_download_path))
throw Exception("Directory " + fullPath(disk, part_download_path) + " already exists.", ErrorCodes::DIRECTORY_ALREADY_EXISTS); {
LOG_WARNING(log, "Directory {} already exists, probably result of a failed fetch. Will remove it before fetching part.",
fullPath(disk, part_download_path));
disk->removeRecursive(part_download_path);
}
disk->createDirectories(part_download_path); disk->createDirectories(part_download_path);