From 15ce3dc1124445c1edd7dde26ca998ed67816150 Mon Sep 17 00:00:00 2001 From: alesapin Date: Tue, 9 Feb 2021 11:24:39 +0300 Subject: [PATCH] Fix access control manager destruction order --- src/Interpreters/Context.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Interpreters/Context.cpp b/src/Interpreters/Context.cpp index 5c99d39dc2e..ca4a313da62 100644 --- a/src/Interpreters/Context.cpp +++ b/src/Interpreters/Context.cpp @@ -331,7 +331,7 @@ struct ContextShared mutable std::optional external_models_loader; String default_profile_name; /// Default profile name used for default values. String system_profile_name; /// Profile used by system processes - AccessControlManager access_control_manager; + std::unique_ptr access_control_manager; mutable UncompressedCachePtr uncompressed_cache; /// The cache of decompressed blocks. mutable MarkCachePtr mark_cache; /// Cache of marks in compressed files. ProcessList process_list; /// Executing queries at the moment. @@ -388,7 +388,8 @@ struct ContextShared Context::ConfigReloadCallback config_reload_callback; ContextShared() - : macros(std::make_unique()) + : access_control_manager(std::make_unique()) + , macros(std::make_unique()) { /// TODO: make it singleton (?) static std::atomic num_calls{0}; @@ -434,6 +435,7 @@ struct ContextShared /// Preemptive destruction is important, because these objects may have a refcount to ContextShared (cyclic reference). /// TODO: Get rid of this. + access_control_manager.reset(); system_logs.reset(); embedded_dictionaries.reset(); external_dictionaries_loader.reset(); @@ -640,7 +642,7 @@ void Context::setConfig(const ConfigurationPtr & config) { auto lock = getLock(); shared->config = config; - shared->access_control_manager.setExternalAuthenticatorsConfig(*shared->config); + shared->access_control_manager->setExternalAuthenticatorsConfig(*shared->config); } const Poco::Util::AbstractConfiguration & Context::getConfigRef() const @@ -652,25 +654,25 @@ const Poco::Util::AbstractConfiguration & Context::getConfigRef() const AccessControlManager & Context::getAccessControlManager() { - return shared->access_control_manager; + return *shared->access_control_manager; } const AccessControlManager & Context::getAccessControlManager() const { - return shared->access_control_manager; + return *shared->access_control_manager; } void Context::setExternalAuthenticatorsConfig(const Poco::Util::AbstractConfiguration & config) { auto lock = getLock(); - shared->access_control_manager.setExternalAuthenticatorsConfig(config); + shared->access_control_manager->setExternalAuthenticatorsConfig(config); } void Context::setUsersConfig(const ConfigurationPtr & config) { auto lock = getLock(); shared->users_config = config; - shared->access_control_manager.setUsersConfig(*shared->users_config); + shared->access_control_manager->setUsersConfig(*shared->users_config); } ConfigurationPtr Context::getUsersConfig()