Skip to content

Commit

Permalink
clear encryption info for temporary dmfile (#6018) (#6030)
Browse files Browse the repository at this point in the history
close #5979
  • Loading branch information
ti-chi-bot authored Oct 8, 2022
1 parent 443e921 commit d90fbfa
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions dbms/src/Storages/DeltaMerge/File/DMFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,33 +707,24 @@ std::set<UInt64> DMFile::listAllInPath(
// or you may delete some writing files
if (options.clean_up)
{
if (startsWith(name, details::FOLDER_PREFIX_WRITABLE))
if (startsWith(name, details::FOLDER_PREFIX_WRITABLE) || startsWith(name, details::FOLDER_PREFIX_DROPPED))
{
// Clear temporary files
const auto full_path = parent_path + "/" + name;
if (Poco::File temp_file(full_path); temp_file.exists())
temp_file.remove(true);
LOG_FMT_WARNING(log, "Existing temporary dmfile, removed: {}", full_path);
continue;
}
else if (startsWith(name, details::FOLDER_PREFIX_DROPPED))
{
// Clear deleted (maybe broken) DTFiles
// Clear temporary/deleted (maybe broken) files
// The encryption info use readable path. We are not sure the encryption info is deleted or not.
// Try to delete and ignore if it is already deleted.
auto res = try_parse_file_id(name);
if (!res)
{
LOG_FMT_INFO(log, "Unrecognized dropped DM file, ignored: {}", name);
LOG_FMT_INFO(log, "Unrecognized temporary or dropped dmfile, ignored: {}", name);
continue;
}
UInt64 file_id = *res;
// The encryption info use readable path. We are not sure the encryption info is deleted or not.
// Try to delete and ignore if it is already deleted.
const String readable_path = getPathByStatus(parent_path, file_id, DMFile::Status::READABLE);
file_provider->deleteEncryptionInfo(EncryptionPath(readable_path, ""), /* throw_on_error= */ false);
const auto full_path = parent_path + "/" + name;
if (Poco::File del_file(full_path); del_file.exists())
del_file.remove(true);
LOG_FMT_WARNING(log, "Existing dropped dmfile, removed: {}", full_path);
if (Poco::File file(full_path); file.exists())
file.remove(true);
LOG_FMT_WARNING(log, "Existing temporary or dropped dmfile, removed: {}", full_path);
continue;
}
}
Expand Down

0 comments on commit d90fbfa

Please sign in to comment.