Stop config reloader before anything else

This commit is contained in:
Antonio Andelic 2022-11-13 19:17:41 +00:00
parent ebde28bc50
commit 38ee1a81a3

View File

@ -1486,11 +1486,6 @@ int Server::main(const std::vector<std::string> & /*args*/)
#endif
SCOPE_EXIT({
/// Stop reloading of the main config. This must be done before `global_context->shutdown()` because
/// otherwise the reloading may pass a changed config to some destroyed parts of ContextSharedPart.
main_config_reloader.reset();
access_control.stopPeriodicReloading();
async_metrics.stop();
/** Ask to cancel background jobs all table engines,
@ -1789,10 +1784,17 @@ int Server::main(const std::vector<std::string> & /*args*/)
SCOPE_EXIT_SAFE({
LOG_DEBUG(log, "Received termination signal.");
LOG_DEBUG(log, "Waiting for current connections to close.");
/// Stop reloading of the main config. This must be done before everything else because it
/// can try to access/modify already deleted objects.
/// E.g. it can recreate new servers or it may pass a changed config to some destroyed parts of ContextSharedPart.
main_config_reloader.reset();
access_control.stopPeriodicReloading();
is_cancelled = true;
LOG_DEBUG(log, "Waiting for current connections to close.");
size_t current_connections = 0;
{
std::lock_guard lock(servers_lock);