mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-19 22:22:00 +00:00
Fix possible NPE when thread_group is not set
This commit is contained in:
parent
b81d600c1e
commit
de432f9270
@ -66,7 +66,11 @@ void UserOvercommitTracker::pickQueryToExcludeImpl()
|
||||
{
|
||||
if (query.second->isKilled())
|
||||
continue;
|
||||
|
||||
auto * memory_tracker = query.second->getMemoryTracker();
|
||||
if (!memory_tracker)
|
||||
continue;
|
||||
|
||||
auto ratio = memory_tracker->getOvercommitRatio();
|
||||
LOG_DEBUG(logger, "Query has ratio {}/{}", ratio.committed, ratio.soft_limit);
|
||||
if (ratio.soft_limit != 0 && current_ratio < ratio)
|
||||
@ -96,6 +100,8 @@ void GlobalOvercommitTracker::pickQueryToExcludeImpl()
|
||||
return;
|
||||
|
||||
auto * memory_tracker = query.getMemoryTracker();
|
||||
if (!memory_tracker)
|
||||
return;
|
||||
auto ratio = memory_tracker->getOvercommitRatio(user_soft_limit);
|
||||
LOG_DEBUG(logger, "Query has ratio {}/{}", ratio.committed, ratio.soft_limit);
|
||||
if (current_ratio < ratio)
|
||||
|
@ -309,12 +309,14 @@ QueryStatus::~QueryStatus()
|
||||
{
|
||||
assert(executors.empty());
|
||||
|
||||
auto * memory_tracker = getMemoryTracker();
|
||||
if (auto * memory_tracker = getMemoryTracker())
|
||||
{
|
||||
if (user_process_list)
|
||||
user_process_list->user_overcommit_tracker.unsubscribe(memory_tracker);
|
||||
if (auto shared_context = getContext())
|
||||
shared_context->getGlobalOvercommitTracker()->unsubscribe(memory_tracker);
|
||||
}
|
||||
}
|
||||
|
||||
CancellationCode QueryStatus::cancelQuery(bool)
|
||||
{
|
||||
|
@ -149,6 +149,8 @@ public:
|
||||
|
||||
MemoryTracker * getMemoryTracker() const
|
||||
{
|
||||
if (!thread_group)
|
||||
return nullptr;
|
||||
return &thread_group->memory_tracker;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user