From 885447342c1cb4937b4d07c8aa46c6407e7d584e Mon Sep 17 00:00:00 2001 From: alesapin Date: Mon, 4 Apr 2022 13:17:33 +0200 Subject: [PATCH 1/3] More logs on unsuccessful part removal --- src/Interpreters/ExternalDictionariesLoader.cpp | 2 +- src/Storages/MergeTree/MergeTreeData.cpp | 12 +++++++++++- src/Storages/StorageReplicatedMergeTree.cpp | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Interpreters/ExternalDictionariesLoader.cpp b/src/Interpreters/ExternalDictionariesLoader.cpp index f615aa24a91..4dd779e3a50 100644 --- a/src/Interpreters/ExternalDictionariesLoader.cpp +++ b/src/Interpreters/ExternalDictionariesLoader.cpp @@ -136,7 +136,7 @@ std::string ExternalDictionariesLoader::resolveDictionaryNameFromDatabaseCatalog if (qualified_name->database.empty()) { - /// Ether database name is not specified and we should use current one + /// Either database name is not specified and we should use current one /// or it's an XML dictionary. bool is_xml_dictionary = has(name); if (is_xml_dictionary) diff --git a/src/Storages/MergeTree/MergeTreeData.cpp b/src/Storages/MergeTree/MergeTreeData.cpp index b433c6e4591..f77480dbaaf 100644 --- a/src/Storages/MergeTree/MergeTreeData.cpp +++ b/src/Storages/MergeTree/MergeTreeData.cpp @@ -2953,7 +2953,8 @@ void MergeTreeData::tryRemovePartImmediately(DataPartPtr && part) { auto lock = lockParts(); - LOG_TRACE(log, "Trying to immediately remove part {}", part->getNameWithState()); + auto part_name_with_state = part->getNameWithState(); + LOG_TRACE(log, "Trying to immediately remove part {}", part_name_with_state); if (part->getState() != DataPartState::Temporary) { @@ -2964,7 +2965,16 @@ void MergeTreeData::tryRemovePartImmediately(DataPartPtr && part) part.reset(); if (!((*it)->getState() == DataPartState::Outdated && it->unique())) + { + if (!(*it)->getState() == DataPartState::Outdated) + LOG_WARNING("Cannot immediately remove part {} because it's not in Outdated state " + "usage counter {}", part_name_with_state, it->use_count()); + + if (!it->unique()) + LOG_WARNING("Cannot immediately remove part {} because someone using it right now " + "usage counter {}", part_name_with_state, it->use_count()); return; + } modifyPartState(it, DataPartState::Deleting); diff --git a/src/Storages/StorageReplicatedMergeTree.cpp b/src/Storages/StorageReplicatedMergeTree.cpp index d9f72cf7feb..b6f7b65dfa2 100644 --- a/src/Storages/StorageReplicatedMergeTree.cpp +++ b/src/Storages/StorageReplicatedMergeTree.cpp @@ -3321,7 +3321,7 @@ void StorageReplicatedMergeTree::removePartAndEnqueueFetch(const String & part_n if (!broken_part_info.contains(part->info)) continue; - /// Broken part itself ether already moved to detached or does not exist. + /// Broken part itself either already moved to detached or does not exist. assert(broken_part_info != part->info); part->makeCloneInDetached("covered-by-broken", getInMemoryMetadataPtr()); } From 9b75ef6ce957b550aaf3fdb0ae2403227a4cfceb Mon Sep 17 00:00:00 2001 From: alesapin Date: Mon, 4 Apr 2022 14:03:16 +0200 Subject: [PATCH 2/3] Fix build --- src/Storages/MergeTree/MergeTreeData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storages/MergeTree/MergeTreeData.cpp b/src/Storages/MergeTree/MergeTreeData.cpp index f77480dbaaf..8419f07ae73 100644 --- a/src/Storages/MergeTree/MergeTreeData.cpp +++ b/src/Storages/MergeTree/MergeTreeData.cpp @@ -2966,7 +2966,7 @@ void MergeTreeData::tryRemovePartImmediately(DataPartPtr && part) if (!((*it)->getState() == DataPartState::Outdated && it->unique())) { - if (!(*it)->getState() == DataPartState::Outdated) + if ((*it)->getState() != DataPartState::Outdated) LOG_WARNING("Cannot immediately remove part {} because it's not in Outdated state " "usage counter {}", part_name_with_state, it->use_count()); From d04c48e67a96493ddae35e6fe7fc15c7fc03d363 Mon Sep 17 00:00:00 2001 From: alesapin Date: Mon, 4 Apr 2022 20:14:09 +0200 Subject: [PATCH 3/3] Fix build --- src/Storages/MergeTree/MergeTreeData.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Storages/MergeTree/MergeTreeData.cpp b/src/Storages/MergeTree/MergeTreeData.cpp index 8419f07ae73..42b26db72ce 100644 --- a/src/Storages/MergeTree/MergeTreeData.cpp +++ b/src/Storages/MergeTree/MergeTreeData.cpp @@ -2967,11 +2967,11 @@ void MergeTreeData::tryRemovePartImmediately(DataPartPtr && part) if (!((*it)->getState() == DataPartState::Outdated && it->unique())) { if ((*it)->getState() != DataPartState::Outdated) - LOG_WARNING("Cannot immediately remove part {} because it's not in Outdated state " + LOG_WARNING(log, "Cannot immediately remove part {} because it's not in Outdated state " "usage counter {}", part_name_with_state, it->use_count()); if (!it->unique()) - LOG_WARNING("Cannot immediately remove part {} because someone using it right now " + LOG_WARNING(log, "Cannot immediately remove part {} because someone using it right now " "usage counter {}", part_name_with_state, it->use_count()); return; }