Skip to content

Commit d2c7d76

Browse files
authored
Don't verify PDisk if it's too small (#12898)
1 parent 4ebc6ff commit d2c7d76

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,10 +1647,11 @@ void TPDisk::WriteDiskFormat(ui64 diskSizeBytes, ui32 sectorSizeBytes, ui32 user
16471647
// Check disk size
16481648
{
16491649
ui32 diskSizeChunks = format.DiskSizeChunks();
1650-
Y_VERIFY_S(diskSizeChunks > format.SystemChunkCount + 2,
1651-
"Incorrect disk parameters! Total chunks# " << diskSizeChunks
1652-
<< ", System chunks needed# " << format.SystemChunkCount << ", cant run with < 3 free chunks!"
1653-
<< " Debug format# " << format.ToString());
1650+
if (diskSizeChunks <= (format.SystemChunkCount + 2)) {
1651+
ythrow yexception() << "Incorrect disk parameters! Total chunks# " << diskSizeChunks
1652+
<< ", System chunks needed# " << format.SystemChunkCount << ", cant run with < 3 free chunks!"
1653+
<< " Debug format# " << format.ToString();
1654+
}
16541655

16551656
ChunkState = TVector<TChunkState>(diskSizeChunks);
16561657
for (ui32 i = 0; i < format.SystemChunkCount; ++i) {

ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,35 @@ Y_UNIT_TEST_SUITE(TPDiskTest) {
900900
}
901901
}
902902

903+
Y_UNIT_TEST(SuprisinglySmallDisk) {
904+
try {
905+
TActorTestContext testCtx({
906+
.IsBad = false,
907+
.DiskSize = 16_MB,
908+
.SmallDisk = true,
909+
});
910+
911+
UNIT_ASSERT(false);
912+
} catch (const yexception &e) {
913+
UNIT_ASSERT_STRING_CONTAINS(e.what(), "Total chunks# 0, System chunks needed# 1, cant run with < 3 free chunks!");
914+
}
915+
916+
TActorTestContext testCtx({
917+
.IsBad = false,
918+
.DiskSize = 16_MB,
919+
.SmallDisk = true,
920+
.InitiallyZeroed = true
921+
});
922+
923+
TVDiskID vdiskID;
924+
925+
const auto evInitRes = testCtx.TestResponse<NPDisk::TEvYardInitResult>(
926+
new NPDisk::TEvYardInit(1, vdiskID, testCtx.TestCtx.PDiskGuid),
927+
NKikimrProto::CORRUPTED);
928+
929+
UNIT_ASSERT_STRING_CONTAINS(evInitRes->ErrorReason, "Total chunks# 0, System chunks needed# 1, cant run with < 3 free chunks!");
930+
}
931+
903932
Y_UNIT_TEST(PDiskIncreaseLogChunksLimitAfterRestart) {
904933
TActorTestContext testCtx({
905934
.IsBad=false,

ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut_env.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct TActorTestContext {
6464
TestCtx.SectorMap->ZeroInit(1_MB / NPDisk::NSectorMap::SECTOR_SIZE);
6565
}
6666

67-
if (!Settings.ReadOnly) {
67+
if (!Settings.ReadOnly && !Settings.InitiallyZeroed) {
6868
if (Settings.DiskSize) {
6969
FormatPDiskForTest(TestCtx.Path, formatGuid, Settings.ChunkSize, Settings.DiskSize, false, TestCtx.SectorMap, Settings.SmallDisk);
7070
} else {

0 commit comments

Comments
 (0)