Fix nasty bug

This commit is contained in:
alesapin 2022-09-16 13:49:39 +02:00
parent 7570c5cf67
commit 06ccdb1ecf
6 changed files with 7 additions and 12 deletions

View File

@ -209,7 +209,7 @@ void DataPartStorageOnDisk::remove(
std::list<ProjectionChecksums> projections,
bool is_temp,
MergeTreeDataPartState state,
Poco::Logger * log) const
Poco::Logger * log)
{
/// NOTE We rename part to delete_tmp_<relative_path> instead of delete_tmp_<name> to avoid race condition
/// when we try to remove two parts with the same name, but different relative paths,
@ -259,6 +259,7 @@ void DataPartStorageOnDisk::remove(
try
{
disk->moveDirectory(from, to);
onRename(root_path, part_dir_without_slash);
}
catch (const fs::filesystem_error & e)
{
@ -271,9 +272,7 @@ void DataPartStorageOnDisk::remove(
}
if (!can_remove_description)
{
can_remove_description.emplace(can_remove_callback());
}
// Record existing projection directories so we don't remove them twice
std::unordered_set<String> projection_directories;

View File

@ -50,7 +50,7 @@ public:
std::list<ProjectionChecksums> projections,
bool is_temp,
MergeTreeDataPartState state,
Poco::Logger * log) const override;
Poco::Logger * log) override;
std::string getRelativePathForPrefix(Poco::Logger * log, const String & prefix, bool detached) const override;

View File

@ -125,7 +125,7 @@ public:
std::list<ProjectionChecksums> projections,
bool is_temp,
MergeTreeDataPartState state,
Poco::Logger * log) const = 0;
Poco::Logger * log) = 0;
/// Get a name like 'prefix_partdir_tryN' which does not exist in a root dir.
/// TODO: remove it.

View File

@ -1433,7 +1433,7 @@ void IMergeTreeDataPart::remove() const
assert(assertHasValidVersionMetadata());
part_is_probably_removed_from_disk = true;
auto can_remove_callback = [&] ()
auto can_remove_callback = [this] ()
{
auto [can_remove, files_not_to_remove] = canRemovePart();
if (!can_remove)

View File

@ -2187,11 +2187,7 @@ void MergeTreeData::dropAllData()
try
{
LOG_INFO(log, "dropAllData: removing table directory recursive to cleanup garbage");
if (disk->supportZeroCopyReplication() && settings_ptr->allow_remote_fs_zero_copy_replication)
disk->removeSharedRecursive(relative_data_path, true, {});
else
disk->removeRecursive(relative_data_path);
disk->removeRecursive(relative_data_path);
}
catch (const fs::filesystem_error & e)
{

View File

@ -7604,7 +7604,7 @@ std::pair<bool, NameSet> StorageReplicatedMergeTree::unlockSharedData(const IMer
}
else
{
LOG_TRACE(log, "Part {} looks temporary, because checksums file doesn't exists, blobs can be removed", part.name);
LOG_TRACE(log, "Part {} looks temporary, because {} file doesn't exists, blobs can be removed", part.name, IMergeTreeDataPart::FILE_FOR_REFERENCES_CHECK);
/// Temporary part with some absent file cannot be locked in shared mode
return std::make_pair(true, NameSet{});
}