diff options
author | alexnick <alexnick@ydb.tech> | 2023-02-20 10:27:22 +0300 |
---|---|---|
committer | alexnick <alexnick@ydb.tech> | 2023-02-20 10:27:22 +0300 |
commit | fa753918f8b35fc12c188a7c0dc2d8420d3c2781 (patch) | |
tree | ddbb0074adc92bedb30cd81b26d8ff2d323bffd2 | |
parent | a6434be90a54e983eca0c6a616c48d740289b1f3 (diff) | |
download | ydb-fa753918f8b35fc12c188a7c0dc2d8420d3c2781.tar.gz |
fix for
progress
fix for tests
-rw-r--r-- | ydb/core/persqueue/partition.cpp | 2 | ||||
-rw-r--r-- | ydb/core/persqueue/user_info.cpp | 9 | ||||
-rw-r--r-- | ydb/core/persqueue/user_info.h | 5 | ||||
-rw-r--r-- | ydb/core/sys_view/ut_labeled.cpp | 84 | ||||
-rw-r--r-- | ydb/core/tablet/private/labeled_db_counters.cpp | 5 |
5 files changed, 55 insertions, 50 deletions
diff --git a/ydb/core/persqueue/partition.cpp b/ydb/core/persqueue/partition.cpp index c79fa14bbe..e2174e0873 100644 --- a/ydb/core/persqueue/partition.cpp +++ b/ydb/core/persqueue/partition.cpp @@ -816,7 +816,7 @@ void TPartition::Initialize(const TActorContext& ctx) { } if (AppData()->PQConfig.GetTopicsAreFirstClassCitizen()) { - PartitionCountersLabeled.Reset(new TPartitionLabeledCounters(TopicConverter->GetClientsideName(), + PartitionCountersLabeled.Reset(new TPartitionLabeledCounters(EscapeBadChars(TopicConverter->GetClientsideName()), Partition, Config.GetYdbDatabasePath())); } else { diff --git a/ydb/core/persqueue/user_info.cpp b/ydb/core/persqueue/user_info.cpp index a1b10ede2f..89e63abb72 100644 --- a/ydb/core/persqueue/user_info.cpp +++ b/ydb/core/persqueue/user_info.cpp @@ -3,6 +3,15 @@ namespace NKikimr { namespace NPQ { +TString EscapeBadChars(const TString& str) { + TStringBuilder res; + for (ui32 i = 0; i < str.size();++i) { + if (str[i] == '|') res << '/'; + else res << str[i]; + } + return res; +} + namespace NDeprecatedUserData { TBuffer Serialize(ui64 offset, ui32 gen, ui32 step, const TString& session) { TBuffer data; diff --git a/ydb/core/persqueue/user_info.h b/ydb/core/persqueue/user_info.h index e60b13b79f..034edacdc2 100644 --- a/ydb/core/persqueue/user_info.h +++ b/ydb/core/persqueue/user_info.h @@ -21,6 +21,9 @@ namespace NKikimr { namespace NPQ { + +TString EscapeBadChars(const TString& str); + namespace NDeprecatedUserData { // [offset:64bit][generation:32bit][step:32bit][session:other bytes] TBuffer Serialize(ui64 offset, ui32 gen, ui32 step, const TString& session); @@ -200,7 +203,7 @@ struct TUserInfo { if (AppData(ctx)->Counters) { if (AppData()->PQConfig.GetTopicsAreFirstClassCitizen()) { LabeledCounters.Reset(new TUserLabeledCounters( - user + "||" + topicConverter->GetClientsideName(), partition, dbPath)); + EscapeBadChars(user) + "||" + EscapeBadChars(topicConverter->GetClientsideName()), partition, dbPath)); SetupStreamCounters(streamCountersSubgroup); } else { diff --git a/ydb/core/sys_view/ut_labeled.cpp b/ydb/core/sys_view/ut_labeled.cpp index 5a98089f87..9b98637823 100644 --- a/ydb/core/sys_view/ut_labeled.cpp +++ b/ydb/core/sys_view/ut_labeled.cpp @@ -24,7 +24,7 @@ void CreateDatabase(TTestEnv& env, const TString& databaseName) { UNIT_ASSERT_VALUES_EQUAL(NMsgBusProxy::MSTATUS_OK, env.GetClient().CreateExtSubdomain("/Root", subdomain)); - env.GetTenants().Run("/Root/" + databaseName, 1); + env.GetTenants().Run("/Root/" + databaseName, 2); auto subdomainSettings = GetSubDomainDefaultSettings(databaseName, env.GetPools()); subdomainSettings.SetExternalSysViewProcessor(true); @@ -51,6 +51,7 @@ bool CheckLabeledCounters(::NMonitoring::TDynamicCounterPtr databaseGroup, const std::function<bool(::NMonitoring::TDynamicCounterPtr)> particularCountersCheck) { bool isGood{true}; Y_UNUSED(dbId); + auto topicGroup = databaseGroup ->GetSubgroup("cloud_id", "") ->GetSubgroup("folder_id", "") @@ -122,6 +123,41 @@ Y_UNIT_TEST_SUITE(LabeledDbCounters) { GetCounters(env, databaseName, databasePath, check); } + + Y_UNIT_TEST(OneTabletRemoveCounters) { + TTestEnv env(1, 2, 0, 1, true); + const TString databaseName = NPQ::TTabletPreparationParameters().databaseId; + const TString databasePath = NPQ::TTabletPreparationParameters().databasePath; + auto edge = env.GetServer().GetRuntime()->AllocateEdgeActor(); + auto checkExists = [](::NMonitoring::TDynamicCounterPtr topicGroup) { + bool isGood{true}; + auto consumerGroup = topicGroup->FindSubgroup("consumer", "consumer"); + if (!consumerGroup) + return false; + isGood &= CheckCounter(consumerGroup, "topic.partition.alive_count", partitionsN, false); + + return isGood; + }; + + CreateDatabase(env, databaseName); + NPQ::PQTabletPrepare({.partitions=partitionsN}, {{"consumer", false}}, *env.GetServer().GetRuntime(), + env.GetPqTabletIds()[0], edge); + GetCounters(env, databaseName, databasePath, checkExists); + + NPQ::PQTabletPrepare({.partitions=partitionsN}, {}, *env.GetServer().GetRuntime(), + env.GetPqTabletIds()[0], edge); + //TODO: fix clearence of groups in sys view service/processor +/* auto checkNotExists = [](::NMonitoring::TDynamicCounterPtr topicGroup) { + auto consumerGroup = topicGroup->FindSubgroup("consumer", "consumer"); + return !consumerGroup; + }; + + GetCounters(env, databaseName, databasePath, checkNotExists); +*/ + + } + + Y_UNIT_TEST(OneTabletRestart) { TTestEnv env(1, 2, 0, 1, true); const TString databaseName = NPQ::TTabletPreparationParameters().databaseId; @@ -232,52 +268,6 @@ Y_UNIT_TEST_SUITE(LabeledDbCounters) { GetCounters(env, databaseName, databasePath, check); } } - - Y_UNIT_TEST(TwoTabletsDisconnectOneNode) { - TTestEnv env(1, 2, 0, 2, true); - const TString databaseName = NPQ::TTabletPreparationParameters().databaseId; - const TString databasePath = NPQ::TTabletPreparationParameters().databasePath; - auto edge = env.GetServer().GetRuntime()->AllocateEdgeActor(); - CreateDatabase(env, databaseName); - for (auto& tbId : env.GetPqTabletIds()) { - NPQ::PQTabletPrepare({.partitions=partitionsN}, {}, *env.GetServer().GetRuntime(), - tbId, edge); - } - - { - auto check = [](::NMonitoring::TDynamicCounterPtr topicGroup) { - bool isGood{true}; - - isGood &= CheckCounter(topicGroup, "topic.partition.alive_count", partitionsN*2, false); - isGood &= CheckCounter(topicGroup, "topic.partition.write.speed_limit_bytes_per_second", 50'000'000, false); - isGood &= CheckCounter(topicGroup, "topic.producers_count", 0, false); - - return isGood; - }; - - GetCounters(env, databaseName, databasePath, check); - } - - for (ui32 i = 0; i < env.GetServer().StaticNodes() + env.GetServer().DynamicNodes(); i++) { - env.GetClient().MarkNodeInHive(env.GetServer().GetRuntime(), i, false); - if (i > 0) { - env.GetServer().GetRuntime()->DisconnectNodes(0, i, false); - env.GetServer().GetRuntime()->DisconnectNodes(i, 0, false); - } - } - - { - auto check = [](::NMonitoring::TDynamicCounterPtr topicGroup) { - bool isGood{true}; - - isGood &= CheckCounter(topicGroup, "topic.partition.alive_count", partitionsN, false); - isGood &= CheckCounter(topicGroup, "topic.partition.total_count", partitionsN, false); - return isGood; - }; - - GetCounters(env, databaseName, databasePath, check); - } - } } } // NSysView diff --git a/ydb/core/tablet/private/labeled_db_counters.cpp b/ydb/core/tablet/private/labeled_db_counters.cpp index 0cd1ffba57..ea338691f1 100644 --- a/ydb/core/tablet/private/labeled_db_counters.cpp +++ b/ydb/core/tablet/private/labeled_db_counters.cpp @@ -17,7 +17,10 @@ TPQCounters::TPQCounters(NMonitoring::TDynamicCounterPtr counters) { void TPQCounters::Apply(ui64 tabletId, const NKikimr::TTabletLabeledCountersBase* labeledCounters) { const TString group = labeledCounters->GetGroup(); TString groupNames; - + if (labeledCounters->GetDrop()) { + LabeledCountersByGroup.Erase(group); + return; + } if (!LabeledCountersByGroup.Has(group)) { TVector<TString> rr; StringSplitter(group).Split('|').Collect(&rr); |