aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Storages/MergeTree/ReplicatedMergeTreeAttachThread.cpp
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2023-11-30 09:51:21 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2023-11-30 10:08:27 +0300
commit468826fff1465595d80da778532b253674e1e1c3 (patch)
tree55979be8d30470ec46d845bb5d2270a11847d186 /contrib/clickhouse/src/Storages/MergeTree/ReplicatedMergeTreeAttachThread.cpp
parent98ecc8deb38724114150e3758b86eb79dc9f12a9 (diff)
downloadydb-468826fff1465595d80da778532b253674e1e1c3.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/clickhouse/src/Storages/MergeTree/ReplicatedMergeTreeAttachThread.cpp')
-rw-r--r--contrib/clickhouse/src/Storages/MergeTree/ReplicatedMergeTreeAttachThread.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/contrib/clickhouse/src/Storages/MergeTree/ReplicatedMergeTreeAttachThread.cpp b/contrib/clickhouse/src/Storages/MergeTree/ReplicatedMergeTreeAttachThread.cpp
index 65cf8bbce7..927df3c50e 100644
--- a/contrib/clickhouse/src/Storages/MergeTree/ReplicatedMergeTreeAttachThread.cpp
+++ b/contrib/clickhouse/src/Storages/MergeTree/ReplicatedMergeTreeAttachThread.cpp
@@ -2,6 +2,11 @@
#include <Storages/StorageReplicatedMergeTree.h>
#include <Common/ZooKeeper/IKeeper.h>
+namespace CurrentMetrics
+{
+ extern const Metric ReadonlyReplica;
+}
+
namespace DB
{
@@ -67,6 +72,9 @@ void ReplicatedMergeTreeAttachThread::run()
LOG_ERROR(log, "Initialization failed, table will remain readonly. Error: {}", getCurrentExceptionMessage(/* with_stacktrace */ true));
storage.initialization_done = true;
}
+
+ if (!std::exchange(storage.is_readonly_metric_set, true))
+ CurrentMetrics::add(CurrentMetrics::ReadonlyReplica);
}
if (!first_try_done.exchange(true))
@@ -74,6 +82,12 @@ void ReplicatedMergeTreeAttachThread::run()
if (shutdown_called)
{
+ if (std::exchange(storage.is_readonly_metric_set, false))
+ {
+ CurrentMetrics::sub(CurrentMetrics::ReadonlyReplica);
+ chassert(CurrentMetrics::get(CurrentMetrics::ReadonlyReplica) >= 0);
+ }
+
LOG_WARNING(log, "Shutdown called, cancelling initialization");
return;
}