@@ -36,11 +36,10 @@ void TKafkaReadSessionActor::HandleWakeup(TEvKafka::TEvWakeup::TPtr, const TActo
3636 return ;
3737 }
3838
39- for (auto & topicToPartitions: NewPartitionsToLockOnTime) {
40- auto & partitions = topicToPartitions.second ;
39+ for (auto & [topicName, partitions]: NewPartitionsToLockOnTime) {
4140 for (auto partitionsIt = partitions.begin (); partitionsIt != partitions.end (); ) {
4241 if (partitionsIt->LockOn <= ctx.Now ()) {
43- TopicPartitions[topicToPartitions. first ].ToLock .emplace (partitionsIt->PartitionId );
42+ TopicPartitions[topicName ].ToLock .emplace (partitionsIt->PartitionId );
4443 NeedRebalance = true ;
4544 partitionsIt = partitions.erase (partitionsIt);
4645 } else {
@@ -408,6 +407,8 @@ void TKafkaReadSessionActor::HandlePipeDestroyed(TEvTabletPipe::TEvClientDestroy
408407}
409408
410409void TKafkaReadSessionActor::ProcessBalancerDead (ui64 tabletId, const TActorContext& ctx) {
410+ NewPartitionsToLockOnTime.clear ();
411+
411412 for (auto & [topicName, topicInfo] : TopicsInfo) {
412413 if (topicInfo.TabletID == tabletId) {
413414 auto partitionsIt = TopicPartitions.find (topicName);
@@ -579,8 +580,7 @@ void TKafkaReadSessionActor::HandleReleasePartition(TEvPersQueue::TEvReleasePart
579580 auto newPartitionsToLockCount = newPartitionsToLockIt == NewPartitionsToLockOnTime.end () ? 0 : newPartitionsToLockIt->second .size ();
580581
581582 auto topicPartitionsIt = TopicPartitions.find (pathIt->second ->GetInternalName ());
582- Y_ABORT_UNLESS (topicPartitionsIt != TopicPartitions.end ());
583- Y_ABORT_UNLESS (record.GetCount () <= topicPartitionsIt->second .ToLock .size () + topicPartitionsIt->second .ReadingNow .size () + newPartitionsToLockCount);
583+ Y_ABORT_UNLESS (record.GetCount () <= (topicPartitionsIt.IsEnd () ? 0 : topicPartitionsIt->second .ToLock .size () + topicPartitionsIt->second .ReadingNow .size ()) + newPartitionsToLockCount);
584584
585585 for (ui32 c = 0 ; c < record.GetCount (); ++c) {
586586 // if some partition not locked yet, then release it without rebalance
0 commit comments