diff --git a/src/Common/OvercommitTracker.cpp b/src/Common/OvercommitTracker.cpp
index 9e3917981f9..99424238dc9 100644
--- a/src/Common/OvercommitTracker.cpp
+++ b/src/Common/OvercommitTracker.cpp
@@ -1,6 +1,5 @@
#include "OvercommitTracker.h"
-#include
#include
#include
@@ -60,24 +59,21 @@ void UserOvercommitTracker::pickQueryToExcludeImpl()
OvercommitRatio current_ratio{0, 0};
// At this moment query list must be read only
auto & queries = user_process_list->queries;
- LOG_DEBUG(&Poco::Logger::get("OvercommitTracker"),
- "Trying to choose query to stop from {} queries", queries.size());
+ LOG_DEBUG(logger, "Trying to choose query to stop from {} queries", queries.size());
for (auto const & query : queries)
{
if (query.second->isKilled())
continue;
auto * memory_tracker = query.second->getMemoryTracker();
auto ratio = memory_tracker->getOvercommitRatio();
- LOG_DEBUG(&Poco::Logger::get("OvercommitTracker"),
- "Query has ratio {}/{}", ratio.committed, ratio.soft_limit);
+ LOG_DEBUG(logger, "Query has ratio {}/{}", ratio.committed, ratio.soft_limit);
if (ratio.soft_limit != 0 && current_ratio < ratio)
{
current_tracker = memory_tracker;
current_ratio = ratio;
}
}
- LOG_DEBUG(&Poco::Logger::get("OvercommitTracker"),
- "Selected to stop query with overcommit ratio {}/{}",
+ LOG_DEBUG(logger, "Selected to stop query with overcommit ratio {}/{}",
current_ratio.committed, current_ratio.soft_limit);
picked_tracker = current_tracker;
}
@@ -86,19 +82,28 @@ void GlobalOvercommitTracker::pickQueryToExcludeImpl()
{
MemoryTracker * current_tracker = nullptr;
OvercommitRatio current_ratio{0, 0};
+ LOG_DEBUG(logger, "Trying to choose query to stop from {} queries", process_list->size());
process_list->processEachQueryStatus([&](DB::QueryStatus const & query)
{
- auto * memory_tracker = query.getMemoryTracker();
+ if (query.isKilled())
+ return;
+
Int64 user_soft_limit = 0;
if (auto const * user_process_list = query.getUserProcessList())
user_soft_limit = user_process_list->user_memory_tracker.getSoftLimit();
+ if (user_soft_limit == 0)
+ return;
+ auto * memory_tracker = query.getMemoryTracker();
auto ratio = memory_tracker->getOvercommitRatio(user_soft_limit);
+ LOG_DEBUG(logger, "Query has ratio {}/{}", ratio.committed, ratio.soft_limit);
if (current_ratio < ratio)
{
current_tracker = memory_tracker;
current_ratio = ratio;
}
});
+ LOG_DEBUG(logger, "Selected to stop query with overcommit ratio {}/{}",
+ current_ratio.committed, current_ratio.soft_limit);
picked_tracker = current_tracker;
}
diff --git a/src/Common/OvercommitTracker.h b/src/Common/OvercommitTracker.h
index 5d02d47259c..845402c9a64 100644
--- a/src/Common/OvercommitTracker.h
+++ b/src/Common/OvercommitTracker.h
@@ -1,5 +1,6 @@
#pragma once
+#include
#include
#include
#include
@@ -93,6 +94,7 @@ protected:
private:
DB::ProcessListForUser * user_process_list;
+ Poco::Logger * logger = &Poco::Logger::get("UserOvercommitTracker");
};
struct GlobalOvercommitTracker : OvercommitTracker
@@ -108,6 +110,7 @@ protected:
private:
DB::ProcessList * process_list;
+ Poco::Logger * logger = &Poco::Logger::get("GlobalOvercommitTracker");
};
struct BlockQueryIfMemoryLimit