Skip to content

Commit b0f921a

Browse files
committed
Report inferred PDisk SlotCount in metrics
1 parent 0382086 commit b0f921a

File tree

6 files changed

+65
-17
lines changed

6 files changed

+65
-17
lines changed

ydb/apps/dstool/lib/dstool_cmd_pdisk_list.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def do(args):
9090
row['Kind'] = pdisk.Kind
9191
row['Guid'] = pdisk.Guid
9292
row['NumStaticSlots'] = pdisk.NumStaticSlots
93-
row['ExpectedSlotCount'] = pdisk.ExpectedSlotCount
94-
row['SlotSizeInUnits'] = pdisk.PDiskConfig.SlotSizeInUnits
93+
row['ExpectedSlotCount'] = pdisk.PDiskMetrics.SlotCount or pdisk.ExpectedSlotCount
94+
row['SlotSizeInUnits'] = pdisk.PDiskMetrics.SlotSizeInUnits or pdisk.PDiskConfig.SlotSizeInUnits
9595
row['PDiskConfig'] = text_format.MessageToString(pdisk.PDiskConfig, as_one_line=True)
9696
row['AvailableSize'] = pdisk.PDiskMetrics.AvailableSize
9797
row['TotalSize'] = pdisk.PDiskMetrics.TotalSize

ydb/core/blobstorage/nodewarden/blobstorage_node_warden_ut.cpp

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageWardenTest) {
265265
}
266266

