Skip to content

Commit b598730

Browse files
authored
Merge f59e023 into 32f057a
2 parents 32f057a + f59e023 commit b598730

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

ydb/core/mind/bscontroller/group_layout_checker.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,15 @@ namespace NKikimr::NBsController {
7272
TEntityId RealmGroup;
7373
TEntityId Realm;
7474
TEntityId Domain;
75+
TEntityId Node;
7576

7677
TPDiskLayoutPosition() = default;
7778

78-
TPDiskLayoutPosition(TEntityId realmGroup, TEntityId realm, TEntityId domain)
79+
TPDiskLayoutPosition(TEntityId realmGroup, TEntityId realm, TEntityId domain, TEntityId node)
7980
: RealmGroup(realmGroup)
8081
, Realm(realm)
8182
, Domain(domain)
83+
, Node(node)
8284
{}
8385

8486
TPDiskLayoutPosition(TDomainMapper& mapper, const TNodeLocation& location, TPDiskId pdiskId, const TGroupGeometryInfo& geom) {
@@ -102,6 +104,7 @@ namespace NKikimr::NBsController {
102104
RealmGroup = mapper(realmGroup.Str());
103105
Realm = mapper(realm.Str());
104106
Domain = mapper(domain.Str());
107+
Node.Value = pdiskId.NodeId;
105108
}
106109

107110
TString ToString() const {
@@ -124,12 +127,13 @@ namespace NKikimr::NBsController {
124127
struct TScore {
125128
ui32 RealmInterlace = 0;
126129
ui32 DomainInterlace = 0;
130+
ui32 NodeInterlace = 0;
127131
ui32 RealmGroupScatter = 0;
128132
ui32 RealmScatter = 0;
129133
ui32 DomainScatter = 0;
130134

131135
auto AsTuple() const {
132-
return std::make_tuple(RealmInterlace, DomainInterlace, RealmGroupScatter, RealmScatter, DomainScatter);
136+
return std::make_tuple(RealmInterlace, DomainInterlace, NodeInterlace, RealmGroupScatter, RealmScatter, DomainScatter);
133137
}
134138

135139
bool BetterThan(const TScore& other) const {
@@ -141,12 +145,13 @@ namespace NKikimr::NBsController {
141145
}
142146

143147
static TScore Max() {
144-
return {::Max<ui32>(), ::Max<ui32>(), ::Max<ui32>(), ::Max<ui32>(), ::Max<ui32>()};
148+
return {::Max<ui32>(), ::Max<ui32>(), ::Max<ui32>(), ::Max<ui32>(), ::Max<ui32>(), ::Max<ui32>()};
145149
}
146150

147151
TString ToString() const {
148152
return TStringBuilder() << "{RealmInterlace# " << RealmInterlace
149153
<< " DomainInterlace# " << DomainInterlace
154+
<< " NodeInterlace# " << NodeInterlace
150155
<< " RealmGroupScatter# " << RealmGroupScatter
151156
<< " RealmScatter# " << RealmScatter
152157
<< " DomainScatter# " << DomainScatter
@@ -168,6 +173,8 @@ namespace NKikimr::NBsController {
168173
TStackVec<THashMap<TEntityId, ui32>, 32> NumDisksPerDomain;
169174
THashMap<TEntityId, ui32> NumDisksPerDomainTotal;
170175

176+
THashMap<TEntityId, ui32> NumDisksPerNode;
177+
171178
TGroupLayout(const TBlobStorageGroupInfo::TTopology& topology)
172179
: Topology(topology)
173180
, NumDisksInRealm(Topology.GetTotalFailRealmsNum())
@@ -187,6 +194,8 @@ namespace NKikimr::NBsController {
187194
NumDisksInDomain[domainIdx] += value;
188195
NumDisksPerDomain[domainIdx][pos.Domain] += value;
189196
NumDisksPerDomainTotal[pos.Domain] += value;
197+
198+
NumDisksPerNode[pos.Node] += value;
190199
}
191200

192201
void AddDisk(const TPDiskLayoutPosition& pos, ui32 orderNumber) {
@@ -204,9 +213,12 @@ namespace NKikimr::NBsController {
204213
const auto& disksPerRealm = NumDisksPerRealm[vdisk.FailRealm][pos.Realm];
205214
const auto& disksPerDomain = NumDisksPerDomain[domainIdx][pos.Domain];
206215

216+
const ui32 disksOnNode = NumDisksPerNode[pos.Node];
217+
207218
return {
208219
.RealmInterlace = NumDisksPerRealmTotal[pos.Realm] - disksPerRealm,
209220
.DomainInterlace = NumDisksPerDomainTotal[pos.Domain] - disksPerDomain,
221+
.NodeInterlace = disksOnNode,
210222
.RealmGroupScatter = NumDisks - NumDisksPerRealmGroup[pos.RealmGroup],
211223
.RealmScatter = NumDisksInRealm[vdisk.FailRealm] - disksPerRealm,
212224
.DomainScatter = NumDisksInDomain[domainIdx] - disksPerDomain,

ydb/core/mind/bscontroller/group_mapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ namespace NKikimr::NBsController {
405405

406406
static std::pair<TPDiskLayoutPosition, TPDiskLayoutPosition> MakeRange(const TPDiskLayoutPosition& x, TEntityId& scope) {
407407
scope = x.Realm;
408-
return {{x.RealmGroup, x.Realm, TEntityId::Min()}, {x.RealmGroup, x.Realm, TEntityId::Max()}};
408+
return {{x.RealmGroup, x.Realm, TEntityId::Min(), TEntityId::Min()}, {x.RealmGroup, x.Realm, TEntityId::Max(), TEntityId::Max()}};
409409
}
410410
};
411411

@@ -415,7 +415,7 @@ namespace NKikimr::NBsController {
415415

416416
static std::pair<TPDiskLayoutPosition, TPDiskLayoutPosition> MakeRange(const TPDiskLayoutPosition& x, TEntityId& scope) {
417417
scope = x.RealmGroup;
418-
return {{x.RealmGroup, TEntityId::Min(), TEntityId::Min()}, {x.RealmGroup, TEntityId::Max(), TEntityId::Max()}};
418+
return {{x.RealmGroup, TEntityId::Min(), TEntityId::Min(), TEntityId::Min()}, {x.RealmGroup, TEntityId::Max(), TEntityId::Max(), TEntityId::Max()}};
419419
}
420420
};
421421

ydb/core/mind/bscontroller/group_mapper_ut.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,39 @@ Y_UNIT_TEST_SUITE(TGroupMapperTest) {
638638
}
639639
}
640640

641+
Y_UNIT_TEST(InterlacedRacksWithoutInterlacedNodes) {
642+
TTestContext context(
643+
{
644+
{1, 1, 1, 1, 1}, // node 1
645+
{1, 1, 2, 1, 1},
646+
{1, 1, 3, 1, 2}, // node 3 has two disks
647+
{1, 1, 4, 1, 1},
648+
{1, 1, 5, 1, 1},
649+
{1, 1, 6, 1, 1},
650+
{1, 1, 2, 1, 1}, // node 7 is in the same rack as node 2
651+
{1, 1, 8, 1, 1},
652+
{1, 1, 3, 1, 1}, // node 9 is in the same rack as node 3
653+
}
654+
);
655+
656+
TGroupMapper mapper(TTestContext::CreateGroupGeometry(TBlobStorageGroupType::Erasure4Plus2Block));
657+
context.PopulateGroupMapper(mapper, 8);
658+
659+
TGroupMapper::TGroupDefinition group;
660+
group.emplace_back(TVector<TVector<TPDiskId>>(8));
661+
auto& g = group[0];
662+
663+
for (int i = 0; i < 8; i++) {
664+
g[i].emplace_back(TPDiskId(i + 1, 1));
665+
}
666+
667+
context.SetGroup(1, group);
668+
669+
TGroupMapper::TGroupDefinition newGroup = context.ReallocateGroup(mapper, 1, {TPDiskId(8, 1)});
670+
671+
UNIT_ASSERT_EQUAL_C(TPDiskId(9, 1), newGroup[0][7][0], context.FormatGroup(newGroup));
672+
}
673+
641674
Y_UNIT_TEST(NonUniformClusterDifferentSlotsPerDisk) {
642675
std::vector<std::tuple<ui32, ui32, ui32, ui32, ui32>> disks;
643676
for (ui32 rack = 0; rack < 12; ++rack) {

0 commit comments

Comments
 (0)