From 9b448481795f2f535ae4b6a287938b0e9b923eda Mon Sep 17 00:00:00 2001 From: Vitaly Baranov Date: Thu, 5 Dec 2019 02:53:06 +0300 Subject: [PATCH] SYSTEM RELOAD DICTIONARY now reloads a dictionary with update_field completely. --- dbms/src/Interpreters/ExternalLoader.cpp | 14 +++++++------- dbms/src/Interpreters/ExternalLoader.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dbms/src/Interpreters/ExternalLoader.cpp b/dbms/src/Interpreters/ExternalLoader.cpp index 10b8a02d660..be854fd7a1a 100644 --- a/dbms/src/Interpreters/ExternalLoader.cpp +++ b/dbms/src/Interpreters/ExternalLoader.cpp @@ -288,7 +288,7 @@ class ExternalLoader::LoadingDispatcher : private boost::noncopyable public: /// Called to load or reload an object. using CreateObjectFunction = std::function; + const String & /* name */, const ObjectConfig & /* config */, const LoadablePtr & /* previous_version */)>; LoadingDispatcher( const CreateObjectFunction & create_object_function_, @@ -791,14 +791,13 @@ private: std::pair loadOneObject( const String & name, const ObjectConfig & config, - bool config_changed, LoadablePtr previous_version) { LoadablePtr new_object; std::exception_ptr new_exception; try { - new_object = create_object(name, config, config_changed, previous_version); + new_object = create_object(name, config, previous_version); } catch (...) { @@ -919,7 +918,8 @@ private: /// Use `create_function` to perform the actual loading. /// It's much better to do it with `mutex` unlocked because the loading can take a lot of time /// and require access to other objects. - auto [new_object, new_exception] = loadOneObject(name, info->object_config, info->config_changed, info->object); + bool need_complete_loading = !info->object || info->config_changed || info->forced_to_reload; + auto [new_object, new_exception] = loadOneObject(name, info->object_config, need_complete_loading ? nullptr : info->object); if (!new_object && !new_exception) throw Exception("No object created and no exception raised for " + type_name, ErrorCodes::LOGICAL_ERROR); @@ -1076,7 +1076,7 @@ private: ExternalLoader::ExternalLoader(const String & type_name_, Logger * log) : config_files_reader(std::make_unique(type_name_, log)) , loading_dispatcher(std::make_unique( - std::bind(&ExternalLoader::createObject, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), + std::bind(&ExternalLoader::createObject, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), type_name_, log)) , periodic_updater(std::make_unique(*config_files_reader, *loading_dispatcher)) @@ -1226,9 +1226,9 @@ void ExternalLoader::addObjectAndLoad( ExternalLoader::LoadablePtr ExternalLoader::createObject( - const String & name, const ObjectConfig & config, bool config_changed, const LoadablePtr & previous_version) const + const String & name, const ObjectConfig & config, const LoadablePtr & previous_version) const { - if (previous_version && !config_changed) + if (previous_version) return previous_version->clone(); return create(name, *config.config, config.key_in_config); diff --git a/dbms/src/Interpreters/ExternalLoader.h b/dbms/src/Interpreters/ExternalLoader.h index 19570d897a5..16cdbd449f2 100644 --- a/dbms/src/Interpreters/ExternalLoader.h +++ b/dbms/src/Interpreters/ExternalLoader.h @@ -175,7 +175,7 @@ protected: private: struct ObjectConfig; - LoadablePtr createObject(const String & name, const ObjectConfig & config, bool config_changed, const LoadablePtr & previous_version) const; + LoadablePtr createObject(const String & name, const ObjectConfig & config, const LoadablePtr & previous_version) const; class LoadablesConfigReader; std::unique_ptr config_files_reader;