aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormonster <monster@ydb.tech>2023-04-10 14:43:05 +0300
committermonster <monster@ydb.tech>2023-04-10 14:43:05 +0300
commit96a67139545e4e9fe45eb11cd25c3cdc4e11cc36 (patch)
tree90e551f9208bf1b6f938fc065b1f9bf76267069d
parente667f88560ba27a376f893d209649db9afe1c076 (diff)
downloadydb-96a67139545e4e9fe45eb11cd25c3cdc4e11cc36.tar.gz
fix counters registry initialization
-rw-r--r--ydb/core/grpc_services/counters/counters.cpp15
-rw-r--r--ydb/core/grpc_services/counters/proxy_counters.cpp15
2 files changed, 18 insertions, 12 deletions
diff --git a/ydb/core/grpc_services/counters/counters.cpp b/ydb/core/grpc_services/counters/counters.cpp
index 9c18b9174cc..56dce58a157 100644
--- a/ydb/core/grpc_services/counters/counters.cpp
+++ b/ydb/core/grpc_services/counters/counters.cpp
@@ -483,13 +483,15 @@ class TGRpcDbCountersRegistry {
public:
void Initialize(TActorSystem* actorSystem) {
- if (Y_LIKELY(ActorSystem)) {
- return;
- }
- ActorSystem = actorSystem;
+ with_lock(InitLock) {
+ if (Y_LIKELY(ActorSystem)) {
+ return;
+ }
+ ActorSystem = actorSystem;
- auto callback = MakeIntrusive<TGRpcDbWatcherCallback>();
- DbWatcherActorId = ActorSystem->Register(NSysView::CreateDbWatcherActor(callback));
+ auto callback = MakeIntrusive<TGRpcDbWatcherCallback>();
+ DbWatcherActorId = ActorSystem->Register(NSysView::CreateDbWatcherActor(callback));
+ }
}
TYdbDbCounterBlockPtr GetCounterBlock(
@@ -529,6 +531,7 @@ private:
TConcurrentRWHashMap<TString, TIntrusivePtr<TGRpcDbCounters>, 256> DbCounters;
TActorSystem* ActorSystem = {};
TActorId DbWatcherActorId;
+ TMutex InitLock;
};
diff --git a/ydb/core/grpc_services/counters/proxy_counters.cpp b/ydb/core/grpc_services/counters/proxy_counters.cpp
index 652dd265a69..56dd763dfc4 100644
--- a/ydb/core/grpc_services/counters/proxy_counters.cpp
+++ b/ydb/core/grpc_services/counters/proxy_counters.cpp
@@ -194,6 +194,7 @@ class TGRpcProxyDbCountersRegistry {
TConcurrentRWHashMap<TString, TGRpcProxyDbCounters::TPtr, 256> DbCounters;
TActorSystem* ActorSystem = {};
TActorId DbWatcherActorId;
+ TMutex InitLock;
class TGRpcProxyDbWatcherCallback : public NKikimr::NSysView::TDbWatcherCallback {
public:
@@ -204,13 +205,15 @@ class TGRpcProxyDbCountersRegistry {
public:
void Initialize(TActorSystem* actorSystem) {
- if (Y_LIKELY(ActorSystem)) {
- return;
- }
- ActorSystem = actorSystem;
+ with_lock(InitLock) {
+ if (Y_LIKELY(ActorSystem)) {
+ return;
+ }
+ ActorSystem = actorSystem;
- auto callback = MakeIntrusive<TGRpcProxyDbWatcherCallback>();
- DbWatcherActorId = ActorSystem->Register(NSysView::CreateDbWatcherActor(callback));
+ auto callback = MakeIntrusive<TGRpcProxyDbWatcherCallback>();
+ DbWatcherActorId = ActorSystem->Register(NSysView::CreateDbWatcherActor(callback));
+ }
}
TGRpcProxyDbCounters::TPtr GetDbProxyCounters(const TString& database) {