From 8d3e6ed5e349bbd14dce8b7b8d783efad181706a Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sun, 19 Apr 2020 23:04:59 +0300 Subject: [PATCH] Added missing code --- src/Interpreters/SystemLog.cpp | 19 +++++++++++-------- src/Interpreters/SystemLog.h | 3 ++- src/Interpreters/TextLog.cpp | 4 ++-- src/Interpreters/TextLog.h | 3 ++- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/Interpreters/SystemLog.cpp b/src/Interpreters/SystemLog.cpp index fc0f2f98125..3740ac3f4c8 100644 --- a/src/Interpreters/SystemLog.cpp +++ b/src/Interpreters/SystemLog.cpp @@ -30,7 +30,8 @@ std::shared_ptr createSystemLog( const String & default_database_name, const String & default_table_name, const Poco::Util::AbstractConfiguration & config, - const String & config_prefix) + const String & config_prefix, + bool lazy_load) { if (!config.has(config_prefix)) return {}; @@ -63,7 +64,7 @@ std::shared_ptr createSystemLog( size_t flush_interval_milliseconds = config.getUInt64(config_prefix + ".flush_interval_milliseconds", DEFAULT_SYSTEM_LOG_FLUSH_INTERVAL_MILLISECONDS); - return std::make_shared(context, database, table, engine, flush_interval_milliseconds); + return std::make_shared(context, database, table, engine, flush_interval_milliseconds, lazy_load); } } @@ -71,12 +72,14 @@ std::shared_ptr createSystemLog( SystemLogs::SystemLogs(Context & global_context, const Poco::Util::AbstractConfiguration & config) { - query_log = createSystemLog(global_context, "system", "query_log", config, "query_log"); - query_thread_log = createSystemLog(global_context, "system", "query_thread_log", config, "query_thread_log"); - part_log = createSystemLog(global_context, "system", "part_log", config, "part_log"); - trace_log = createSystemLog(global_context, "system", "trace_log", config, "trace_log"); - text_log = createSystemLog(global_context, "system", "text_log", config, "text_log"); - metric_log = createSystemLog(global_context, "system", "metric_log", config, "metric_log"); + bool lazy_load = config.getBool("system_tables_lazy_load", true); + + query_log = createSystemLog(global_context, "system", "query_log", config, "query_log", lazy_load); + query_thread_log = createSystemLog(global_context, "system", "query_thread_log", config, "query_thread_log", lazy_load); + part_log = createSystemLog(global_context, "system", "part_log", config, "part_log", lazy_load); + trace_log = createSystemLog(global_context, "system", "trace_log", config, "trace_log", lazy_load); + text_log = createSystemLog(global_context, "system", "text_log", config, "text_log", lazy_load); + metric_log = createSystemLog(global_context, "system", "metric_log", config, "metric_log", lazy_load); if (metric_log) { diff --git a/src/Interpreters/SystemLog.h b/src/Interpreters/SystemLog.h index 9b6a23ecff6..ceffba67b50 100644 --- a/src/Interpreters/SystemLog.h +++ b/src/Interpreters/SystemLog.h @@ -117,7 +117,8 @@ public: const String & database_name_, const String & table_name_, const String & storage_def_, - size_t flush_interval_milliseconds_); + size_t flush_interval_milliseconds_, + bool lazy_load); /** Append a record into log. * Writing to table will be done asynchronously and in case of failure, record could be lost. diff --git a/src/Interpreters/TextLog.cpp b/src/Interpreters/TextLog.cpp index b5f1d987b91..8ecf6f029d2 100644 --- a/src/Interpreters/TextLog.cpp +++ b/src/Interpreters/TextLog.cpp @@ -72,9 +72,9 @@ void TextLogElement::appendToBlock(Block & block) const TextLog::TextLog(Context & context_, const String & database_name_, const String & table_name_, const String & storage_def_, - size_t flush_interval_milliseconds_) + size_t flush_interval_milliseconds_, bool lazy_load) : SystemLog(context_, database_name_, table_name_, - storage_def_, flush_interval_milliseconds_) + storage_def_, flush_interval_milliseconds_, lazy_load) { // SystemLog methods may write text logs, so we disable logging for the text // log table to avoid recursion. diff --git a/src/Interpreters/TextLog.h b/src/Interpreters/TextLog.h index 73c38429662..aaf64974e05 100644 --- a/src/Interpreters/TextLog.h +++ b/src/Interpreters/TextLog.h @@ -36,7 +36,8 @@ public: const String & database_name_, const String & table_name_, const String & storage_def_, - size_t flush_interval_milliseconds_); + size_t flush_interval_milliseconds_, + bool lazy_load); }; }