Merge pull request #2131 from ClickHouse-Ninja/system-log-prepare-table-on-each-flush

SystemLog: проверка структуры и существования таблицы при каждом flush
This commit is contained in:
alexey-milovidov 2018-03-29 23:55:14 +03:00 committed by GitHub
commit 10e5d63d76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -233,8 +233,10 @@ void SystemLog<LogElement>::flush()
{
LOG_TRACE(log, "Flushing system log");
if (!is_prepared) /// BTW, flush method is called from single thread.
prepareTable();
/// We check for existence of the table and create it as needed at every flush.
/// This is done to allow user to drop the table at any moment (new empty table will be created automatically).
/// BTW, flush method is called from single thread.
prepareTable();
Block block = LogElement::createBlock();
for (const LogElement & elem : data)
@ -311,7 +313,7 @@ void SystemLog<LogElement>::prepareTable()
/// The required table will be created.
table = nullptr;
}
else
else if (!is_prepared)
LOG_DEBUG(log, "Will use existing table " << description << " for " + LogElement::name());
}