From 76723df6d021663f586b37c181ac3eeb128c577b Mon Sep 17 00:00:00 2001 From: Sergey Belyakov Date: Fri, 8 Mar 2024 18:17:23 +0300 Subject: Validate tabletId to be not null on puts in Skeleton (#2535) --- .../ut_blobstorage/incorrect_queries.cpp | 5 +- ydb/core/blobstorage/ut_vdisk/lib/dataset.cpp | 49 +++++++++++-------- ydb/core/blobstorage/ut_vdisk/lib/dataset.h | 10 ++++ .../blobstorage/ut_vdisk/lib/test_bad_blobid.cpp | 57 ++++++++++++++++++++++ .../blobstorage/ut_vdisk/lib/test_bad_blobid.h | 10 ++++ ydb/core/blobstorage/ut_vdisk/lib/test_defrag.cpp | 4 +- ydb/core/blobstorage/ut_vdisk/lib/test_gc.cpp | 46 ++++++++--------- ydb/core/blobstorage/ut_vdisk/lib/test_huge.cpp | 2 +- .../ut_vdisk/lib/test_localrecovery.cpp | 8 +-- ydb/core/blobstorage/ut_vdisk/lib/test_many.cpp | 14 +++--- ydb/core/blobstorage/ut_vdisk/lib/test_many.h | 11 +++-- ydb/core/blobstorage/ut_vdisk/lib/test_repl.cpp | 8 +-- .../blobstorage/ut_vdisk/lib/test_simplebs.cpp | 30 ++++++------ ydb/core/blobstorage/ut_vdisk/lib/ya.make | 2 + ydb/core/blobstorage/ut_vdisk/vdisk_test.cpp | 17 ++++++- .../vdisk/skeleton/blobstorage_skeleton.cpp | 7 +++ 16 files changed, 196 insertions(+), 84 deletions(-) create mode 100644 ydb/core/blobstorage/ut_vdisk/lib/test_bad_blobid.cpp create mode 100644 ydb/core/blobstorage/ut_vdisk/lib/test_bad_blobid.h diff --git a/ydb/core/blobstorage/ut_blobstorage/incorrect_queries.cpp b/ydb/core/blobstorage/ut_blobstorage/incorrect_queries.cpp index 3340a1da453..fd2519512a7 100644 --- a/ydb/core/blobstorage/ut_blobstorage/incorrect_queries.cpp +++ b/ydb/core/blobstorage/ut_blobstorage/incorrect_queries.cpp @@ -132,7 +132,7 @@ Y_UNIT_TEST_SUITE(IncorrectQueries) { auto blobId = LogoBlobIDFromLogoBlobID(pBlobId); SendPut(env,test, blobId, NKikimrProto::ERROR, 0); - pBlobId.set_rawx1(0); + pBlobId.set_rawx1(0xABC); pBlobId.set_rawx2(0); pBlobId.set_rawx3(crc); @@ -267,6 +267,7 @@ Y_UNIT_TEST_SUITE(IncorrectQueries) { TTestInfo test = InitTest(env); NKikimrProto::TLogoBlobID protoBlobId; + protoBlobId.set_rawx1(0xABC); protoBlobId.set_rawx2(std::numeric_limits::max()); protoBlobId.set_rawx3(17); @@ -387,7 +388,7 @@ Y_UNIT_TEST_SUITE(IncorrectQueries) { SendMultiPut(env, test, NKikimrProto::OK, blobs); - pBlobId.set_rawx1(0); + pBlobId.set_rawx1(0xABC); pBlobId.set_rawx2(0); pBlobId.set_rawx3((1ull << 30) + (1ull << 31) + 1); diff --git a/ydb/core/blobstorage/ut_vdisk/lib/dataset.cpp b/ydb/core/blobstorage/ut_vdisk/lib/dataset.cpp index 89e383aea55..dcf16954229 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/dataset.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/dataset.cpp @@ -5,6 +5,7 @@ using namespace NKikimr; +extern const ui64 DefaultTestTabletId = 5000; TString CreateData(const TString &orig, ui32 minHugeBlobSize, bool huge) { if (huge) { @@ -23,15 +24,15 @@ TString CreateData(const TString &orig, ui32 minHugeBlobSize, bool huge) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////// TSmallCommonDataSet::TSmallCommonDataSet() { auto put = [&] (ui32 step, TString data) { - Items.push_back(TDataItem{NKikimr::TLogoBlobID(0, 1, step, 0, data.size(), 0), std::move(data), + Items.push_back(TDataItem{NKikimr::TLogoBlobID(DefaultTestTabletId, 1, step, 0, data.size(), 0), std::move(data), NKikimrBlobStorage::EPutHandleClass::TabletLog}); }; - put(321, "xxxxxxxxxx"); - put(331, "yyy"); - put(408, "zzz"); - put(471, "pppp"); - put(909, "qqqqq"); + put(322, "xxxxxxxxxx"); + put(370, "yyy"); + put(424, "zzz"); + put(472, "pppp"); + put(915, "qqqqq"); } @@ -54,15 +55,15 @@ TCustomDataSet::TCustomDataSet(ui64 tabletId, ui32 gen, ui32 channel, ui32 step, //////////////////////////////////////////////////////////////////////////////////////////////////////////////// T3PutDataSet::T3PutDataSet(NKikimrBlobStorage::EPutHandleClass cls, ui32 minHugeBlobSize, bool huge) { TString abcdefghkj(CreateData("abcdefghkj", minHugeBlobSize, huge)); - TLogoBlobID id1(0, 1, 10, 0, abcdefghkj.size(), 0, 1); + TLogoBlobID id1(DefaultTestTabletId, 1, 16, 0, abcdefghkj.size(), 0, 1); Items.push_back(TDataItem(id1, abcdefghkj, cls)); TString pqr(CreateData("pqr", minHugeBlobSize, huge)); - TLogoBlobID id2(0, 1, 30, 0, pqr.size(), 0, 1); + TLogoBlobID id2(DefaultTestTabletId, 1, 30, 0, pqr.size(), 0, 1); Items.push_back(TDataItem(id2, pqr, cls)); TString xyz(CreateData("xyz", minHugeBlobSize, huge)); - TLogoBlobID id3(0, 1, 34, 0, xyz.size(), 0, 1); + TLogoBlobID id3(DefaultTestTabletId, 1, 36, 0, xyz.size(), 0, 1); Items.push_back(TDataItem(id3, xyz, cls)); } @@ -72,8 +73,8 @@ T3PutDataSet::T3PutDataSet(NKikimrBlobStorage::EPutHandleClass cls, ui32 minHuge //////////////////////////////////////////////////////////////////////////////////////////////////////////////// T1PutHandoff2DataSet::T1PutHandoff2DataSet(NKikimrBlobStorage::EPutHandleClass cls, ui32 minHugeBlobSize, bool huge) { TString abc(CreateData("abc", minHugeBlobSize, huge)); - TLogoBlobID id1Part1(0, 1, 10, 0, abc.size(), 0, 1); - TLogoBlobID id1Part2(0, 1, 10, 0, abc.size(), 0, 2); + TLogoBlobID id1Part1(DefaultTestTabletId, 1, 16, 0, abc.size(), 0, 1); + TLogoBlobID id1Part2(DefaultTestTabletId, 1, 16, 0, abc.size(), 0, 2); Items.push_back(TDataItem(id1Part1, abc, cls)); Items.push_back(TDataItem(id1Part2, abc, cls)); @@ -86,12 +87,12 @@ T3PutHandoff2DataSet::T3PutHandoff2DataSet(NKikimrBlobStorage::EPutHandleClass c TString abcdefghkj(CreateData("abcdefghkj", minHugeBlobSize, huge)); TString pqr(CreateData("pqr", minHugeBlobSize, huge)); TString xyz(CreateData("xyz", minHugeBlobSize, huge)); - TLogoBlobID id1Part1(0, 1, 10, 0, abcdefghkj.size(), 0, 1); - TLogoBlobID id1Part2(0, 1, 10, 0, abcdefghkj.size(), 0, 2); - TLogoBlobID id2Part1(0, 1, 30, 0, pqr.size(), 0, 1); - TLogoBlobID id2Part2(0, 1, 30, 0, pqr.size(), 0, 2); - TLogoBlobID id3Part1(0, 1, 34, 0, xyz.size(), 0, 1); - TLogoBlobID id3Part2(0, 1, 34, 0, xyz.size(), 0, 2); + TLogoBlobID id1Part1(DefaultTestTabletId, 1, 16, 0, abcdefghkj.size(), 0, 1); + TLogoBlobID id1Part2(DefaultTestTabletId, 1, 16, 0, abcdefghkj.size(), 0, 2); + TLogoBlobID id2Part1(DefaultTestTabletId, 1, 30, 0, pqr.size(), 0, 1); + TLogoBlobID id2Part2(DefaultTestTabletId, 1, 30, 0, pqr.size(), 0, 2); + TLogoBlobID id3Part1(DefaultTestTabletId, 1, 36, 0, xyz.size(), 0, 1); + TLogoBlobID id3Part2(DefaultTestTabletId, 1, 36, 0, xyz.size(), 0, 2); Items.push_back(TDataItem(id1Part1, abcdefghkj, cls)); Items.push_back(TDataItem(id1Part2, abcdefghkj, cls)); @@ -193,9 +194,9 @@ IDataGenerator* CreateBlobGenerator(ui64 maxCumSize, ui32 maxNumBlobs, ui32 minB ui64 GenerateTabletId() { if (DifferentTablets > 1) { - return Rng() % DifferentTablets; + return Rng() % DifferentTablets + DefaultTestTabletId; } else { - return 0; + return DefaultTestTabletId; } } @@ -219,4 +220,14 @@ IDataGenerator* CreateBlobGenerator(ui64 maxCumSize, ui32 maxNumBlobs, ui32 minB std::move(matchingVDisks), reuseData); } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// TBadIdsDataSet +//////////////////////////////////////////////////////////////////////////////////////////////////////////////// +TBadIdsDataSet::TBadIdsDataSet(NKikimrBlobStorage::EPutHandleClass cls, ui32 minHugeBlobSize, bool huge) { + TString abcdefghkj(CreateData("abcdefghkj", minHugeBlobSize, huge)); + ui64 tabletId = 0; + TLogoBlobID id(tabletId, 1, 10, 0, abcdefghkj.size(), 0, 1); + Items.push_back(TDataItem(id, abcdefghkj, cls)); +} + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/ydb/core/blobstorage/ut_vdisk/lib/dataset.h b/ydb/core/blobstorage/ut_vdisk/lib/dataset.h index 46e967d1da7..85986bf9f25 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/dataset.h +++ b/ydb/core/blobstorage/ut_vdisk/lib/dataset.h @@ -4,6 +4,8 @@ #include +extern const ui64 DefaultTestTabletId; + TString CreateData(const TString &orig, ui32 minHugeBlobSize, bool huge); //////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -229,6 +231,14 @@ IDataGenerator* CreateBlobGenerator(ui64 maxCumSize, ui32 maxNumBlobs, ui32 minB ui32 differentTablets, ui32 startingStep, TIntrusivePtr info, TVector matchingVDisks, bool reuseData = false); +//////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// TBadIdsDataSet +//////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class TBadIdsDataSet : public TVectorDataSet { +public: + TBadIdsDataSet(NKikimrBlobStorage::EPutHandleClass cls, ui32 minHugeBlobSize, bool huge); +}; + diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_bad_blobid.cpp b/ydb/core/blobstorage/ut_vdisk/lib/test_bad_blobid.cpp new file mode 100644 index 00000000000..e8cba9cfdac --- /dev/null +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_bad_blobid.cpp @@ -0,0 +1,57 @@ +#include "test_bad_blobid.h" +#include "helpers.h" + +#include +#include +#include + +using namespace NKikimr; + +#define STR Cnull + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class TWriteAndExpectErrorActor : public TActorBootstrapped { +protected: + TConfiguration* Conf; + const TAllVDisks::TVDiskInstance VDiskInfo; + IDataSetPtr DataSetPtr; + +public: + TWriteAndExpectErrorActor(TConfiguration *conf) + : TActorBootstrapped() + , Conf(conf) + , VDiskInfo(conf->VDisks->Get(0)) + , DataSetPtr(new TBadIdsDataSet(NKikimrBlobStorage::EPutHandleClass::TabletLog, 64<<10, false)) + {} + + void Bootstrap(const TActorContext &ctx) { + for (auto it = DataSetPtr->First(); it->IsValid(); it->Next()) { + const auto &x = *it->Get(); + ctx.Send(VDiskInfo.ActorID, new TEvBlobStorage::TEvVPut(x.Id, TRope(x.Data), + VDiskInfo.VDiskID, false, nullptr, TInstant::Max(), x.HandleClass)); + } + Become(&TThis::StateFunc); + } + +private: + void Handle(TEvBlobStorage::TEvVPutResult::TPtr &ev, const TActorContext &ctx) { + Y_ABORT_UNLESS(ev->Get()->Record.GetStatus() == NKikimrProto::ERROR, "Status=%s", + NKikimrProto::EReplyStatus_Name(ev->Get()->Record.GetStatus()).data()); + LOG_NOTICE(ctx, NActorsServices::TEST, " TEvVPut failed successfully"); + AtomicIncrement(Conf->SuccessCount); + Conf->SignalDoneEvent(); + Die(ctx); + } + + STRICT_STFUNC(StateFunc, + HFunc(TEvBlobStorage::TEvVPutResult, Handle); + ) +}; + + +using namespace NKikimr; +void TWriteAndExpectError::operator ()(TConfiguration *conf) { + conf->ActorSystem1->Register(new TWriteAndExpectErrorActor(conf)); +} + diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_bad_blobid.h b/ydb/core/blobstorage/ut_vdisk/lib/test_bad_blobid.h new file mode 100644 index 00000000000..9fca66df3d3 --- /dev/null +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_bad_blobid.h @@ -0,0 +1,10 @@ +#pragma once + +#include "defs.h" +#include "prepare.h" + +/////////////////////////////////////////////////////////////////////////// +struct TWriteAndExpectError { + void operator ()(TConfiguration *conf); +}; + diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_defrag.cpp b/ydb/core/blobstorage/ut_vdisk/lib/test_defrag.cpp index dee8df824dc..adb7cf3f23f 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/test_defrag.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_defrag.cpp @@ -54,7 +54,7 @@ virtual void Scenario(const TActorContext &ctx) { // prepare gc command -- it deletes all data from one tablet TGCSettings settings; - settings.TabletID = 0; + settings.TabletID = DefaultTestTabletId; settings.RecGen = 1; settings.RecGenCounter = 1; settings.Channel = 0; @@ -98,7 +98,7 @@ virtual void Scenario(const TActorContext &ctx) { LOG_NOTICE(ctx, NActorsServices::TEST, " Defrag completed"); // check actually freed chunks - UNIT_ASSERT_VALUES_EQUAL(freedChunks, 3); + UNIT_ASSERT_VALUES_EQUAL(freedChunks, 4); } SYNC_TEST_END(TDefrag50PercentGarbage, TSyncTestBase) diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_gc.cpp b/ydb/core/blobstorage/ut_vdisk/lib/test_gc.cpp index a0577918274..28ab4fda733 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/test_gc.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_gc.cpp @@ -7,14 +7,14 @@ using namespace NKikimr; // Put Keep flags into empty db, than VGet data SYNC_TEST_BEGIN(TGCPutKeepIntoEmptyDB, TSyncTestBase) virtual void Scenario(const TActorContext &ctx) { - TLogoBlobID generic(0, 1, 2, 0, 0, 0); + TLogoBlobID generic(DefaultTestTabletId, 1, 2, 0, 0, 0); TLogoBlobID part0(generic, 1); TAllVDisks::TVDiskInstance &instance = Conf->VDisks->Get(0); // prepare gc command TAutoPtr> Keep(new TVector); Keep->push_back(generic); - ui64 tabletID = 0; + ui64 tabletID = DefaultTestTabletId; ui32 recGen = 1; ui32 recGenCounter = 1; ui32 channel = 0; @@ -51,7 +51,7 @@ SYNC_TEST_END(TGCPutKeepIntoEmptyDB, TSyncTestBase) SYNC_TEST_BEGIN(TGCPutBarrierVDisk0, TSyncTestWithSmallCommonDataset) virtual void Scenario(const TActorContext &ctx) { // prepare gc command - ui64 tabletID = 0; + ui64 tabletID = DefaultTestTabletId; ui32 recGen = 1; ui32 recGenCounter = 1; ui32 channel = 0; @@ -81,8 +81,8 @@ virtual void Scenario(const TActorContext &ctx) { TAutoPtr readCmd; auto sendFunc = [this](const TActorContext &ctx) { TAllVDisks::TVDiskInstance &instance = Conf->VDisks->Get(0); - TLogoBlobID from(0, 4294967295, 4294967295, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); - TLogoBlobID to (0, 0, 0, 0, 0, 0, 1); + TLogoBlobID from(DefaultTestTabletId, 4294967295, 4294967295, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); + TLogoBlobID to (DefaultTestTabletId, 0, 0, 0, 0, 0, 1); LOG_NOTICE(ctx, NActorsServices::TEST, " Test: from=%s to=%s\n", from.ToString().data(), to.ToString().data()); auto req = TEvBlobStorage::TEvVGet::CreateRangeIndexQuery(instance.VDiskID, TInstant::Max(), @@ -96,8 +96,8 @@ virtual void Scenario(const TActorContext &ctx) { TString pppp("pppp"); TString qqqqq("qqqqq"); - ExpectedSet.Put(TLogoBlobID(0, 1, 471, 0, pppp.size(), 0), NKikimrProto::OK, {}); - ExpectedSet.Put(TLogoBlobID(0, 1, 909, 0, qqqqq.size(), 0), NKikimrProto::OK, {}); + ExpectedSet.Put(TLogoBlobID(DefaultTestTabletId, 1, 472, 0, pppp.size(), 0), NKikimrProto::OK, {}); + ExpectedSet.Put(TLogoBlobID(DefaultTestTabletId, 1, 915, 0, qqqqq.size(), 0), NKikimrProto::OK, {}); }; auto checkFunc = [this](TEvBlobStorage::TEvVGetResult::TPtr &ev, const TActorContext &ctx) { CheckQueryResult(ev, ctx, EQR_OK_EXPECTED_SET, &ExpectedSet); @@ -112,7 +112,7 @@ SYNC_TEST_END(TGCPutBarrierVDisk0, TSyncTestWithSmallCommonDataset) SYNC_TEST_BEGIN(TGCPutBarrier, TSyncTestWithSmallCommonDataset) virtual void Scenario(const TActorContext &ctx) { // prepare gc command - ui64 tabletID = 0; + ui64 tabletID = DefaultTestTabletId; ui32 recGen = 1; ui32 recGenCounter = 1; ui32 channel = 0; @@ -149,8 +149,8 @@ SYNC_TEST_BEGIN(TGCPutBarrier, TSyncTestWithSmallCommonDataset) TAutoPtr readCmd; auto sendFunc = [this](const TActorContext &ctx) { TAllVDisks::TVDiskInstance &instance = Conf->VDisks->Get(0); - TLogoBlobID from(0, 4294967295, 4294967295, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); - TLogoBlobID to (0, 0, 0, 0, 0, 0, 1); + TLogoBlobID from(DefaultTestTabletId, 4294967295, 4294967295, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); + TLogoBlobID to (DefaultTestTabletId, 0, 0, 0, 0, 0, 1); LOG_NOTICE(ctx, NActorsServices::TEST, " Test: from=%s to=%s\n", from.ToString().data(), to.ToString().data()); auto req = TEvBlobStorage::TEvVGet::CreateRangeIndexQuery(instance.VDiskID, TInstant::Max(), @@ -164,8 +164,8 @@ SYNC_TEST_BEGIN(TGCPutBarrier, TSyncTestWithSmallCommonDataset) TString pppp("pppp"); TString qqqqq("qqqqq"); - ExpectedSet.Put(TLogoBlobID(0, 1, 471, 0, pppp.size(), 0), NKikimrProto::OK, {}); - ExpectedSet.Put(TLogoBlobID(0, 1, 909, 0, qqqqq.size(), 0), NKikimrProto::OK, {}); + ExpectedSet.Put(TLogoBlobID(DefaultTestTabletId, 1, 472, 0, pppp.size(), 0), NKikimrProto::OK, {}); + ExpectedSet.Put(TLogoBlobID(DefaultTestTabletId, 1, 915, 0, qqqqq.size(), 0), NKikimrProto::OK, {}); }; auto checkFunc = [this](TEvBlobStorage::TEvVGetResult::TPtr &ev, const TActorContext &ctx) { CheckQueryResult(ev, ctx, EQR_OK_EXPECTED_SET, &ExpectedSet); @@ -180,7 +180,7 @@ SYNC_TEST_END(TGCPutBarrier, TSyncTestWithSmallCommonDataset) SYNC_TEST_BEGIN(TGCPutKeepBarrier, TSyncTestWithSmallCommonDataset) virtual void Scenario(const TActorContext &ctx) { // prepare gc command - ui64 tabletID = 0; + ui64 tabletID = DefaultTestTabletId; ui32 recGen = 1; ui32 recGenCounter = 2; ui32 channel = 0; @@ -189,7 +189,7 @@ virtual void Scenario(const TActorContext &ctx) { ui32 collectStep = 1000; TAutoPtr> keep(new TVector()); TString qqqqq("qqqqq"); - keep->push_back(TLogoBlobID(0, 1, 909, 0, qqqqq.size(), 0)); + keep->push_back(TLogoBlobID(DefaultTestTabletId, 1, 915, 0, qqqqq.size(), 0)); TAutoPtr gcCommand(PutGCToCorrespondingVDisks(SyncRunner->NotifyID(), Conf, tabletID, recGen, recGenCounter, channel, collect, collectGen, collectStep, keep, nullptr)); // set gc settings @@ -219,8 +219,8 @@ virtual void Scenario(const TActorContext &ctx) { TAutoPtr readCmd; auto sendFunc = [this, qqqqq](const TActorContext &ctx) { TAllVDisks::TVDiskInstance &instance = Conf->VDisks->Get(0); - TLogoBlobID from(0, 4294967295, 4294967295, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); - TLogoBlobID to (0, 0, 0, 0, 0, 0, 1); + TLogoBlobID from(DefaultTestTabletId, 4294967295, 4294967295, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); + TLogoBlobID to (DefaultTestTabletId, 0, 0, 0, 0, 0, 1); LOG_NOTICE(ctx, NActorsServices::TEST, " Test: from=%s to=%s\n", from.ToString().data(), to.ToString().data()); auto req = TEvBlobStorage::TEvVGet::CreateRangeIndexQuery(instance.VDiskID, TInstant::Max(), @@ -232,7 +232,7 @@ virtual void Scenario(const TActorContext &ctx) { 10); ctx.Send(instance.ActorID, req.release()); - ExpectedSet.Put(TLogoBlobID(0, 1, 909, 0, qqqqq.size(), 0), NKikimrProto::OK, {}); + ExpectedSet.Put(TLogoBlobID(DefaultTestTabletId, 1, 915, 0, qqqqq.size(), 0), NKikimrProto::OK, {}); }; auto checkFunc = [this](TEvBlobStorage::TEvVGetResult::TPtr &ev, const TActorContext &ctx) { CheckQueryResult(ev, ctx, EQR_OK_EXPECTED_SET, &ExpectedSet); @@ -261,7 +261,7 @@ virtual void Scenario(const TActorContext &ctx) { LOG_NOTICE(ctx, NActorsServices::TEST, " COMPACTION done"); // prepare gc command - ui64 tabletID = 0; + ui64 tabletID = DefaultTestTabletId; ui32 recGen = 1; ui32 recGenCounter = 2; ui32 channel = 0; @@ -280,8 +280,8 @@ virtual void Scenario(const TActorContext &ctx) { TAutoPtr readCmd; auto sendFunc = [this](const TActorContext &ctx) { TAllVDisks::TVDiskInstance &instance = Conf->VDisks->Get(0); - TLogoBlobID from(0, 0, 0, 0, 0, 0, 1); - TLogoBlobID to (0, 4294967295, 4294967295, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); + TLogoBlobID from(DefaultTestTabletId, 0, 0, 0, 0, 0, 1); + TLogoBlobID to (DefaultTestTabletId, 4294967295, 4294967295, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); LOG_NOTICE(ctx, NActorsServices::TEST, " Test: from=%s to=%s", from.ToString().data(), to.ToString().data()); auto req = TEvBlobStorage::TEvVGet::CreateRangeIndexQuery(instance.VDiskID, TInstant::Max(), @@ -327,7 +327,7 @@ virtual void Scenario(const TActorContext &ctx) { LOG_NOTICE(ctx, NActorsServices::TEST, " COMPACTION done"); // prepare gc command - ui64 tabletID = 0; + ui64 tabletID = DefaultTestTabletId; ui32 recGen = Max(); ui32 recGenCounter = Max(); ui32 channel = 0; @@ -346,8 +346,8 @@ virtual void Scenario(const TActorContext &ctx) { TAutoPtr readCmd; auto sendFunc = [this](const TActorContext &ctx) { TAllVDisks::TVDiskInstance &instance = Conf->VDisks->Get(0); - TLogoBlobID from(0, 0, 0, 0, 0, 0, 1); - TLogoBlobID to (0, 4294967295, 4294967295, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); + TLogoBlobID from(DefaultTestTabletId, 0, 0, 0, 0, 0, 1); + TLogoBlobID to (DefaultTestTabletId, 4294967295, 4294967295, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); LOG_NOTICE(ctx, NActorsServices::TEST, " Test: from=%s to=%s", from.ToString().data(), to.ToString().data()); auto req = TEvBlobStorage::TEvVGet::CreateRangeIndexQuery(instance.VDiskID, TInstant::Max(), diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_huge.cpp b/ydb/core/blobstorage/ut_vdisk/lib/test_huge.cpp index 2affc1e91a6..55b6d64fb2d 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/test_huge.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_huge.cpp @@ -55,7 +55,7 @@ public: case 0: { const ui32 minHugeBlobSize = 65 << 10; TString abcdefghkj(CreateData("abcdefghkj", minHugeBlobSize, true)); - const TLogoBlobID logoBlobId(0, 1, 10, 0, abcdefghkj.size(), 0, 1); + const TLogoBlobID logoBlobId(DefaultTestTabletId, 1, 10, 0, abcdefghkj.size(), 0, 1); ctx.Send(HugeKeeperId, new TEvHullWriteHugeBlob(TActorId(), 0, logoBlobId, TIngress(), TRope(abcdefghkj), diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_localrecovery.cpp b/ydb/core/blobstorage/ut_vdisk/lib/test_localrecovery.cpp index b65c601f86e..54ee836be4d 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/test_localrecovery.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_localrecovery.cpp @@ -16,7 +16,7 @@ class TCheckDbIsEmptyManyPutGetActor : public TSyncTestBase { virtual void Scenario(const TActorContext &ctx) { SyncRunner->Run(ctx, CreateCheckDbEmptyness(SyncRunner->NotifyID(), Conf->VDisks->Get(0), ExpectEmpty)); SyncRunner->Run(ctx, CreateManyPuts(Conf, SyncRunner->NotifyID(), Conf->VDisks->Get(0), MsgSize, MsgNum, - 0, 0, 1, HandleClassGen, BadSteps, TDuration::Seconds(0))); + DefaultTestTabletId, 0, 1, HandleClassGen, BadSteps, TDuration::Seconds(0))); } public: @@ -46,7 +46,7 @@ class TManyPutsActor : public TSyncTestBase { std::shared_ptr> BadSteps; virtual void Scenario(const TActorContext &ctx) { - ui64 tabletId = 0; + ui64 tabletId = DefaultTestTabletId; ui32 channel = 0; ui32 gen = 1; SyncRunner->Run(ctx, CreateManyPuts(Conf, SyncRunner->NotifyID(), Conf->VDisks->Get(0), @@ -77,7 +77,7 @@ class TManyGetsActor : public TSyncTestBase { std::shared_ptr> BadSteps; virtual void Scenario(const TActorContext &ctx) { - ui64 tabletId = 0; + ui64 tabletId = DefaultTestTabletId; ui32 channel = 0; ui32 gen = 1; SyncRunner->Run(ctx, CreateManyGets(SyncRunner->NotifyID(), Conf->VDisks->Get(0), @@ -109,7 +109,7 @@ class TManyMultiPutsActor : public TSyncTestBase { std::shared_ptr> BadSteps; virtual void Scenario(const TActorContext &ctx) { - ui64 tabletId = 0; + ui64 tabletId = DefaultTestTabletId; ui32 channel = 0; ui32 gen = 1; SyncRunner->Run(ctx, CreateManyMultiPuts(Conf, SyncRunner->NotifyID(), Conf->VDisks->Get(0), diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_many.cpp b/ydb/core/blobstorage/ut_vdisk/lib/test_many.cpp index a5ff4a8e03d..b67451af786 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/test_many.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_many.cpp @@ -178,7 +178,7 @@ protected: virtual void Scenario(const TActorContext &ctx) { // load data SyncRunner->Run(ctx, CreateManyPuts(Conf, SyncRunner->NotifyID(), Conf->VDisks->Get(0), MsgSize, MsgNum, - 0, 0, 1, HandleClassGen, BadSteps, TDuration::Seconds(0))); + DefaultTestTabletId, 0, 1, HandleClassGen, BadSteps, TDuration::Seconds(0))); LOG_NOTICE(ctx, NActorsServices::TEST, " Data is loaded"); // wait for compaction @@ -188,8 +188,8 @@ protected: } // range read - TLogoBlobID readFrom(0, 4294967295, 4294967295, 0, 0, 0, TLogoBlobID::MaxPartId); - TLogoBlobID readTo (0, 0, 0, 0, 0, 0, 1); + TLogoBlobID readFrom(DefaultTestTabletId, 4294967295, 4294967295, 0, 0, 0, TLogoBlobID::MaxPartId); + TLogoBlobID readTo (DefaultTestTabletId, 0, 0, 0, 0, 0, 1); SyncRunner->Run(ctx, CreateRangeGet(SyncRunner->NotifyID(), Conf->VDisks->Get(0), readFrom, readTo, IndexOnly, MsgNum)); LOG_NOTICE(ctx, NActorsServices::TEST, " RANGE GET done"); } @@ -230,12 +230,12 @@ protected: virtual void Scenario(const TActorContext &ctx) { // load data 1 SyncRunner->Run(ctx, CreateManyPuts(Conf, SyncRunner->NotifyID(), Conf->VDisks->Get(0), MsgSize, MsgNum, - 0, 0, 1, HandleClassGen1, BadSteps, TDuration::Seconds(0))); + DefaultTestTabletId, 0, 1, HandleClassGen1, BadSteps, TDuration::Seconds(0))); LOG_NOTICE(ctx, NActorsServices::TEST, " Data1 is loaded"); // load data 2 SyncRunner->Run(ctx, CreateManyPuts(Conf, SyncRunner->NotifyID(), Conf->VDisks->Get(0), MsgSize, MsgNum, - 0, 1, 1, HandleClassGen2, BadSteps, TDuration::Seconds(0))); + DefaultTestTabletId, 1, 1, HandleClassGen2, BadSteps, TDuration::Seconds(0))); LOG_NOTICE(ctx, NActorsServices::TEST, " Data2 is loaded"); // wait for compaction @@ -245,8 +245,8 @@ protected: } // range read - TLogoBlobID readFrom(0, 4294967295, 4294967295, 0, 0, 0, TLogoBlobID::MaxPartId); - TLogoBlobID readTo (0, 0, 0, 0, 0, 0, 1); + TLogoBlobID readFrom(DefaultTestTabletId, 4294967295, 4294967295, 0, 0, 0, TLogoBlobID::MaxPartId); + TLogoBlobID readTo (DefaultTestTabletId, 0, 0, 0, 0, 0, 1); SyncRunner->Run(ctx, CreateRangeGet(SyncRunner->NotifyID(), Conf->VDisks->Get(0), readFrom, readTo, IndexOnly, MsgNum)); LOG_NOTICE(ctx, NActorsServices::TEST, " RANGE GET done"); } diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_many.h b/ydb/core/blobstorage/ut_vdisk/lib/test_many.h index c0de6f41fb7..daad480817d 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/test_many.h +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_many.h @@ -14,7 +14,7 @@ struct TManyPutOneGet { const bool WithErrorResponse; TManyPutOneGet(bool waitForCompaction, ui32 msgNum, ui32 msgSize, NKikimrBlobStorage::EPutHandleClass cls, - ui64 tabletId = 0, ui64 shift = 0, bool withErrorResponse = false) + ui64 tabletId = DefaultTestTabletId, ui64 shift = 0, bool withErrorResponse = false) : WaitForCompaction(waitForCompaction) , MsgPacks(new TVector{TMsgPackInfo(msgSize, msgNum)}) , HandleClass(cls) @@ -24,8 +24,8 @@ struct TManyPutOneGet { {} TManyPutOneGet(bool waitForCompaction, std::shared_ptr> msgPacks, - NKikimrBlobStorage::EPutHandleClass cls, ui64 tabletId = 0, ui64 shift = 0, - bool withErrorResponse = false) + NKikimrBlobStorage::EPutHandleClass cls, ui64 tabletId = DefaultTestTabletId, + ui64 shift = 0, bool withErrorResponse = false) : WaitForCompaction(waitForCompaction) , MsgPacks(msgPacks) , HandleClass(cls) @@ -45,7 +45,8 @@ struct TManyPutGet { const NKikimrBlobStorage::EPutHandleClass HandleClass; const ui64 TabletId; - TManyPutGet(bool waitForCompaction, ui32 msgNum, ui32 msgSize, NKikimrBlobStorage::EPutHandleClass cls, ui64 tabletId = 0) + TManyPutGet(bool waitForCompaction, ui32 msgNum, ui32 msgSize, NKikimrBlobStorage::EPutHandleClass cls, + ui64 tabletId = DefaultTestTabletId) : WaitForCompaction(waitForCompaction) , MsgNum(msgNum) , MsgSize(msgSize) @@ -66,7 +67,7 @@ struct TManyMultiPutGet { const ui64 TabletId; TManyMultiPutGet(bool waitForCompaction, ui32 msgNum, ui32 msgSize, ui32 batchSize, - NKikimrBlobStorage::EPutHandleClass cls, ui64 tabletId = 0) + NKikimrBlobStorage::EPutHandleClass cls, ui64 tabletId = DefaultTestTabletId) : WaitForCompaction(waitForCompaction) , MsgNum(msgNum) , MsgSize(msgSize) diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_repl.cpp b/ydb/core/blobstorage/ut_vdisk/lib/test_repl.cpp index b2948fb9049..37982bbd8a7 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/test_repl.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_repl.cpp @@ -352,7 +352,7 @@ SYNC_TEST_END(TTestReplProxyData, TSyncTestWithSmallCommonDataset) SYNC_TEST_BEGIN(TTestReplProxyKeepBits, TSyncTestWithSmallCommonDataset) virtual void Scenario(const TActorContext &ctx) { // prepare gc command - ui64 tabletID = 0; + ui64 tabletID = DefaultTestTabletId; ui32 recGen = 1; ui32 recGenCounter = 1; ui32 channel = 0; @@ -360,7 +360,7 @@ virtual void Scenario(const TActorContext &ctx) { ui32 collectGen = 1; ui32 collectStep = 40; TAutoPtr> keep(new TVector()); - keep->push_back(TLogoBlobID(0, 1, 37, 0, 0, 0)); + keep->push_back(TLogoBlobID(DefaultTestTabletId, 1, 37, 0, 0, 0)); TAutoPtr gcCommand(PutGCToCorrespondingVDisks(SyncRunner->NotifyID(), Conf, tabletID, recGen, recGenCounter, channel, collect, collectGen, collectStep, keep, nullptr)); // set gc settings @@ -390,7 +390,7 @@ SYNC_TEST_BEGIN(TTestHandoffMoveDel, TSyncTestBase) virtual void Scenario(const TActorContext &ctx) { TDataSnapshotPtr data(new TDataSnapshot(Conf->GroupInfo.Get())); TString aaaa("aaaa"); - TLogoBlobID id0(0, 1, 321, 0, aaaa.size(), 0); + TLogoBlobID id0(DefaultTestTabletId, 1, 322, 0, aaaa.size(), 0); // [0:0:0:0:0] - main // [0:0:0:1:1] - main // [0:0:0:2:0] - main @@ -458,7 +458,7 @@ SYNC_TEST_END(TTestHandoffMoveDel, TSyncTestBase) SYNC_TEST_BEGIN(TTestCollectAllSimpleDataset, TSyncTestBase) virtual void Scenario(const TActorContext &ctx) { // prepare gc command - ui64 tabletID = 0; + ui64 tabletID = DefaultTestTabletId; ui32 recGen = 1; ui32 recGenCounter = 1; ui32 channel = 1; diff --git a/ydb/core/blobstorage/ut_vdisk/lib/test_simplebs.cpp b/ydb/core/blobstorage/ut_vdisk/lib/test_simplebs.cpp index 229826e73f0..561844adc7d 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/test_simplebs.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/test_simplebs.cpp @@ -367,8 +367,8 @@ SIMPLE_TEST_BEGIN(TSimple3PutRangeGetAllForward, TBasePut3ForRange) using TBasePut3ForRange::SendReadRequests; void SendReadRequests(const TActorContext &ctx) { ExpectedSetAll(); - TLogoBlobID from(0, 0, 0, 0, 0, 0, 1); - TLogoBlobID to(0, 4294967295, 4294967295, 0, 0, 0, TLogoBlobID::MaxPartId); + TLogoBlobID from(DefaultTestTabletId, 0, 0, 0, 0, 0, 1); + TLogoBlobID to(DefaultTestTabletId, 4294967295, 4294967295, 0, 0, 0, TLogoBlobID::MaxPartId); TBasePut3ForRange::SendReadRequests(ctx, from, to); } SIMPLE_TEST_END(TSimple3PutRangeGetAllForward, TBasePut3ForRange) @@ -378,8 +378,8 @@ SIMPLE_TEST_BEGIN(TSimple3PutRangeGetAllBackward, TBasePut3ForRange) using TBasePut3ForRange::SendReadRequests; void SendReadRequests(const TActorContext &ctx) { ExpectedSetAll(); - TLogoBlobID from(0, 4294967295, 4294967295, 0, 0, 0, TLogoBlobID::MaxPartId); - TLogoBlobID to (0, 0, 0, 0, 0, 0, 1); + TLogoBlobID from(DefaultTestTabletId, 4294967295, 4294967295, 0, 0, 0, TLogoBlobID::MaxPartId); + TLogoBlobID to (DefaultTestTabletId, 0, 0, 0, 0, 0, 1); TBasePut3ForRange::SendReadRequests(ctx, from, to); } SIMPLE_TEST_END(TSimple3PutRangeGetAllBackward, TBasePut3ForRange) @@ -390,8 +390,8 @@ SIMPLE_TEST_BEGIN(TSimple3PutRangeGetNothingForward, TBasePut3ForRange) using TBasePut3ForRange::SendReadRequests; void SendReadRequests(const TActorContext &ctx) { ExpectedSetNothing(); - TLogoBlobID from(1, 0, 0, 0, 0, 0, 1); - TLogoBlobID to(1, 4294967295, 4294967295, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); + TLogoBlobID from(DefaultTestTabletId + 1, 0, 0, 0, 0, 0, 1); + TLogoBlobID to(DefaultTestTabletId + 1, 4294967295, 4294967295, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); TBasePut3ForRange::SendReadRequests(ctx, from, to); } SIMPLE_TEST_END(TSimple3PutRangeGetNothingForward, TBasePut3ForRange) @@ -401,8 +401,8 @@ SIMPLE_TEST_BEGIN(TSimple3PutRangeGetNothingBackward, TBasePut3ForRange) using TBasePut3ForRange::SendReadRequests; void SendReadRequests(const TActorContext &ctx) { ExpectedSetNothing(); - TLogoBlobID from(1, 4294967295, 4294967295, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); - TLogoBlobID to (1, 0, 0, 0, 0, 0, 1); + TLogoBlobID from(DefaultTestTabletId + 1, 4294967295, 4294967295, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); + TLogoBlobID to (DefaultTestTabletId + 1, 0, 0, 0, 0, 0, 1); TBasePut3ForRange::SendReadRequests(ctx, from, to); } SIMPLE_TEST_END(TSimple3PutRangeGetNothingBackward, TBasePut3ForRange) @@ -413,8 +413,8 @@ SIMPLE_TEST_BEGIN(TSimple3PutRangeGetMiddleForward, TBasePut3ForRange) using TBasePut3ForRange::SendReadRequests; void SendReadRequests(const TActorContext &ctx) { ExpectedSetMiddle(); - TLogoBlobID from(0, 1, 17, 0, 0, 0, 1); - TLogoBlobID to (0, 1, 32, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); + TLogoBlobID from(DefaultTestTabletId, 1, 17, 0, 0, 0, 1); + TLogoBlobID to (DefaultTestTabletId, 1, 32, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); TBasePut3ForRange::SendReadRequests(ctx, from, to); } SIMPLE_TEST_END(TSimple3PutRangeGetMiddleForward, TBasePut3ForRange) @@ -424,8 +424,8 @@ SIMPLE_TEST_BEGIN(TSimple3PutRangeGetMiddleBackward, TBasePut3ForRange) using TBasePut3ForRange::SendReadRequests; void SendReadRequests(const TActorContext &ctx) { ExpectedSetMiddle(); - TLogoBlobID from(0, 1, 32, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); - TLogoBlobID to (0, 1, 17, 0, 0, 0, 1); + TLogoBlobID from(DefaultTestTabletId, 1, 32, 0, TLogoBlobID::MaxBlobSize, 0, TLogoBlobID::MaxPartId); + TLogoBlobID to (DefaultTestTabletId, 1, 17, 0, 0, 0, 1); TBasePut3ForRange::SendReadRequests(ctx, from, to); } SIMPLE_TEST_END(TSimple3PutRangeGetMiddleBackward, TBasePut3ForRange) @@ -464,7 +464,7 @@ public: : TActorBootstrapped() , Conf(conf) , VDiskInfo(Conf->VDisks->Get(0)) - , LogoBlobID1(0, 1, 1, 0, 0, 0) + , LogoBlobID1(DefaultTestTabletId, 1, 1, 0, 0, 0) {} }; @@ -484,8 +484,8 @@ class TRangeGetFromEmptyDBActor : public TActorBootstrapped #include #include +#include #include #include #include @@ -262,14 +263,14 @@ Y_UNIT_TEST_SUITE(TBsVDiskManyPutGetCheckSize) { TMsgPackInfo(100'000, 672), TMsgPackInfo(17'026, 1) })); - TManyPutOneGet testOk(false, msgPacks, UNK, 0, 257, false); + TManyPutOneGet testOk(false, msgPacks, UNK, DefaultTestTabletId, 257, false); TestRun(&testOk, TDuration::Minutes(100), DefChunkSize, DefDiskSize, 1, 1, NKikimr::TErasureType::ErasureNone); std::shared_ptr> failMsgPacks(std::unique_ptr>(new TVector{ TMsgPackInfo(100'000, 672), TMsgPackInfo(17'027, 1) })); - TManyPutOneGet testError(false, failMsgPacks, UNK, 0, 257, true); + TManyPutOneGet testError(false, failMsgPacks, UNK, DefaultTestTabletId, 257, true); TestRun(&testError, TDuration::Minutes(100), DefChunkSize, DefDiskSize, 1, 1, NKikimr::TErasureType::ErasureNone); } @@ -855,3 +856,15 @@ Y_UNIT_TEST_SUITE(TBsVDiskRepl3) { UNIT_ASSERT(success1); } } + +/////////////////////////////////////////////////////////////////////////////////////////////////////// +// BAD BLOBID +/////////////////////////////////////////////////////////////////////////////////////////////////////// +Y_UNIT_TEST_SUITE(TBsVDiskBadBlobId) { + // Ensure that putting blob with bad id results in ERROR status + + Y_UNIT_TEST(PutBlobWithBadId) { + TWriteAndExpectError test; + TestRun(&test, TIMEOUT); + } +} diff --git a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp index 47b6b14f35d..1b04bfab2fb 100644 --- a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp +++ b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp @@ -448,6 +448,13 @@ namespace NKikimr { return {NKikimrProto::ERROR, "buffer is too large"}; } + if (id.TabletID() == 0) { + LOG_ERROR_S(ctx, BS_VDISK_PUT, VCtx->VDiskLogPrefix << evPrefix << ": TabletID cannot be empty;" + << " id# " << id + << " Marker# BSVS43"); + return {NKikimrProto::ERROR, "empty TabletID"}; + } + auto status = Hull->CheckLogoBlob(ctx, id, ignoreBlock, extraBlockChecks, writtenBeyondBarrier); if (status.Status != NKikimrProto::OK) { LOG_ERROR_S(ctx, BS_VDISK_PUT, VCtx->VDiskLogPrefix << evPrefix << ": failed to pass the Hull check;" -- cgit v1.3