add SCOPE_EXIT

This commit is contained in:
Yarik Briukhovetskyi 2024-10-17 19:37:33 +02:00 committed by GitHub
parent 73748075a2
commit 57798a19c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1101,10 +1101,6 @@ try
PlacementInfo::PlacementInfo::instance().initialize(config());
auto cancellation_task_holder = global_context->getSchedulePool().createTask("CancellationChecker", []{ CancellationChecker::getInstance().workerFunction(); });
auto cancellation_task = std::make_unique<DB::BackgroundSchedulePoolTaskHolder>(std::move(cancellation_task_holder));
(*cancellation_task)->activateAndSchedule();
zkutil::validateZooKeeperConfig(config());
bool has_zookeeper = zkutil::hasZooKeeperConfig(config());
@ -1249,6 +1245,14 @@ try
setOOMScore(oom_score, log);
#endif
auto cancellation_task_holder = global_context->getSchedulePool().createTask("CancellationChecker", []{ CancellationChecker::getInstance().workerFunction(); });
auto cancellation_task = std::make_unique<DB::BackgroundSchedulePoolTaskHolder>(std::move(cancellation_task_holder));
(*cancellation_task)->activateAndSchedule();
SCOPE_EXIT({
CancellationChecker::getInstance().terminateThread();
});
global_context->setRemoteHostFilter(config());
global_context->setHTTPHeaderFilter(config());
@ -2318,8 +2322,6 @@ 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);