Avoid stale log files.

When the logging configuration changes, the logging-related data
structures on the server are not properly updated. This leads to a bug
where logs are written to old files, and it is impossible to fix without
restarting the server. The log file grows indefinitely and eventually
makes the server run out of disk space (see #8696). To avoid
catastrophic consequences, require that the server is restarted to apply
logging configuration changes, until the proper fix is developed.
This commit is contained in:
Alexander Kuzmenkov 2020-01-17 22:19:09 +03:00
parent e2d8360a76
commit 8de0f4fc34

View File

@ -436,8 +436,10 @@ int Server::main(const std::vector<std::string> & /*args*/)
main_config_zk_changed_event,
[&](ConfigurationPtr config)
{
setTextLog(global_context->getTextLog());
buildLoggers(*config, logger());
// FIXME logging-related things need synchronization -- see the 'Logger * log' saved
// in a lot of places. For now, disable updating log configuration without server restart.
//setTextLog(global_context->getTextLog());
//buildLoggers(*config, logger());
global_context->setClustersConfig(config);
global_context->setMacros(std::make_unique<Macros>(*config, "macros"));
@ -862,6 +864,9 @@ int Server::main(const std::vector<std::string> & /*args*/)
for (auto & server : servers)
server->start();
setTextLog(global_context->getTextLog());
buildLoggers(config(), logger());
main_config_reloader->start();
users_config_reloader->start();
if (dns_cache_updater)