mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-20 06:32:08 +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())
|
if (query.second->isKilled())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto * memory_tracker = query.second->getMemoryTracker();
|
auto * memory_tracker = query.second->getMemoryTracker();
|
||||||
|
if (!memory_tracker)
|
||||||
|
continue;
|
||||||
|
|
||||||
auto ratio = memory_tracker->getOvercommitRatio();
|
auto ratio = memory_tracker->getOvercommitRatio();
|
||||||
LOG_DEBUG(logger, "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)
|
if (ratio.soft_limit != 0 && current_ratio < ratio)
|
||||||
@ -96,6 +100,8 @@ void GlobalOvercommitTracker::pickQueryToExcludeImpl()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
auto * memory_tracker = query.getMemoryTracker();
|
auto * memory_tracker = query.getMemoryTracker();
|
||||||
|
if (!memory_tracker)
|
||||||
|
return;
|
||||||
auto ratio = memory_tracker->getOvercommitRatio(user_soft_limit);
|
auto ratio = memory_tracker->getOvercommitRatio(user_soft_limit);
|
||||||
LOG_DEBUG(logger, "Query has ratio {}/{}", ratio.committed, ratio.soft_limit);
|
LOG_DEBUG(logger, "Query has ratio {}/{}", ratio.committed, ratio.soft_limit);
|
||||||
if (current_ratio < ratio)
|
if (current_ratio < ratio)
|
||||||
|
@ -309,12 +309,14 @@ QueryStatus::~QueryStatus()
|
|||||||
{
|
{
|
||||||
assert(executors.empty());
|
assert(executors.empty());
|
||||||
|
|
||||||
auto * memory_tracker = getMemoryTracker();
|
if (auto * memory_tracker = getMemoryTracker())
|
||||||
|
{
|
||||||
if (user_process_list)
|
if (user_process_list)
|
||||||
user_process_list->user_overcommit_tracker.unsubscribe(memory_tracker);
|
user_process_list->user_overcommit_tracker.unsubscribe(memory_tracker);
|
||||||
if (auto shared_context = getContext())
|
if (auto shared_context = getContext())
|
||||||
shared_context->getGlobalOvercommitTracker()->unsubscribe(memory_tracker);
|
shared_context->getGlobalOvercommitTracker()->unsubscribe(memory_tracker);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CancellationCode QueryStatus::cancelQuery(bool)
|
CancellationCode QueryStatus::cancelQuery(bool)
|
||||||
{
|
{
|
||||||
|
@ -149,6 +149,8 @@ public:
|
|||||||
|
|
||||||
MemoryTracker * getMemoryTracker() const
|
MemoryTracker * getMemoryTracker() const
|
||||||
{
|
{
|
||||||
|
if (!thread_group)
|
||||||
|
return nullptr;
|
||||||
return &thread_group->memory_tracker;
|
return &thread_group->memory_tracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user