From 31f6636a47bc83b49b60ffa2988e351a44f1d289 Mon Sep 17 00:00:00 2001 From: alesapin Date: Mon, 26 Sep 2022 16:33:25 +0200 Subject: [PATCH] Fix endless remove --- .../ObjectStorages/DiskObjectStorageTransaction.cpp | 2 +- src/Storages/MergeTree/DataPartStorageOnDisk.cpp | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Disks/ObjectStorages/DiskObjectStorageTransaction.cpp b/src/Disks/ObjectStorages/DiskObjectStorageTransaction.cpp index 5f376de34dc..2a75668dd76 100644 --- a/src/Disks/ObjectStorages/DiskObjectStorageTransaction.cpp +++ b/src/Disks/ObjectStorages/DiskObjectStorageTransaction.cpp @@ -490,7 +490,7 @@ void DiskObjectStorageTransaction::moveFile(const String & from_path, const Stri throw Exception("File already exists: " + to_path, ErrorCodes::FILE_ALREADY_EXISTS); if (!metadata_storage.exists(from_path)) - throw Exception(ErrorCodes::FILE_DOESNT_EXIST, "File {} doesn't exist, cannot move", to_path); + throw Exception(ErrorCodes::FILE_DOESNT_EXIST, "File {} doesn't exist, cannot move", from_path); tx->moveFile(from_path, to_path); })); diff --git a/src/Storages/MergeTree/DataPartStorageOnDisk.cpp b/src/Storages/MergeTree/DataPartStorageOnDisk.cpp index 5245bc89e0c..06a3887f1b0 100644 --- a/src/Storages/MergeTree/DataPartStorageOnDisk.cpp +++ b/src/Storages/MergeTree/DataPartStorageOnDisk.cpp @@ -21,6 +21,7 @@ namespace ErrorCodes extern const int DIRECTORY_ALREADY_EXISTS; extern const int NOT_ENOUGH_SPACE; extern const int LOGICAL_ERROR; + extern const int FILE_DOESNT_EXIST; } DataPartStorageOnDisk::DataPartStorageOnDisk(VolumePtr volume_, std::string root_path_, std::string part_dir_) @@ -261,11 +262,20 @@ void DataPartStorageOnDisk::remove( disk->moveDirectory(from, to); onRename(root_path, part_dir_without_slash); } + catch (const Exception & e) + { + if (e.code() == ErrorCodes::FILE_DOESNT_EXIST) + { + LOG_ERROR(log, "Directory {} (part to remove) doesn't exist or one of nested files has gone. Most likely this is due to manual removing. This should be discouraged. Ignoring.", fullPath(disk, from)); + return; + } + throw; + } catch (const fs::filesystem_error & e) { if (e.code() == std::errc::no_such_file_or_directory) { - LOG_ERROR(log, "Directory {} (part to remove) doesn't exist or one of nested files has gone. Most likely this is due to manual removing. This should be discouraged. Ignoring.", fullPath(disk, to)); + LOG_ERROR(log, "Directory {} (part to remove) doesn't exist or one of nested files has gone. Most likely this is due to manual removing. This should be discouraged. Ignoring.", fullPath(disk, from)); return; } throw;