@@ -710,6 +710,9 @@ TString TRowDispatcher::GetInternalState() {
710
710
}
711
711
712
712
for (auto & [readActorId, consumer] : sessionInfo.Consumers ) {
713
+ if (!consumer->Partitions .contains (key.PartitionId )) {
714
+ continue ;
715
+ }
713
716
const auto & partition = consumer->Partitions [key.PartitionId ];
714
717
str << " " << consumer->QueryId << " " << LeftPad (readActorId, 32 ) << " unread bytes "
715
718
<< toHuman (consumer->Stat .QueuedBytes ) << " (" << leftPad (consumer->Stat .QueuedRows ) << " rows) "
@@ -913,7 +916,7 @@ void TRowDispatcher::Handle(NFq::TEvRowDispatcher::TEvStopSession::TPtr& ev) {
913
916
}
914
917
915
918
LWPROBE (StopSession, ev->Sender .ToString (), it->second ->QueryId , ev->Get ()->Record .ByteSizeLong ());
916
- LOG_ROW_DISPATCHER_DEBUG (" Received TEvStopSession, topicPath " << ev->Get ()->Record .GetSource ().GetTopicPath () << " query id " << it->second ->QueryId );
919
+ LOG_ROW_DISPATCHER_DEBUG (" Received TEvStopSession from " << ev-> Sender << " topic " << ev->Get ()->Record .GetSource ().GetTopicPath () << " query id " << it->second ->QueryId );
917
920
if (!CheckSession (it->second , ev)) {
918
921
return ;
919
922
}
@@ -942,8 +945,11 @@ void TRowDispatcher::DeleteConsumer(NActors::TActorId readActorId) {
942
945
partitionId};
943
946
TTopicSessionInfo& topicSessionInfo = TopicSessions[topicKey];
944
947
TSessionInfo& sessionInfo = topicSessionInfo.Sessions [partition.TopicSessionId ];
945
- Y_ENSURE (sessionInfo.Consumers .count (consumer->ReadActorId ));
946
- sessionInfo.Consumers .erase (consumer->ReadActorId );
948
+ if (!sessionInfo.Consumers .contains (consumer->ReadActorId )) {
949
+ LOG_ROW_DISPATCHER_ERROR (" Wrong readActorId " << consumer->ReadActorId << " , no such consumer" );
950
+ } else {
951
+ sessionInfo.Consumers .erase (consumer->ReadActorId );
952
+ }
947
953
if (sessionInfo.Consumers .empty ()) {
948
954
LOG_ROW_DISPATCHER_DEBUG (" Session is not used, sent TEvPoisonPill to " << partition.TopicSessionId );
949
955
topicSessionInfo.Sessions .erase (partition.TopicSessionId );
@@ -989,10 +995,15 @@ void TRowDispatcher::Handle(NFq::TEvRowDispatcher::TEvNewDataArrived::TPtr& ev)
989
995
}
990
996
LWPROBE (NewDataArrived, ev->Sender .ToString (), ev->Get ()->ReadActorId .ToString (), it->second ->QueryId , it->second ->Generation , ev->Get ()->Record .ByteSizeLong ());
991
997
LOG_ROW_DISPATCHER_TRACE (" Forward TEvNewDataArrived from " << ev->Sender << " to " << ev->Get ()->ReadActorId << " query id " << it->second ->QueryId );
992
- auto & partition = it->second ->Partitions [ev->Get ()->Record .GetPartitionId ()];
993
- partition.PendingNewDataArrived = true ;
994
- it->second ->Counters .NewDataArrived ++;
995
- it->second ->EventsQueue .Send (ev->Release ().Release (), it->second ->Generation );
998
+ auto consumerInfoPtr = it->second ;
999
+ auto partitionIt = consumerInfoPtr->Partitions .find (ev->Get ()->Record .GetPartitionId ());
1000
+ if (partitionIt == consumerInfoPtr->Partitions .end ()) {
1001
+ // Ignore TEvNewDataArrived because read actor now read others partitions.
1002
+ return ;
1003
+ }
1004
+ partitionIt->second .PendingNewDataArrived = true ;
1005
+ consumerInfoPtr->Counters .NewDataArrived ++;
1006
+ consumerInfoPtr->EventsQueue .Send (ev->Release ().Release (), it->second ->Generation );
996
1007
}
997
1008
998
1009
void TRowDispatcher::Handle (NFq::TEvRowDispatcher::TEvMessageBatch::TPtr& ev) {
@@ -1004,10 +1015,15 @@ void TRowDispatcher::Handle(NFq::TEvRowDispatcher::TEvMessageBatch::TPtr& ev) {
1004
1015
LWPROBE (MessageBatch, ev->Sender .ToString (), ev->Get ()->ReadActorId .ToString (), it->second ->QueryId , it->second ->Generation , ev->Get ()->Record .ByteSizeLong ());
1005
1016
LOG_ROW_DISPATCHER_TRACE (" Forward TEvMessageBatch from " << ev->Sender << " to " << ev->Get ()->ReadActorId << " query id " << it->second ->QueryId );
1006
1017
Metrics.RowsSent ->Add (ev->Get ()->Record .MessagesSize ());
1007
- auto & partition = it->second ->Partitions [ev->Get ()->Record .GetPartitionId ()];
1008
- partition.PendingGetNextBatch = false ;
1009
- it->second ->Counters .MessageBatch ++;
1010
- it->second ->EventsQueue .Send (ev->Release ().Release (), it->second ->Generation );
1018
+ auto consumerInfoPtr = it->second ;
1019
+ auto partitionIt = consumerInfoPtr->Partitions .find (ev->Get ()->Record .GetPartitionId ());
1020
+ if (partitionIt == consumerInfoPtr->Partitions .end ()) {
1021
+ // Ignore TEvMessageBatch because read actor now read others partitions.
1022
+ return ;
1023
+ }
1024
+ partitionIt->second .PendingGetNextBatch = false ;
1025
+ consumerInfoPtr->Counters .MessageBatch ++;
1026
+ consumerInfoPtr->EventsQueue .Send (ev->Release ().Release (), it->second ->Generation );
1011
1027
}
1012
1028
1013
1029
void TRowDispatcher::Handle (NFq::TEvRowDispatcher::TEvSessionError::TPtr& ev) {
0 commit comments