mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-13 09:52:38 +00:00
Read config_reload_sync_zookeeper only from the server config
Previously it had been read from each config, i.e. for users it should be defined in users.xml/yaml. Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
parent
c9291949ba
commit
86fb8f647f
@ -579,6 +579,7 @@ try
|
||||
getKeeperPath(config()),
|
||||
std::move(unused_cache),
|
||||
unused_event,
|
||||
config().getBool("config_reload_sync_zookeeper", false),
|
||||
[&](ConfigurationPtr config, bool /* initial_loading */)
|
||||
{
|
||||
updateLevels(*config, logger());
|
||||
|
@ -284,6 +284,7 @@ namespace ServerSetting
|
||||
extern const ServerSettingsString primary_index_cache_policy;
|
||||
extern const ServerSettingsUInt64 primary_index_cache_size;
|
||||
extern const ServerSettingsDouble primary_index_cache_size_ratio;
|
||||
extern const ServerSettingsBool config_reload_sync_zookeeper;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1245,14 +1246,13 @@ try
|
||||
if (loaded_config.has_zk_includes)
|
||||
{
|
||||
auto old_configuration = loaded_config.configuration;
|
||||
bool config_reload_sync_zookeeper = old_configuration->getBool("config_reload_sync_zookeeper", false);
|
||||
ConfigProcessor config_processor(config_path);
|
||||
loaded_config = config_processor.loadConfigWithZooKeeperIncludes(
|
||||
main_config_zk_node_cache,
|
||||
main_config_zk_changed_event,
|
||||
/*fallback_to_preprocessed =*/ true,
|
||||
/*is_config_changed=*/ true,
|
||||
config_reload_sync_zookeeper);
|
||||
server_settings[ServerSetting::config_reload_sync_zookeeper]);
|
||||
config_processor.savePreprocessedConfig(loaded_config, path_str);
|
||||
config().removeConfiguration(old_configuration.get());
|
||||
config().add(loaded_config.configuration.duplicate(), PRIO_DEFAULT, false);
|
||||
@ -1686,6 +1686,7 @@ try
|
||||
config().getString("path", DBMS_DEFAULT_PATH),
|
||||
std::move(main_config_zk_node_cache),
|
||||
main_config_zk_changed_event,
|
||||
server_settings[ServerSetting::config_reload_sync_zookeeper],
|
||||
[&, config_file = config().getString("config-file", "config.xml")](ConfigurationPtr config, bool initial_loading)
|
||||
{
|
||||
if (!initial_loading)
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <Common/StringUtils.h>
|
||||
#include <Common/quoteString.h>
|
||||
#include <Common/transformEndianness.h>
|
||||
#include <Core/ServerSettings.h>
|
||||
#include <Core/Settings.h>
|
||||
#include <Interpreters/executeQuery.h>
|
||||
#include <Parsers/Access/ASTGrantQuery.h>
|
||||
@ -42,6 +43,11 @@ namespace ErrorCodes
|
||||
extern const int SUPPORT_IS_DISABLED;
|
||||
}
|
||||
|
||||
namespace ServerSetting
|
||||
{
|
||||
extern const ServerSettingsBool config_reload_sync_zookeeper;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -880,15 +886,21 @@ void UsersConfigAccessStorage::load(
|
||||
const String & preprocessed_dir,
|
||||
const zkutil::GetZooKeeper & get_zookeeper_function)
|
||||
{
|
||||
bool sync_zookeeper = false;
|
||||
if (auto context = Context::getGlobalContextInstance())
|
||||
sync_zookeeper = context->getServerSettings()[ServerSetting::config_reload_sync_zookeeper];
|
||||
|
||||
std::lock_guard lock{load_mutex};
|
||||
path = std::filesystem::path{users_config_path}.lexically_normal();
|
||||
config_reloader.reset();
|
||||
|
||||
config_reloader = std::make_unique<ConfigReloader>(
|
||||
users_config_path,
|
||||
std::vector{{include_from_path}},
|
||||
preprocessed_dir,
|
||||
zkutil::ZooKeeperNodeCache(get_zookeeper_function),
|
||||
std::make_shared<Poco::Event>(),
|
||||
sync_zookeeper,
|
||||
[&](Poco::AutoPtr<Poco::Util::AbstractConfiguration> new_config, bool /*initial_loading*/)
|
||||
{
|
||||
Settings::checkNoSettingNamesAtTopLevel(*new_config, users_config_path);
|
||||
|
@ -1,11 +1,10 @@
|
||||
#include "ConfigReloader.h"
|
||||
|
||||
#include <Poco/Util/Application.h>
|
||||
#include <Common/logger_useful.h>
|
||||
#include <Common/setThreadName.h>
|
||||
#include "ConfigProcessor.h"
|
||||
#include <filesystem>
|
||||
#include <Common/Config/ConfigReloader.h>
|
||||
#include <Common/Config/ConfigProcessor.h>
|
||||
#include <Common/filesystemHelpers.h>
|
||||
#include <filesystem>
|
||||
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
@ -19,6 +18,7 @@ ConfigReloader::ConfigReloader(
|
||||
const std::string & preprocessed_dir_,
|
||||
zkutil::ZooKeeperNodeCache && zk_node_cache_,
|
||||
const zkutil::EventPtr & zk_changed_event_,
|
||||
bool sync_zookeeper_,
|
||||
Updater && updater_)
|
||||
: config_path(config_path_)
|
||||
, extra_paths(extra_paths_)
|
||||
@ -26,6 +26,7 @@ ConfigReloader::ConfigReloader(
|
||||
, zk_node_cache(std::move(zk_node_cache_))
|
||||
, zk_changed_event(zk_changed_event_)
|
||||
, updater(std::move(updater_))
|
||||
, sync_zookeeper(sync_zookeeper_)
|
||||
{
|
||||
auto config = reloadIfNewer(/* force = */ true, /* throw_on_error = */ true, /* fallback_to_preprocessed = */ true, /* initial_loading = */ true);
|
||||
|
||||
@ -34,7 +35,7 @@ ConfigReloader::ConfigReloader(
|
||||
else
|
||||
reload_interval = DEFAULT_RELOAD_INTERVAL;
|
||||
|
||||
LOG_TRACE(log, "Config reload interval set to {}ms", reload_interval.count());
|
||||
LOG_TRACE(log, "Config reload interval set to {}ms (sync_zookeeper: {})", reload_interval.count(), sync_zookeeper);
|
||||
}
|
||||
|
||||
void ConfigReloader::start()
|
||||
@ -123,15 +124,12 @@ std::optional<ConfigProcessor::LoadedConfig> ConfigReloader::reloadIfNewer(bool
|
||||
{
|
||||
loaded_config = config_processor.loadConfig(/* allow_zk_includes = */ true, is_config_changed);
|
||||
if (loaded_config.has_zk_includes)
|
||||
{
|
||||
bool config_reload_sync_zookeeper = loaded_config.configuration->getBool("config_reload_sync_zookeeper", false);
|
||||
loaded_config = config_processor.loadConfigWithZooKeeperIncludes(
|
||||
zk_node_cache,
|
||||
zk_changed_event,
|
||||
fallback_to_preprocessed,
|
||||
is_config_changed,
|
||||
config_reload_sync_zookeeper);
|
||||
}
|
||||
sync_zookeeper);
|
||||
}
|
||||
catch (const Coordination::Exception & e)
|
||||
{
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
const std::string & preprocessed_dir,
|
||||
zkutil::ZooKeeperNodeCache && zk_node_cache,
|
||||
const zkutil::EventPtr & zk_changed_event,
|
||||
bool sync_zookeeper_,
|
||||
Updater && updater);
|
||||
|
||||
~ConfigReloader();
|
||||
@ -86,6 +87,8 @@ private:
|
||||
|
||||
/// Locked inside reloadIfNewer.
|
||||
std::mutex reload_mutex;
|
||||
|
||||
bool sync_zookeeper;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user