mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
fix "incorrect replica identifier"
This commit is contained in:
parent
e2c1d06032
commit
629690c32b
@ -126,13 +126,30 @@ std::pair<String, String> DatabaseReplicated::parseFullReplicaName(const String
|
||||
return {shard, replica};
|
||||
}
|
||||
|
||||
ClusterPtr DatabaseReplicated::getCluster() const
|
||||
ClusterPtr DatabaseReplicated::tryGetCluster() const
|
||||
{
|
||||
std::lock_guard lock{mutex};
|
||||
if (cluster)
|
||||
return cluster;
|
||||
|
||||
cluster = getClusterImpl();
|
||||
/// Database is probably not created or not initialized yet, it's ok to return nullptr
|
||||
if (is_readonly)
|
||||
return cluster;
|
||||
|
||||
try
|
||||
{
|
||||
/// A quick fix for stateless tests with DatabaseReplicated. Its ZK
|
||||
/// node can be destroyed at any time. If another test lists
|
||||
/// system.clusters to get client command line suggestions, it will
|
||||
/// get an error when trying to get the info about DB from ZK.
|
||||
/// Just ignore these inaccessible databases. A good example of a
|
||||
/// failing test is `01526_client_start_and_exit`.
|
||||
cluster = getClusterImpl();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(log);
|
||||
}
|
||||
return cluster;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
const String & getZooKeeperPath() const { return zookeeper_path; }
|
||||
|
||||
/// Returns cluster consisting of database replicas
|
||||
ClusterPtr getCluster() const;
|
||||
ClusterPtr tryGetCluster() const;
|
||||
|
||||
void drop(ContextPtr /*context*/) override;
|
||||
|
||||
|
@ -469,7 +469,7 @@ void ZooKeeperMetadataTransaction::commit()
|
||||
ClusterPtr tryGetReplicatedDatabaseCluster(const String & cluster_name)
|
||||
{
|
||||
if (const auto * replicated_db = dynamic_cast<const DatabaseReplicated *>(DatabaseCatalog::instance().tryGetDatabase(cluster_name).get()))
|
||||
return replicated_db->getCluster();
|
||||
return replicated_db->tryGetCluster();
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -39,20 +39,8 @@ void StorageSystemClusters::fillData(MutableColumns & res_columns, ContextPtr co
|
||||
{
|
||||
if (const auto * replicated = typeid_cast<const DatabaseReplicated *>(name_and_database.second.get()))
|
||||
{
|
||||
// A quick fix for stateless tests with DatabaseReplicated. Its ZK
|
||||
// node can be destroyed at any time. If another test lists
|
||||
// system.clusters to get client command line suggestions, it will
|
||||
// get an error when trying to get the info about DB from ZK.
|
||||
// Just ignore these inaccessible databases. A good example of a
|
||||
// failing test is `01526_client_start_and_exit`.
|
||||
try
|
||||
{
|
||||
writeCluster(res_columns, {name_and_database.first, replicated->getCluster()});
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
if (auto database_cluster = replicated->tryGetCluster())
|
||||
writeCluster(res_columns, {name_and_database.first, database_cluster});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user