mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
fxs
This commit is contained in:
parent
cf8ddbc15e
commit
f08cb90fe3
@ -379,10 +379,17 @@ ReplicasInfo DatabaseReplicated::tryGetReplicasInfo(const ClusterPtr & cluster_)
|
||||
auto replica_active = zk_res[2 * global_replica_index + 1];
|
||||
auto replica_log_ptr = zk_res[2 * global_replica_index + 2];
|
||||
|
||||
UInt64 recovery_time = 0;
|
||||
{
|
||||
std::lock_guard lock(ddl_worker_mutex);
|
||||
if (replica.is_local && ddl_worker)
|
||||
recovery_time = ddl_worker->getCurrentInitializationDurationMs();
|
||||
}
|
||||
|
||||
replicas_info[global_replica_index] = ReplicaInfo{
|
||||
.is_active = replica_active.error == Coordination::Error::ZOK,
|
||||
.replication_lag = replica_log_ptr.error != Coordination::Error::ZNONODE ? std::optional(max_log_ptr - parse<UInt32>(replica_log_ptr.data)) : std::nullopt,
|
||||
.recovery_time = replica.is_local && ddl_worker ? ddl_worker->getCurrentInitializationDurationMs() : 0,
|
||||
.recovery_time = recovery_time,
|
||||
};
|
||||
|
||||
++global_replica_index;
|
||||
|
@ -70,8 +70,9 @@ void StorageSystemClusters::writeCluster(MutableColumns & res_columns, const std
|
||||
const auto & shards_info = cluster->getShardsInfo();
|
||||
const auto & addresses_with_failover = cluster->getShardsAddresses();
|
||||
|
||||
size_t recovery_time_column_idx = columns_mask.size() - 1, replication_lag_column_idx = columns_mask.size() - 2, is_active_column_idx = columns_mask.size() - 3;
|
||||
ReplicasInfo replicas_info;
|
||||
if (replicated)
|
||||
if (replicated && (columns_mask[recovery_time_column_idx] || columns_mask[replication_lag_column_idx] || columns_mask[is_active_column_idx]))
|
||||
replicas_info = replicated->tryGetReplicasInfo(name_and_cluster.second);
|
||||
|
||||
size_t replica_idx = 0;
|
||||
@ -122,6 +123,7 @@ void StorageSystemClusters::writeCluster(MutableColumns & res_columns, const std
|
||||
if (columns_mask[src_index++])
|
||||
res_columns[res_index++]->insert(address.database_replica_name);
|
||||
|
||||
/// make sure these three columns remain the last ones
|
||||
if (columns_mask[src_index++])
|
||||
{
|
||||
if (replicas_info.empty())
|
||||
@ -132,7 +134,6 @@ void StorageSystemClusters::writeCluster(MutableColumns & res_columns, const std
|
||||
res_columns[res_index++]->insert(replica_info.is_active);
|
||||
}
|
||||
}
|
||||
|
||||
if (columns_mask[src_index++])
|
||||
{
|
||||
if (replicas_info.empty())
|
||||
@ -146,7 +147,6 @@ void StorageSystemClusters::writeCluster(MutableColumns & res_columns, const std
|
||||
res_columns[res_index++]->insertDefault();
|
||||
}
|
||||
}
|
||||
|
||||
if (columns_mask[src_index++])
|
||||
{
|
||||
if (replicas_info.empty())
|
||||
|
Loading…
Reference in New Issue
Block a user