diff --git a/src/Common/Config/ConfigProcessor.cpp b/src/Common/Config/ConfigProcessor.cpp index 4e60eadd835..f4dd1cfa3fc 100644 --- a/src/Common/Config/ConfigProcessor.cpp +++ b/src/Common/Config/ConfigProcessor.cpp @@ -671,9 +671,11 @@ XMLDocumentPtr ConfigProcessor::parseConfig(const std::string & config_path) XMLDocumentPtr ConfigProcessor::processConfig( bool * has_zk_includes, zkutil::ZooKeeperNodeCache * zk_node_cache, - const zkutil::EventPtr & zk_changed_event) + const zkutil::EventPtr & zk_changed_event, + bool is_config_changed) { - LOG_DEBUG(log, "Processing configuration file '{}'.", path); + if (is_config_changed) + LOG_DEBUG(log, "Processing configuration file '{}'.", path); XMLDocumentPtr config; @@ -686,7 +688,8 @@ XMLDocumentPtr ConfigProcessor::processConfig( /// When we can use a config embedded in the binary. if (auto it = embedded_configs.find(path); it != embedded_configs.end()) { - LOG_DEBUG(log, "There is no file '{}', will use embedded config.", path); + if (is_config_changed) + LOG_DEBUG(log, "There is no file '{}', will use embedded config.", path); config = dom_parser.parseMemory(it->second.data(), it->second.size()); } else @@ -700,7 +703,8 @@ XMLDocumentPtr ConfigProcessor::processConfig( { try { - LOG_DEBUG(log, "Merging configuration file '{}'.", merge_file); + if (is_config_changed) + LOG_DEBUG(log, "Merging configuration file '{}'.", merge_file); XMLDocumentPtr with; with = parseConfig(merge_file); @@ -790,10 +794,10 @@ XMLDocumentPtr ConfigProcessor::processConfig( return config; } -ConfigProcessor::LoadedConfig ConfigProcessor::loadConfig(bool allow_zk_includes) +ConfigProcessor::LoadedConfig ConfigProcessor::loadConfig(bool allow_zk_includes, bool is_config_changed) { bool has_zk_includes; - XMLDocumentPtr config_xml = processConfig(&has_zk_includes); + XMLDocumentPtr config_xml = processConfig(&has_zk_includes, nullptr, nullptr, is_config_changed); if (has_zk_includes && !allow_zk_includes) throw Poco::Exception("Error while loading config '" + path + "': from_zk includes are not allowed!"); @@ -806,14 +810,15 @@ ConfigProcessor::LoadedConfig ConfigProcessor::loadConfig(bool allow_zk_includes ConfigProcessor::LoadedConfig ConfigProcessor::loadConfigWithZooKeeperIncludes( zkutil::ZooKeeperNodeCache & zk_node_cache, const zkutil::EventPtr & zk_changed_event, - bool fallback_to_preprocessed) + bool fallback_to_preprocessed, + bool is_config_changed) { XMLDocumentPtr config_xml; bool has_zk_includes; bool processed_successfully = false; try { - config_xml = processConfig(&has_zk_includes, &zk_node_cache, zk_changed_event); + config_xml = processConfig(&has_zk_includes, &zk_node_cache, zk_changed_event, is_config_changed); processed_successfully = true; } catch (const Poco::Exception & ex) diff --git a/src/Common/Config/ConfigProcessor.h b/src/Common/Config/ConfigProcessor.h index a9d1325b722..373e0809c5d 100644 --- a/src/Common/Config/ConfigProcessor.h +++ b/src/Common/Config/ConfigProcessor.h @@ -63,7 +63,8 @@ public: XMLDocumentPtr processConfig( bool * has_zk_includes = nullptr, zkutil::ZooKeeperNodeCache * zk_node_cache = nullptr, - const zkutil::EventPtr & zk_changed_event = nullptr); + const zkutil::EventPtr & zk_changed_event = nullptr, + bool is_config_changed = true); XMLDocumentPtr parseConfig(const std::string & config_path); @@ -88,14 +89,15 @@ public: /// If allow_zk_includes is true, expect that the configuration XML can contain from_zk nodes. /// If it is the case, set has_zk_includes to true and don't write config-preprocessed.xml, /// expecting that config would be reloaded with zookeeper later. - LoadedConfig loadConfig(bool allow_zk_includes = false); + LoadedConfig loadConfig(bool allow_zk_includes = false, bool is_config_changed = true); /// If fallback_to_preprocessed is true, then if KeeperException is thrown during config /// processing, load the configuration from the preprocessed file. LoadedConfig loadConfigWithZooKeeperIncludes( zkutil::ZooKeeperNodeCache & zk_node_cache, const zkutil::EventPtr & zk_changed_event, - bool fallback_to_preprocessed = false); + bool fallback_to_preprocessed = false, + bool is_config_changed = true); /// Save preprocessed config to specified directory. /// If preprocessed_dir is empty - calculate from loaded_config.path + /preprocessed_configs/ diff --git a/src/Common/Config/ConfigReloader.cpp b/src/Common/Config/ConfigReloader.cpp index 769a63c036b..a9a02ba6784 100644 --- a/src/Common/Config/ConfigReloader.cpp +++ b/src/Common/Config/ConfigReloader.cpp @@ -111,7 +111,8 @@ std::optional ConfigReloader::reloadIfNewer(bool std::lock_guard lock(reload_mutex); FilesChangesTracker new_files = getNewFileList(); - if (force || need_reload_from_zk || new_files.isDifferOrNewerThan(files)) + const bool is_config_changed = new_files.isDifferOrNewerThan(files); + if (force || need_reload_from_zk || is_config_changed) { ConfigProcessor config_processor(config_path); ConfigProcessor::LoadedConfig loaded_config; @@ -120,10 +121,10 @@ std::optional ConfigReloader::reloadIfNewer(bool try { - loaded_config = config_processor.loadConfig(/* allow_zk_includes = */ true); + loaded_config = config_processor.loadConfig(/* allow_zk_includes = */ true, is_config_changed); if (loaded_config.has_zk_includes) loaded_config = config_processor.loadConfigWithZooKeeperIncludes( - zk_node_cache, zk_changed_event, fallback_to_preprocessed); + zk_node_cache, zk_changed_event, fallback_to_preprocessed, is_config_changed); } catch (const Coordination::Exception & e) {