10
10
#include < ydb/core/base/counters.h>
11
11
#include < ydb/core/base/path.h>
12
12
#include < ydb/core/quoter/public/quoter.h>
13
+ #include < ydb/core/persqueue/writer/source_id_encoding.h>
13
14
#include < ydb/core/protos/counters_pq.pb.h>
14
15
#include < ydb/core/protos/msgbus.pb.h>
15
16
#include < ydb/library/persqueue/topic_parser/topic_parser.h>
@@ -482,8 +483,6 @@ void TPartition::Handle(TEvents::TEvPoisonPill::TPtr&, const TActorContext& ctx)
482
483
483
484
Send (ReadQuotaTrackerActor, new TEvents::TEvPoisonPill ());
484
485
485
- SourceManager.PassAway ();
486
-
487
486
Die (ctx);
488
487
}
489
488
@@ -935,50 +934,33 @@ void TPartition::Handle(TEvPQ::TEvTxRollback::TPtr& ev, const TActorContext& ctx
935
934
}
936
935
937
936
void TPartition::Handle (TEvPQ::TEvGetMaxSeqNoRequest::TPtr& ev, const TActorContext& ctx) {
938
- SourceManager.EnsureSourceIds (ev->Get ()->SourceIds );
939
- MaxSeqNoRequests.emplace_back (ev);
940
- ProcessMaxSeqNoRequest (ctx);
941
- }
942
-
943
- void TPartition::ProcessMaxSeqNoRequest (const TActorContext& ctx) {
944
- PQ_LOG_T (" TPartition::ProcessMaxSeqNoRequest. Queue size: " << MaxSeqNoRequests.size ());
945
-
946
- while (!MaxSeqNoRequests.empty ()) {
947
- auto & ev = MaxSeqNoRequests.front ();
948
-
949
- auto response = MakeHolder<TEvPQ::TEvProxyResponse>(ev->Get ()->Cookie );
950
- NKikimrClient::TResponse& resp = *response->Response ;
951
-
952
- resp.SetStatus (NMsgBusProxy::MSTATUS_OK);
953
- resp.SetErrorCode (NPersQueue::NErrorCode::OK);
954
-
955
- auto & result = *resp.MutablePartitionResponse ()->MutableCmdGetMaxSeqNoResult ();
956
- for (const auto & sourceId : ev->Get ()->SourceIds ) {
957
- auto & protoInfo = *result.AddSourceIdInfo ();
958
- protoInfo.SetSourceId (sourceId);
937
+ auto response = MakeHolder<TEvPQ::TEvProxyResponse>(ev->Get ()->Cookie );
938
+ NKikimrClient::TResponse& resp = *response->Response ;
959
939
960
- auto info = SourceManager.Get (sourceId);
961
- if (!info) {
962
- PQ_LOG_D (" Stop MaxSeqNoRequest - scheduled a research. SourceId: " << sourceId);
963
- return ;
964
- }
965
- if (info.State == TSourceIdInfo::EState::Unknown) {
966
- continue ;
967
- }
940
+ resp.SetStatus (NMsgBusProxy::MSTATUS_OK);
941
+ resp.SetErrorCode (NPersQueue::NErrorCode::OK);
968
942
969
- Y_ABORT_UNLESS (info.Offset <= (ui64)Max<i64>(), " Offset is too big: %" PRIu64, info.Offset );
970
- Y_ABORT_UNLESS (info.SeqNo <= (ui64)Max<i64>(), " SeqNo is too big: %" PRIu64, info.SeqNo );
943
+ auto & result = *resp.MutablePartitionResponse ()->MutableCmdGetMaxSeqNoResult ();
944
+ for (const auto & sourceId : ev->Get ()->SourceIds ) {
945
+ auto & protoInfo = *result.AddSourceIdInfo ();
946
+ protoInfo.SetSourceId (sourceId);
971
947
972
- protoInfo.SetSeqNo (info.SeqNo );
973
- protoInfo.SetOffset (info.Offset );
974
- protoInfo.SetWriteTimestampMS (info.WriteTimestamp .MilliSeconds ());
975
- protoInfo.SetExplicit (info.Explicit );
976
- protoInfo.SetState (TSourceIdInfo::ConvertState (info.State ));
948
+ auto info = SourceManager.Get (sourceId);
949
+ if (info.State == TSourceIdInfo::EState::Unknown) {
950
+ continue ;
977
951
}
978
952
979
- ctx.Send (Tablet, response.Release ());
980
- MaxSeqNoRequests.pop_front ();
953
+ Y_ABORT_UNLESS (info.Offset <= (ui64)Max<i64>(), " Offset is too big: %" PRIu64, info.Offset );
954
+ Y_ABORT_UNLESS (info.SeqNo <= (ui64)Max<i64>(), " SeqNo is too big: %" PRIu64, info.SeqNo );
955
+
956
+ protoInfo.SetSeqNo (info.SeqNo );
957
+ protoInfo.SetOffset (info.Offset );
958
+ protoInfo.SetWriteTimestampMS (info.WriteTimestamp .MilliSeconds ());
959
+ protoInfo.SetExplicit (info.Explicit );
960
+ protoInfo.SetState (TSourceIdInfo::ConvertState (info.State ));
981
961
}
962
+
963
+ ctx.Send (Tablet, response.Release ());
982
964
}
983
965
984
966
void TPartition::Handle (TEvPQ::TEvBlobResponse::TPtr& ev, const TActorContext& ctx) {
@@ -2612,42 +2594,6 @@ void TPartition::Handle(TEvPQ::TEvSubDomainStatus::TPtr& ev, const TActorContext
2612
2594
}
2613
2595
}
2614
2596
2615
- void TPartition::Handle (TEvPQ::TEvSourceIdRequest::TPtr& ev, const TActorContext& ctx) {
2616
- auto & record = ev->Get ()->Record ;
2617
-
2618
- if (Partition != record.GetPartition ()) {
2619
- LOG_INFO_S (
2620
- ctx, NKikimrServices::PERSQUEUE,
2621
- " TEvSourceIdRequest for wrong partition " << record.GetPartition () << " ." <<
2622
- " Topic: \" " << TopicName () << " \" ." <<
2623
- " Partition: " << Partition << " ."
2624
- );
2625
- return ;
2626
- }
2627
-
2628
- auto & memoryStorage = SourceIdStorage.GetInMemorySourceIds ();
2629
-
2630
- auto response = MakeHolder<TEvPQ::TEvSourceIdResponse>();
2631
- for (auto & sourceId : record.GetSourceId ()) {
2632
- auto * s = response->Record .AddSource ();
2633
- s->SetId (sourceId);
2634
-
2635
- auto it = memoryStorage.find (sourceId);
2636
- if (it != memoryStorage.end ()) {
2637
- auto & info = it->second ;
2638
- s->SetState (Convert (info.State ));
2639
- s->SetSeqNo (info.SeqNo );
2640
- s->SetOffset (info.Offset );
2641
- s->SetExplicit (info.Explicit );
2642
- s->SetWriteTimestamp (info.WriteTimestamp .GetValue ());
2643
- } else {
2644
- s->SetState (NKikimrPQ::TEvSourceIdResponse::EState::TEvSourceIdResponse_EState_Unknown);
2645
- }
2646
- }
2647
-
2648
- Send (ev->Sender , response.Release ());
2649
- }
2650
-
2651
2597
void TPartition::Handle (TEvPQ::TEvCheckPartitionStatusRequest::TPtr& ev, const TActorContext& ctx) {
2652
2598
auto & record = ev->Get ()->Record ;
2653
2599
@@ -2664,6 +2610,13 @@ void TPartition::Handle(TEvPQ::TEvCheckPartitionStatusRequest::TPtr& ev, const T
2664
2610
auto response = MakeHolder<TEvPQ::TEvCheckPartitionStatusResponse>();
2665
2611
response->Record .SetStatus (PartitionConfig ? PartitionConfig->GetStatus () : NKikimrPQ::ETopicPartitionStatus::Active);
2666
2612
2613
+ if (record.HasSourceId ()) {
2614
+ auto sit = SourceIdStorage.GetInMemorySourceIds ().find (NSourceIdEncoding::EncodeSimple (record.GetSourceId ()));
2615
+ if (sit != SourceIdStorage.GetInMemorySourceIds ().end ()) {
2616
+ response->Record .SetSeqNo (sit->second .SeqNo );
2617
+ }
2618
+ }
2619
+
2667
2620
Send (ev->Sender , response.Release ());
2668
2621
}
2669
2622
0 commit comments