diff options
author | mokhotskii <mokhotskii@ydb.tech> | 2023-02-07 15:54:37 +0300 |
---|---|---|
committer | mokhotskii <mokhotskii@ydb.tech> | 2023-02-07 15:54:37 +0300 |
commit | d9c697fb69f8e6c5712b15ce795823ddf2a045ea (patch) | |
tree | 762e84356d2b253072134e6bd2eadc0b99748100 | |
parent | 37151df3c62268ba29778745a30e59c0a5f5b8fa (diff) | |
download | ydb-d9c697fb69f8e6c5712b15ce795823ddf2a045ea.tar.gz |
Fix crash on access to static HashMap
Fix crash on access to static HashMap
-rw-r--r-- | ydb/core/tablet/private/labeled_db_counters.cpp | 12 | ||||
-rw-r--r-- | ydb/core/tablet/private/labeled_db_counters.h | 29 |
2 files changed, 28 insertions, 13 deletions
diff --git a/ydb/core/tablet/private/labeled_db_counters.cpp b/ydb/core/tablet/private/labeled_db_counters.cpp index feb0d41a1f..0cd1ffba57 100644 --- a/ydb/core/tablet/private/labeled_db_counters.cpp +++ b/ydb/core/tablet/private/labeled_db_counters.cpp @@ -10,8 +10,6 @@ namespace NKikimr::NPrivate { ** class TPQCounters */ -THashMap<TString, TAutoPtr<TAggregatedLabeledCounters>> TPQCounters::LabeledCountersByGroupReference = {}; - TPQCounters::TPQCounters(NMonitoring::TDynamicCounterPtr counters) { Group = counters; } @@ -28,12 +26,6 @@ void TPQCounters::Apply(ui64 tabletId, const NKikimr::TTabletLabeledCountersBase groupNames += '|'; groupNames += labeledCounters->GetGroupName(i); } - - if (!LabeledCountersByGroupReference.contains(groupNames)) { - LabeledCountersByGroupReference.emplace(groupNames, new TAggregatedLabeledCounters( - labeledCounters->GetCounters().Size(), labeledCounters->GetAggrFuncs(), - labeledCounters->GetNames(), labeledCounters->GetTypes(), groupNames)); - } } auto& el = LabeledCountersByGroup.InsertIfAbsent(group, new TAggregatedLabeledCounters( @@ -109,8 +101,8 @@ void TDbLabeledCounters::FromProto(NKikimr::NSysView::TDbServiceCounters& counte } const TString groupNamesStr = (groups.size() == 3) ? "client|important|topic" : "topic"; - LabeledCountersByGroupReference[groupNamesStr]->FromProto(countersGroup, - proto.GetAggregatedPerTablets()); + LabeledCountersByGroupReference.at(groupNamesStr)->FromProto(countersGroup, + proto.GetAggregatedPerTablets()); } } diff --git a/ydb/core/tablet/private/labeled_db_counters.h b/ydb/core/tablet/private/labeled_db_counters.h index 8359381c73..deb8c6e2ec 100644 --- a/ydb/core/tablet/private/labeled_db_counters.h +++ b/ydb/core/tablet/private/labeled_db_counters.h @@ -1,7 +1,9 @@ #pragma once -#include <ydb/core/sys_view/service/db_counters.h> +#include <ydb/core/protos/counters_pq.pb.h> #include <ydb/core/tablet/labeled_db_counters.h> +#include <ydb/core/tablet/tablet_counters_protobuf.h> +#include <ydb/core/sys_view/service/db_counters.h> #include <ydb/core/util/concurrent_rw_hash.h> #include "aggregated_counters.h" @@ -9,7 +11,6 @@ namespace NKikimr::NPrivate { - class TPQCounters : public ILabeledCounters { protected: TConcurrentRWHashMap<TString, TAutoPtr<TAggregatedLabeledCounters>, 256> LabeledCountersByGroup; @@ -23,7 +24,29 @@ public: void Apply(ui64 tabletID, const NKikimr::TTabletLabeledCountersBase* labeledCounters) override; void ForgetTablet(ui64 tabletID) override; - static THashMap<TString, TAutoPtr<TAggregatedLabeledCounters>> LabeledCountersByGroupReference; + const TProtobufTabletLabeledCounters<NKikimr::NPQ::EPartitionLabeledCounters_descriptor> + PartitionCounters{"topic_name", 1, "/Root/Db"}; + const TProtobufTabletLabeledCounters<NKikimr::NPQ::EClientLabeledCounters_descriptor> + UserCounters{"client_name||topic_name", 1, "/Root/Db"}; + const THashMap<TString, TAutoPtr<TAggregatedLabeledCounters>> LabeledCountersByGroupReference = { + { + "topic", + new TAggregatedLabeledCounters(PartitionCounters.GetCounters().Size(), + PartitionCounters.GetAggrFuncs(), + PartitionCounters.GetNames(), + PartitionCounters.GetTypes(), + "topic") + }, + { + "client|important|topic", + new TAggregatedLabeledCounters(UserCounters.GetCounters().Size(), + UserCounters.GetAggrFuncs(), + UserCounters.GetNames(), + UserCounters.GetTypes(), + "client|important|topic") + }, + {} + }; }; class TDbLabeledCounters : public TPQCounters, public NSysView::IDbCounters { |