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