dbms: fixed error [#METR-20301].

This commit is contained in:
Alexey Milovidov 2016-03-10 06:08:09 +03:00
parent 711e7c7245
commit b92b0660a7
4 changed files with 14 additions and 18 deletions

View File

@ -264,8 +264,7 @@ public:
*/
void resetCaches() const;
void initClusters();
Cluster & getCluster(const std::string & cluster_name);
const Cluster & getCluster(const std::string & cluster_name) const;
Poco::SharedPtr<Clusters> getClusters() const;
Compiler & getCompiler();

View File

@ -112,7 +112,7 @@ struct ContextShared
/// Кластеры для distributed таблиц
/// Создаются при создании Distributed таблиц, так как нужно дождаться пока будут выставлены Settings
Poco::SharedPtr<Clusters> clusters;
mutable Poco::SharedPtr<Clusters> clusters;
Poco::UUIDGenerator uuid_generator;
@ -892,17 +892,13 @@ UInt16 Context::getTCPPort() const
}
void Context::initClusters()
const Cluster & Context::getCluster(const std::string & cluster_name) const
{
Poco::ScopedLock<Poco::Mutex> lock(shared->mutex);
if (!shared->clusters)
shared->clusters = new Clusters(settings);
}
Cluster & Context::getCluster(const std::string & cluster_name)
{
if (!shared->clusters)
throw Poco::Exception("Clusters have not been initialized yet.");
{
Poco::ScopedLock<Poco::Mutex> lock(shared->mutex);
if (!shared->clusters)
shared->clusters = new Clusters(settings);
}
Clusters::Impl::iterator it = shared->clusters->impl.find(cluster_name);
if (it != shared->clusters->impl.end())
@ -913,8 +909,12 @@ Cluster & Context::getCluster(const std::string & cluster_name)
Poco::SharedPtr<Clusters> Context::getClusters() const
{
if (!shared->clusters)
throw Poco::Exception("Clusters have not been initialized yet.");
{
Poco::ScopedLock<Poco::Mutex> lock(shared->mutex);
if (!shared->clusters)
shared->clusters = new Clusters(settings);
}
return shared->clusters;
}

View File

@ -131,8 +131,6 @@ StoragePtr StorageDistributed::create(
const ASTPtr & sharding_key_,
const String & data_path_)
{
context_.initClusters();
return (new StorageDistributed{
name_, columns_,
materialized_columns_, alias_columns_, column_defaults_,

View File

@ -29,7 +29,6 @@ StorageSystemClusters::StorageSystemClusters(const std::string & name_, Context
StoragePtr StorageSystemClusters::create(const std::string & name_, Context & context_)
{
context_.initClusters();
return (new StorageSystemClusters{name_, context_})->thisPtr();
}