@@ -341,7 +341,7 @@ void TPartitionFamily::AttachePartitions(const std::vector<ui32>& partitions, co
341
341
}
342
342
343
343
auto [activePartitionCount, inactivePartitionCount] = ClassifyPartitions (newPartitions);
344
- ChangePartitionCounters (activePartitionCount, activePartitionCount );
344
+ ChangePartitionCounters (activePartitionCount, inactivePartitionCount );
345
345
346
346
if (IsActive ()) {
347
347
if (!Session->AllPartitionsReadable (newPartitions)) {
@@ -391,7 +391,7 @@ void TPartitionFamily::InactivatePartition(ui32 partitionId) {
391
391
ActivePartitionCount += active;
392
392
InactivePartitionCount += inactive;
393
393
394
- if (IsActive ()) {
394
+ if (IsActive () && Session ) {
395
395
Session->ActivePartitionCount += active;
396
396
Session->InactivePartitionCount += inactive;
397
397
}
@@ -710,30 +710,39 @@ bool TConsumer::BreakUpFamily(TPartitionFamily* family, ui32 partitionId, bool d
710
710
}
711
711
712
712
std::vector<ui32> members;
713
-
714
713
GetPartitionGraph ().Travers (id, [&](auto childId) {
715
714
if (partitions.contains (childId)) {
716
- members.push_back (childId);
717
715
auto [_, i] = processedPartitions.insert (childId);
718
716
if (!i) {
719
717
familiesIntersect = true ;
718
+ } else {
719
+ members.push_back (childId);
720
720
}
721
721
722
722
return true ;
723
723
}
724
724
return false ;
725
725
});
726
726
727
- auto * f = CreateFamily ({id}, family->Status , ctx);
728
- f->Partitions .insert (f->Partitions .end (), members.begin (), members.end ());
727
+ bool locked = family->Session && (family->LockedPartitions .contains (id) ||
728
+ std::any_of (members.begin (), members.end (), [family](auto id) { return family->LockedPartitions .contains (id); }));
729
+ auto * f = CreateFamily ({id}, locked ? family->Status : TPartitionFamily::EStatus::Free, ctx);
729
730
f->TargetStatus = family->TargetStatus ;
730
- f->Session = family->Session ;
731
- f->LockedPartitions = Intercept (family->LockedPartitions , f->Partitions );
731
+ f->Partitions .insert (f->Partitions .end (), members.begin (), members.end ());
732
732
f->LastPipe = family->LastPipe ;
733
- if (f->Session ) {
733
+ f->UpdatePartitionMapping (f->Partitions );
734
+ f->ClassifyPartitions ();
735
+ if (locked) {
736
+ f->LockedPartitions = Intercept (family->LockedPartitions , f->Partitions );
737
+
738
+ f->Session = family->Session ;
734
739
f->Session ->Families .try_emplace (f->Id , f);
740
+ f->Session ->ActivePartitionCount += f->ActivePartitionCount ;
741
+ f->Session ->InactivePartitionCount += f->InactivePartitionCount ;
735
742
if (f->IsActive ()) {
736
743
++f->Session ->ActiveFamilyCount ;
744
+ } else if (f->IsRelesing ()) {
745
+ ++f->Session ->ReleasingFamilyCount ;
737
746
}
738
747
}
739
748
@@ -1300,7 +1309,7 @@ void TConsumer::Balance(const TActorContext& ctx) {
1300
1309
}
1301
1310
}
1302
1311
1303
- if (session->ActiveFamilyCount > desiredFamilyCount) {
1312
+ if (allowPlusOne && session->ActiveFamilyCount > desiredFamilyCount) {
1304
1313
--allowPlusOne;
1305
1314
}
1306
1315
}
0 commit comments