mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Merge pull request #22411 from nvartolomei/nv/replication-queue-directory-already-exists
Delete temporary fetch directory if it already exists
This commit is contained in:
commit
2d1a2ddb9b
@ -543,11 +543,22 @@ MergeTreeData::MutableDataPartPtr Fetcher::downloadPartToDisk(
|
||||
static const String TMP_PREFIX = "tmp_fetch_";
|
||||
String tmp_prefix = tmp_prefix_.empty() ? TMP_PREFIX : tmp_prefix_;
|
||||
|
||||
/// We will remove directory if it's already exists. Make precautions.
|
||||
if (tmp_prefix.empty()
|
||||
|| part_name.empty()
|
||||
|| std::string::npos != tmp_prefix.find_first_of("/.")
|
||||
|| std::string::npos != part_name.find_first_of("/."))
|
||||
throw Exception("Logical error: tmp_prefix and part_name cannot be empty or contain '.' or '/' characters.", ErrorCodes::LOGICAL_ERROR);
|
||||
|
||||
String part_relative_path = String(to_detached ? "detached/" : "") + tmp_prefix + part_name;
|
||||
String part_download_path = data.getRelativeDataPath() + part_relative_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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user