Avoid std::terminate in case of exception from SystemLogs::SystemLogs

Since, at least, this will hide the real exception
This commit is contained in:
Azat Khuzhin 2020-05-09 16:02:37 +03:00
parent 699ef4ff52
commit c42943850f
2 changed files with 20 additions and 4 deletions

View File

@ -98,12 +98,22 @@ SystemLogs::SystemLogs(Context & global_context, const Poco::Util::AbstractConfi
logs.emplace_back(metric_log.get());
bool lazy_load = config.getBool("system_tables_lazy_load", true);
try
{
for (auto & log : logs)
{
if (!lazy_load)
log->prepareTable();
log->startup();
}
}
catch (...)
{
/// join threads
shutdown();
throw;
}
}

View File

@ -208,6 +208,7 @@ SystemLog<LogElement>::SystemLog(Context & context_,
template <typename LogElement>
void SystemLog<LogElement>::startup()
{
std::unique_lock lock(mutex);
saving_thread = ThreadFromGlobalPool([this] { savingThreadFunction(); });
}
@ -288,6 +289,11 @@ void SystemLog<LogElement>::stopFlushThread()
{
std::unique_lock lock(mutex);
if (!saving_thread.joinable())
{
return;
}
if (is_shutdown)
{
return;