267267
ui32 CreatePDisk(TTestActorRuntime &runtime, ui32 nodeIdx, TString path, ui64 guid, ui32 pdiskId, ui64 pDiskCategory,
268-
ui64 inferPDiskSlotCountFromUnitSize = 0) {
268+
const NKikimrBlobStorage::TPDiskConfig* pdiskConfig = nullptr, ui64 inferPDiskSlotCountFromUnitSize = 0) {
269269
VERBOSE_COUT(" Creating pdisk");
270270

271271
ui32 nodeId = runtime.GetNodeId(nodeIdx);
@@ -278,7 +278,10 @@ Y_UNIT_TEST_SUITE(TBlobStorageWardenTest) {
278278
pdisk->SetPDiskGuid(guid);
279279
pdisk->SetPDiskCategory(pDiskCategory);
280280
pdisk->SetEntityStatus(NKikimrBlobStorage::CREATE);
281-
if (inferPDiskSlotCountFromUnitSize) {
281+
if (pdiskConfig) {
282+
pdisk->MutablePDiskConfig()->CopyFrom(*pdiskConfig);
283+
}
284+
if (inferPDiskSlotCountFromUnitSize != 0) {
282285
pdisk->SetInferPDiskSlotCountFromUnitSize(inferPDiskSlotCountFromUnitSize);
283286
}
284287

@@ -1005,19 +1008,42 @@ Y_UNIT_TEST_SUITE(TBlobStorageWardenTest) {
10051008
TTestBasicRuntime runtime(1, false);
10061009
auto nodeId = runtime.GetNodeId(0);
10071010
TString pdiskPath = "SectorMap:TestInferPDiskSlotCountComplexSetup";
1008-
TIntrusivePtr<NPDisk::TSectorMap> sectorMap(new NPDisk::TSectorMap(32_GB));
1011+
TIntrusivePtr<NPDisk::TSectorMap> sectorMap(new NPDisk::TSectorMap(30_GB));
10091012
Setup(runtime, pdiskPath, sectorMap);
10101013

10111014
TActorId edge = runtime.AllocateEdgeActor();
10121015
runtime.SetDispatchTimeout(TDuration::Seconds(10));
10131016
runtime.RegisterService(NNodeWhiteboard::MakeNodeWhiteboardServiceId(nodeId), edge);
10141017

1015-
NKikimrBlobStorage::TPDiskConfig pdiskConfig;
1016-
ui32 pdiskId = CreatePDisk(runtime, 0, pdiskPath, 0, 1001, 0, 1_GB);
1018+
ui32 pdiskId = CreatePDisk(runtime, 0, pdiskPath, 0, 1001, 0, nullptr, 1_GB);
10171019
std::optional<NKikimrWhiteboard::TPDiskStateInfo> pdiskInfo = GrabEvPDiskStateUpdate(runtime, edge, pdiskId);
10181020
UNIT_ASSERT_C(pdiskInfo, "No appropriate TEvPDiskStateUpdate received");
1019-
UNIT_ASSERT_VALUES_EQUAL(pdiskInfo->GetExpectedSlotCount(), 16);
1021+
UNIT_ASSERT_VALUES_EQUAL(pdiskInfo->GetExpectedSlotCount(), 15);
10201022
UNIT_ASSERT_VALUES_EQUAL(pdiskInfo->GetSlotSizeInUnits(), 2u);
1023+
1024+
}
1025+
1026+
CUSTOM_UNIT_TEST(TestInferPDiskSlotCountExplicitConfig) {
1027+
TTempDir tempDir;
1028+
1029+
TTestBasicRuntime runtime(1, false);
1030+
auto nodeId = runtime.GetNodeId(0);
1031+
TString pdiskPath = "SectorMap:TestInferPDiskSlotCountExplicitConfig";
1032+
TIntrusivePtr<NPDisk::TSectorMap> sectorMap(new NPDisk::TSectorMap(30_GB));
1033+
Setup(runtime, pdiskPath, sectorMap);
1034+
1035+
NKikimrBlobStorage::TPDiskConfig pdiskConfig;
1036+
pdiskConfig.SetExpectedSlotCount(13);
1037+
ui32 pdiskId = CreatePDisk(runtime, 0, pdiskPath, 0, 1001, 0, &pdiskConfig, 512_MB);
1038+
1039+
TActorId edge = runtime.AllocateEdgeActor();
1040+
runtime.SetDispatchTimeout(TDuration::Seconds(10));
1041+
runtime.RegisterService(NNodeWhiteboard::MakeNodeWhiteboardServiceId(nodeId), edge);
1042+
1043+
std::optional<NKikimrWhiteboard::TPDiskStateInfo> pdiskInfo = GrabEvPDiskStateUpdate(runtime, edge, pdiskId);
1044+
UNIT_ASSERT_C(pdiskInfo, "No appropriate TEvPDiskStateUpdate received");
1045+
UNIT_ASSERT_VALUES_EQUAL(pdiskInfo->GetExpectedSlotCount(), 13);
1046+
UNIT_ASSERT_VALUES_EQUAL(pdiskInfo->GetSlotSizeInUnits(), 0u);
10211047
}
10221048
}
10231049

ydb/core/blobstorage/nodewarden/node_warden_pdisk.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ namespace NKikimr::NStorage {
137137
pdiskConfig->EnableSectorEncryption = !pdiskConfig->SectorMap;
138138
}
139139

140-
if (ui64 unitSizeInBytes = pdisk.GetInferPDiskSlotCountFromUnitSize()) {
140+
if (pdisk.GetPDiskConfig().GetExpectedSlotCount() != 0) {
141+
// Skip inferring PDisk SlotCount
142+
} else if (ui64 unitSizeInBytes = pdisk.GetInferPDiskSlotCountFromUnitSize()) {
141143
ui64 driveSize = 0;
142144
TStringStream outDetails;
143145
if (pdiskConfig->SectorMap) {

ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,6 +1630,10 @@ void TPDisk::WhiteboardReport(TWhiteboardReport &whiteboardReport) {
16301630
pdiskState.SetEnforcedDynamicSlotSize(minSlotSize);
16311631
}
16321632
pDiskMetrics.SetState(state);
1633+
pDiskMetrics.SetSlotSizeInUnits(Cfg->SlotSizeInUnits);
1634+
if (ExpectedSlotCount) {
1635+
pDiskMetrics.SetSlotCount(ExpectedSlotCount);
1636+
}
16331637
}
16341638

16351639
PCtx->ActorSystem->Send(whiteboardReport.Sender, reportResult);
@@ -2330,7 +2334,7 @@ void TPDisk::Slay(TSlay &evSlay) {
23302334
TVDiskID vDiskId = evSlay.VDiskId;
23312335
vDiskId.GroupGeneration = -1;
23322336
auto it = VDiskOwners.find(vDiskId);
2333-
2337+
23342338
for (auto& pendingInit : PendingYardInits) {
23352339
if (vDiskId == pendingInit->VDiskIdWOGeneration()) {
23362340
TStringStream str;
@@ -2999,7 +3003,7 @@ NKikimrProto::EReplyStatus TPDisk::CheckOwnerAndRound(TRequestBase* req, TString
29993003

30003004
if (!IsOwnerUser(req->Owner)) {
30013005
if (req->Owner == OwnerUnallocated && req->OwnerRound == 0) {
3002-
return NKikimrProto::OK;
3006+
return NKikimrProto::OK;
30033007
}
30043008
err << " ownerId# " << req->Owner << " < Begin# " << (ui32)OwnerBeginUser
30053009
<< " or >= End# " << (ui32)OwnerEndUser << " Marker# BPD72";
@@ -4343,7 +4347,7 @@ void TPDisk::ProgressShredState() {
43434347
<< " ShredGeneration# " << ShredGeneration
43444348
<< " ShredState# " << (ui32)ShredState);
43454349
// Send/schedule a request to retry
4346-
THolder<TCompletionEventSender> completion(new TCompletionEventSender(this, PCtx->PDiskActor, new NPDisk::TEvContinueShred()));
4350+
THolder<TCompletionEventSender> completion(new TCompletionEventSender(this, PCtx->PDiskActor, new NPDisk::TEvContinueShred()));
43474351
if (ReleaseUnusedLogChunks(completion.Get())) {
43484352
ContinueShredsInFlight++;
43494353
WriteSysLogRestorePoint(completion.Release(), TReqId(TReqId::ShredPDisk, 0), {});
@@ -4367,7 +4371,7 @@ void TPDisk::ProgressShredState() {
43674371
}
43684372
}
43694373
// Looks good, but there still can be chunks that need to be shredded still int transition between states.
4370-
// For example, log chunks are removed from the log chunk list on log cut but added to free chunk list on log cut
4374+
// For example, log chunks are removed from the log chunk list on log cut but added to free chunk list on log cut
43714375
// write operation completion. So, walk through the whole chunk list and check.
43724376
for (ui32 chunkIdx = Format.SystemChunkCount; chunkIdx < ChunkState.size(); ++chunkIdx) {
43734377
TChunkState &state = ChunkState[chunkIdx];
@@ -4382,7 +4386,7 @@ void TPDisk::ProgressShredState() {
43824386
<< ", there are already ContinueShredsInFlight# " << ContinueShredsInFlight.load()
43834387
<< " so just wait for it to arrive. "
43844388
<< " ShredGeneration# " << ShredGeneration);
4385-
return;
4389+
return;
43864390
} else {
43874391
LOG_DEBUG_S(*PCtx->ActorSystem, NKikimrServices::BS_PDISK_SHRED,
43884392
"PDisk# " << PCtx->PDiskId

ydb/core/mind/bscontroller/config_fit_groups.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,14 +678,28 @@ namespace NKikimr {
678678
}
679679
}
680680

681+
ui32 maxSlots = 0;
682+
ui32 slotSizeInUnits = 0;
683+
if (info.Metrics.HasSlotCount()) {
684+
maxSlots = info.Metrics.GetSlotCount();
685+
slotSizeInUnits = info.Metrics.GetSlotSizeInUnits();
686+
} else if (info.InferPDiskSlotCountFromUnitSize != 0) {
687+
// inferred values are unknown yet
688+
maxSlots = 0;
689+
slotSizeInUnits = 0;
690+
} else {
691+
maxSlots = info.ExpectedSlotCount;
692+
slotSizeInUnits = info.SlotSizeInUnits;
693+
}
694+
681695
// register PDisk in the mapper
682696
return Mapper->RegisterPDisk({
683697
.PDiskId = id,
684698
.Location = State.HostRecords->GetLocation(id.NodeId),
685699
.Usable = usable,
686700
.NumSlots = numSlots,
687-
.MaxSlots = info.ExpectedSlotCount,
688-
.SlotSizeInUnits = info.SlotSizeInUnits,
701+
.MaxSlots = maxSlots,
702+
.SlotSizeInUnits = slotSizeInUnits,
689703
.Groups = std::move(groups),
690704
.SpaceAvailable = availableSpace,
691705
.Operational = info.Operational,

ydb/core/protos/blobstorage_disk.proto

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,14 @@ message TPDiskMetrics {
8080
optional uint64 NonRealTimeMs = 6; // ms per second of non-realtime, [0..1000]
8181
optional uint64 SlowDeviceMs = 7; // ms per second of slow device, [0..1000]
8282
optional uint32 MaxIOPS = 8; // number of IOPS this device can carry out
83-
83+
8484
// maximum expected slot size; if set, then it is guaranteed that EnforcedDynamicSlotSize bytes of space are
8585
// available for every slot over this PDisk; if not set, then no space enforcement assumed
8686
optional uint64 EnforcedDynamicSlotSize = 9;
8787

8888
optional TPDiskState.E State = 10;
8989

9090
optional uint64 UpdateTimestamp = 11; // TInstant::GetValue()
91+
optional uint64 SlotCount = 12;
92+
optional uint32 SlotSizeInUnits = 13;
9193
}

0 commit comments

Comments
 (0)