Skip to content

Commit

Permalink
Merge pull request #55549 from ClickHouse/backport/23.9/55480
Browse files Browse the repository at this point in the history
Backport #55480 to 23.9: Remove existing moving/ dir if allow_remove_stale_moving_parts is off
  • Loading branch information
vdimir committed Oct 12, 2023
2 parents 6c51244 + 129942e commit 4dc5125
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Storages/MergeTree/MergeTreePartsMover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,16 @@ MergeTreePartsMover::TemporaryClonedPart MergeTreePartsMover::clonePart(const Me
String relative_path = part->getDataPartStorage().getPartDirectory();
if (disk->exists(path_to_clone + relative_path))
{
throw Exception(ErrorCodes::DIRECTORY_ALREADY_EXISTS,
"Cannot clone part {} from '{}' to '{}': path '{}' already exists",
part->name, part->getDataPartStorage().getDiskName(), disk->getName(),
// If setting is on, we should've already cleaned moving/ dir on startup
if (data->allowRemoveStaleMovingParts())
throw Exception(ErrorCodes::DIRECTORY_ALREADY_EXISTS,
"Cannot clone part {} from '{}' to '{}': path '{}' already exists",
part->name, part->getDataPartStorage().getDiskName(), disk->getName(),
fullPath(disk, path_to_clone + relative_path));

LOG_DEBUG(log, "Path {} already exists. Will remove it and clone again",
fullPath(disk, path_to_clone + relative_path));
disk->removeRecursive(fs::path(path_to_clone) / relative_path / "");
}

disk->createDirectories(path_to_clone);
Expand Down

0 comments on commit 4dc5125

Please sign in to comment.