diff options
author | komels <komels@ydb.tech> | 2022-07-13 08:53:45 +0300 |
---|---|---|
committer | komels <komels@ydb.tech> | 2022-07-13 08:53:45 +0300 |
commit | 46ef7ab6f7c6d155901d911a6e0a6c4c3887596d (patch) | |
tree | 2de1912de5c3b55f589cee319663548482626789 | |
parent | ca41e150f41ddc5bd631a17f3857a0f10ee646dd (diff) | |
download | ydb-46ef7ab6f7c6d155901d911a6e0a6c4c3887596d.tar.gz |
Fix compatibility issues
3 files changed, 29 insertions, 9 deletions
diff --git a/ydb/library/persqueue/topic_parser/topic_parser.cpp b/ydb/library/persqueue/topic_parser/topic_parser.cpp index a7271ec043..fe7ff48264 100644 --- a/ydb/library/persqueue/topic_parser/topic_parser.cpp +++ b/ydb/library/persqueue/topic_parser/topic_parser.cpp @@ -130,12 +130,15 @@ TDiscoveryConverter::TDiscoveryConverter(bool firstClass, : PQPrefix(pqNormalizedPrefix) { auto name = pqTabletConfig.GetTopicName(); - if (name.empty()) { - name = pqTabletConfig.GetTopic(); - } - Y_VERIFY(!name.empty()); auto path = pqTabletConfig.GetTopicPath(); - if (path.empty()) { + if (name.empty()) { + Y_VERIFY(!pqTabletConfig.GetTopic().empty()); + Y_VERIFY(!path.empty()); + TStringBuf pathBuf(path), fst, snd; + auto res = pathBuf.TryRSplit("/", fst, snd); + Y_VERIFY(res); + name = snd; + } else if (path.empty()) { path = name; } if (!ydbDatabaseRootOverride.empty()) { @@ -464,9 +467,6 @@ void TDiscoveryConverter::BuildFromLegacyName(const TString& rootPrefix, bool fo } topicName = topic; } - if (!modernName.empty()) { - modernName << topicName; - } modernName << topicName; Y_VERIFY(!Dc.empty()); bool isMirrored = (!LocalDc.empty() && Dc != LocalDc); diff --git a/ydb/library/persqueue/topic_parser/ut/topic_names_converter_ut.cpp b/ydb/library/persqueue/topic_parser/ut/topic_names_converter_ut.cpp index d116f07115..0439c634d4 100644 --- a/ydb/library/persqueue/topic_parser/ut/topic_names_converter_ut.cpp +++ b/ydb/library/persqueue/topic_parser/ut/topic_names_converter_ut.cpp @@ -222,6 +222,26 @@ Y_UNIT_TEST_SUITE(TopicNameConverterTest) { } } + Y_UNIT_TEST(NoTopicName) { + TConverterTestWrapper wrapper(false, "/Root/PQ", "dc1"); + { + NKikimrPQ::TPQTabletConfig pqConfig; + pqConfig.SetTopic("topic"); + pqConfig.SetTopicPath("/Root/PQ/rt3.dc1--account@path--topic"); + pqConfig.SetFederationAccount("account"); + pqConfig.SetDC("dc1"); + pqConfig.SetLocalDC(true); + + wrapper.SetConverter(pqConfig); + + UNIT_ASSERT_VALUES_EQUAL(wrapper.TopicConverter->GetPrimaryPath(), "/Root/PQ/rt3.dc1--account@path--topic"); + UNIT_ASSERT_VALUES_EQUAL(wrapper.TopicConverter->GetModernName(), "path/topic"); + UNIT_ASSERT_VALUES_EQUAL(wrapper.TopicConverter->GetClientsideName(), "rt3.dc1--account@path--topic"); + UNIT_ASSERT_VALUES_EQUAL(wrapper.TopicConverter->GetFederationPath(), "account/path/topic"); + UNIT_ASSERT_VALUES_EQUAL(wrapper.TopicConverter->GetInternalName(), "rt3.dc1--account@path--topic"); + + } + } Y_UNIT_TEST(FirstClass) { TConverterTestWrapper wrapper(true, "", ""); diff --git a/ydb/services/persqueue_v1/actors/read_session_actor.ipp b/ydb/services/persqueue_v1/actors/read_session_actor.ipp index f5c77fa973..d2cd462597 100644 --- a/ydb/services/persqueue_v1/actors/read_session_actor.ipp +++ b/ydb/services/persqueue_v1/actors/read_session_actor.ipp @@ -661,7 +661,7 @@ void TReadSessionActor<UseMigrationProtocol>::Handle(typename TEvReadInit::TPtr& if (AppData(ctx)->PQConfig.GetTopicsAreFirstClassCitizen()) { ClientPath = init.consumer(); } else { - ClientPath = NPersQueue::NormalizeFullPath(NPersQueue::MakeConsumerPath(init.consumer())); + ClientPath = NPersQueue::StripLeadSlash(NPersQueue::MakeConsumerPath(init.consumer())); } TStringBuilder session; |