mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-11 17:02:25 +00:00
add proper thread termination
This commit is contained in:
parent
568e25889b
commit
4ec7b10c73
@ -2318,6 +2318,8 @@ try
|
||||
if (current_connections)
|
||||
current_connections = waitServersToFinish(servers, servers_lock, server_settings.shutdown_wait_unfinished);
|
||||
|
||||
CancellationChecker::getInstance().terminateThread();
|
||||
|
||||
if (current_connections)
|
||||
LOG_WARNING(log, "Closed connections. But {} remain."
|
||||
" Tip: To increase wait time add to config: <shutdown_wait_unfinished>60</shutdown_wait_unfinished>", current_connections);
|
||||
|
@ -30,17 +30,20 @@ CancellationChecker::CancellationChecker() : stop_thread(false)
|
||||
{
|
||||
}
|
||||
|
||||
CancellationChecker::~CancellationChecker()
|
||||
{
|
||||
stop_thread = true;
|
||||
}
|
||||
|
||||
CancellationChecker& CancellationChecker::getInstance()
|
||||
{
|
||||
static CancellationChecker instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void CancellationChecker::terminateThread()
|
||||
{
|
||||
LOG_TRACE(getLogger("CancellationChecker"), "Stopping CancellationChecker");
|
||||
stop_thread = true;
|
||||
cond_var.notify_all();
|
||||
}
|
||||
|
||||
|
||||
void CancellationChecker::cancelTask(std::shared_ptr<QueryStatus> query, CancelReason reason)
|
||||
{
|
||||
query->cancelQuery(/*kill=*/false, /*reason=*/reason);
|
||||
|
@ -34,7 +34,6 @@ class CancellationChecker
|
||||
{
|
||||
private:
|
||||
CancellationChecker();
|
||||
~CancellationChecker();
|
||||
|
||||
// Priority queue to manage tasks based on endTime
|
||||
std::multiset<QueryToTrack, CompareEndTime> querySet;
|
||||
@ -55,6 +54,8 @@ public:
|
||||
CancellationChecker(const CancellationChecker&) = delete;
|
||||
CancellationChecker& operator=(const CancellationChecker&) = delete;
|
||||
|
||||
void terminateThread();
|
||||
|
||||
// Method to add a new task to the multiset
|
||||
void appendTask(const std::shared_ptr<QueryStatus> & query, const Int64 & timeout);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user