mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
Added metric about leadership [#METR-23272].
This commit is contained in:
parent
2dd43be6e6
commit
9a3deed1ea
@ -22,6 +22,7 @@
|
||||
M(SendExternalTables) \
|
||||
M(QueryThread) \
|
||||
M(ReadonlyReplica) \
|
||||
M(LeaderReplica) \
|
||||
M(MemoryTracking) \
|
||||
|
||||
|
||||
|
@ -16,6 +16,7 @@ namespace ProfileEvents
|
||||
namespace CurrentMetrics
|
||||
{
|
||||
extern const Metric ReadonlyReplica;
|
||||
extern const Metric LeaderReplica;
|
||||
}
|
||||
|
||||
|
||||
@ -137,6 +138,7 @@ void ReplicatedMergeTreeRestartingThread::run()
|
||||
if (storage.is_leader_node)
|
||||
{
|
||||
storage.is_leader_node = false;
|
||||
CurrentMetrics::sub(CurrentMetrics::LeaderReplica);
|
||||
if (storage.merge_selecting_thread.joinable())
|
||||
storage.merge_selecting_thread.join();
|
||||
|
||||
@ -201,7 +203,7 @@ bool ReplicatedMergeTreeRestartingThread::tryStartup()
|
||||
storage.zookeeper_path + "/leader_election",
|
||||
*storage.current_zookeeper, /// current_zookeeper живёт в течение времени жизни leader_election,
|
||||
/// так как до изменения current_zookeeper, объект leader_election уничтожается в методе partialShutdown.
|
||||
[this] { storage.becomeLeader(); },
|
||||
[this] { storage.becomeLeader(); CurrentMetrics::add(CurrentMetrics::LeaderReplica); },
|
||||
storage.replica_name);
|
||||
|
||||
/// Все, что выше, может бросить KeeperException, если что-то не так с ZK.
|
||||
@ -372,6 +374,7 @@ void ReplicatedMergeTreeRestartingThread::partialShutdown()
|
||||
if (storage.is_leader_node)
|
||||
{
|
||||
storage.is_leader_node = false;
|
||||
CurrentMetrics::sub(CurrentMetrics::LeaderReplica);
|
||||
if (storage.merge_selecting_thread.joinable())
|
||||
storage.merge_selecting_thread.join();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user