mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-13 18:02:24 +00:00
Yet another deadlock fix attempt
This commit is contained in:
parent
326217a039
commit
7b478cb73f
@ -133,13 +133,15 @@ void QueryMetricLog::finishQuery(const String & query_id, QueryStatusInfoPtr que
|
||||
add(std::move(elem.value()));
|
||||
}
|
||||
|
||||
/// Take ownership of the task, setting finished to true so that we don't try to schedule it anymore.
|
||||
auto task = std::move(it->second.task);
|
||||
it->second.finished = true;
|
||||
{
|
||||
/// Take ownership of the task, setting the old one so that we don't try to schedule it anymore.
|
||||
auto task = std::move(it->second.task);
|
||||
it->second.task = {};
|
||||
|
||||
/// Make sure to always deactivate the task without locking queries_mutex to prevent deadlock.
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
/// Make sure to always deactivate the task without locking queries_mutex to prevent deadlock.
|
||||
lock.unlock();
|
||||
task->deactivate();
|
||||
lock.lock();
|
||||
queries.erase(query_id);
|
||||
}
|
||||
@ -175,7 +177,7 @@ std::optional<QueryMetricLogElement> QueryMetricLog::createLogMetricElement(cons
|
||||
elem.profile_events = query_status.last_profile_events;
|
||||
}
|
||||
|
||||
if (!query_status.finished && schedule_next)
|
||||
if (query_status.task && schedule_next)
|
||||
{
|
||||
query_status.next_collect_time += std::chrono::milliseconds(query_status.interval_milliseconds);
|
||||
const auto wait_time = std::chrono::duration_cast<std::chrono::milliseconds>(query_status.next_collect_time - std::chrono::system_clock::now()).count();
|
||||
|
Loading…
Reference in New Issue
Block a user