Fixed race condition at startup [#CLICKHOUSE-2]

This commit is contained in:
Alexey Milovidov 2018-03-03 17:39:16 +03:00
parent fca64bb9da
commit 1aad435d52
3 changed files with 13 additions and 1 deletions

View File

@ -24,7 +24,11 @@ ConfigReloader::ConfigReloader(
{
if (!already_loaded)
reloadIfNewer(/* force = */ true, /* throw_on_error = */ true, /* fallback_to_preprocessed = */ true);
}
void ConfigReloader::start()
{
thread = std::thread(&ConfigReloader::run, this);
}
@ -35,7 +39,9 @@ ConfigReloader::~ConfigReloader()
{
quit = true;
zk_node_cache.getChangedEvent().set();
thread.join();
if (thread.joinable())
thread.join();
}
catch (...)
{

View File

@ -39,6 +39,9 @@ public:
~ConfigReloader();
/// Call this method to run the backround thread.
void start();
private:
void run();

View File

@ -473,6 +473,9 @@ int Server::main(const std::vector<std::string> & /*args*/)
for (auto & server : servers)
server->start();
main_config_reloader->start();
users_config_reloader->start();
{
std::stringstream message;
message << "Available RAM = " << formatReadableSizeWithBinarySuffix(getMemoryAmount()) << ";"