Skip to content

Commit 8d6cc99

Browse files
authored
Merge 7711c80 into b6b1333
2 parents b6b1333 + 7711c80 commit 8d6cc99

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1002
-1479
lines changed

ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@ ui32 TBlobStorageGroupInfo::TTopology::GetIdxInSubgroup(const TVDiskIdShort& vdi
420420
return BlobMapper->GetIdxInSubgroup(vdisk, hash);
421421
}
422422

423+
bool TBlobStorageGroupInfo::TTopology::IsHandoff(const TVDiskIdShort& vdisk, ui32 hash) const {
424+
return BlobMapper->GetIdxInSubgroup(vdisk, hash) >= GType.TotalPartCount();
425+
}
426+
423427
TVDiskIdShort TBlobStorageGroupInfo::TTopology::GetVDiskInSubgroup(ui32 idxInSubgroup, ui32 hash) const {
424428
return BlobMapper->GetVDiskInSubgroup(idxInSubgroup, hash);
425429
}

ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ class TBlobStorageGroupInfo : public TThrRefBase {
250250
// function returns idxInSubgroup-th element of vdisks array from PickSubgroup
251251
TVDiskIdShort GetVDiskInSubgroup(ui32 idxInSubgroup, ui32 hash) const;
252252

253+
bool IsHandoff(const TVDiskIdShort& vdisk, ui32 hash) const;
254+
253255

254256
TFailRealmIterator FailRealmsBegin() const;
255257
TFailRealmIterator FailRealmsEnd() const;

ydb/core/blobstorage/ut_blobstorage/balancing.cpp

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct TTestEnv {
6060
return data;
6161
};
6262

63-
void SendPut(ui32 step, const TString& data, NKikimrProto::EReplyStatus expectedStatus) {
63+
NKikimrProto::EReplyStatus SendPut(ui32 step, const TString& data) {
6464
const TLogoBlobID id(1, 1, step, 0, data.size(), 0);
6565
Cerr << "SEND TEvPut with key " << id.ToString() << Endl;
6666
const TActorId sender = Env.Runtime->AllocateEdgeActor(GroupInfo->GetActorId(*RunningNodes.begin()).NodeId(), __FILE__, __LINE__);
@@ -69,8 +69,12 @@ struct TTestEnv {
6969
SendToBSProxy(sender, GroupInfo->GroupID, ev.release());
7070
});
7171
auto res = Env.WaitForEdgeActorEvent<TEvBlobStorage::TEvPutResult>(sender, false);
72-
UNIT_ASSERT_VALUES_EQUAL(res->Get()->Status, expectedStatus);
7372
Cerr << "TEvPutResult: " << res->Get()->ToString() << Endl;
73+
return res->Get()->Status;
74+
};
75+
76+
void SendPut(ui32 step, const TString& data, NKikimrProto::EReplyStatus expectedStatus) {
77+
UNIT_ASSERT_VALUES_EQUAL(SendPut(step, data), expectedStatus);
7478
};
7579

7680
auto SendGet(ui32 step, ui32 dataSize, bool mustRestoreFirst=false) {
@@ -114,7 +118,6 @@ struct TTestEnv {
114118
const TActorId sender = Env.Runtime->AllocateEdgeActor(GroupInfo->GetActorId(*RunningNodes.begin()).NodeId(), __FILE__, __LINE__);
115119
TVector<ui32> partsRes;
116120

117-
Cerr << "Get request for vdisk " << position << Endl;
118121
auto queueId = GetQueue(vDiskId);
119122
Env.Runtime->WrapInActorContext(sender, [&] {
120123
Env.Runtime->Send(new IEventHandle(queueId, sender, ev.release()));
@@ -244,13 +247,6 @@ struct TStopOneNodeTest {
244247
Env->Sim(TDuration::Seconds(10));
245248
Cerr << "Finish compaction 2" << Endl;
246249

247-
Cerr << "Start compaction 3" << Endl;
248-
for (ui32 pos = 0; pos < Env->Settings.NodeCount; ++pos) {
249-
Env->CompactVDisk(Env.GroupInfo->GetActorId(pos));
250-
}
251-
Env->Sim(TDuration::Seconds(10));
252-
Cerr << "Finish compaction 3" << Endl;
253-
254250
Env.CheckPartsLocations(MakeLogoBlobId(step, data.size()));
255251
UNIT_ASSERT_VALUES_EQUAL(Env.SendGet(step, data.size())->Get()->Responses[0].Buffer.ConvertToString(), data);
256252
}
@@ -264,21 +260,23 @@ struct TRandomTest {
264260
void RunTest() {
265261
TVector<TString> data(Reserve(NumIters));
266262

263+
TVector<ui32> successfulSteps;
264+
267265
for (ui32 step = 0; step < NumIters; ++step) {
268-
Cerr << step << Endl;
266+
Cerr << "Step = " << step << Endl;
269267
data.push_back(GenData(16 + random() % 4096));
270-
auto blobId = MakeLogoBlobId(step, data.back().size());
271-
auto locations = Env.GetExpectedPartsLocations(blobId);
268+
269+
if (Env.SendPut(step, data.back()) == NKikimrProto::OK) {
270+
successfulSteps.push_back(step);
271+
}
272272

273273
if (random() % 10 == 1 && Env.RunningNodes.size() + 2 > Env->Settings.NodeCount) {
274-
ui32 nodeId = random() % Env->Settings.NodeCount;
275-
Cerr << "Stop node " << nodeId << Endl;
276-
Env.StopNode(nodeId);
274+
ui32 pos = random() % Env->Settings.NodeCount;
275+
Cerr << "Stop node " << pos << Endl;
276+
Env.StopNode(pos);
277277
Env->Sim(TDuration::Seconds(10));
278278
}
279279

280-
Env.SendPut(step, data.back(), NKikimrProto::OK);
281-
282280
if (random() % 10 == 1) {
283281
for (ui32 pos = 0; pos < Env->Settings.NodeCount; ++pos) {
284282
if (!Env.RunningNodes.contains(pos)) {
@@ -293,6 +291,7 @@ struct TRandomTest {
293291
if (random() % 50 == 1) {
294292
ui32 pos = random() % Env->Settings.NodeCount;
295293
if (Env.RunningNodes.contains(pos)) {
294+
Cerr << "Compact vdisk " << pos << Endl;
296295
Env->CompactVDisk(Env.GroupInfo->GetActorId(pos));
297296
Env->Sim(TDuration::Seconds(10));
298297
}
@@ -302,6 +301,7 @@ struct TRandomTest {
302301
if (random() % 100 == 1) {
303302
ui32 pos = random() % Env->Settings.NodeCount;
304303
if (Env.RunningNodes.contains(pos)) {
304+
Cerr << "Wipe node " << pos << Endl;
305305
auto baseConfig = Env->FetchBaseConfig();
306306
const auto& somePDisk = baseConfig.GetPDisk(pos);
307307
const auto& someVSlot = baseConfig.GetVSlot(pos);
@@ -311,14 +311,29 @@ struct TRandomTest {
311311
}
312312
}
313313

314+
UNIT_ASSERT(successfulSteps.size() > NumIters / 2);
315+
316+
Cerr << "Starting nodes" << Endl;
314317
for (ui32 pos = 0; pos < Env->Settings.NodeCount; ++pos) {
315318
Env.StartNode(pos);
316319
}
320+
Env->Sim(TDuration::Seconds(10));
321+
322+
Cerr << "Start compaction 1" << Endl;
323+
for (ui32 pos = 0; pos < Env->Settings.NodeCount; ++pos) {
324+
Env->CompactVDisk(Env.GroupInfo->GetActorId(pos));
325+
}
326+
Env->Sim(TDuration::Seconds(60));
327+
328+
Cerr << "Start compaction 2" << Endl;
329+
for (ui32 pos = 0; pos < Env->Settings.NodeCount; ++pos) {
330+
Env->CompactVDisk(Env.GroupInfo->GetActorId(pos));
331+
}
332+
Env->Sim(TDuration::Seconds(60));
317333

318-
Env->Sim(TDuration::Seconds(300));
319334
Cerr << "Start checking" << Endl;
320-
for (ui32 step = 0; step < NumIters; ++step) {
321-
Cerr << step << Endl;
335+
for (ui32 step: successfulSteps) {
336+
Cerr << "step = " << step << Endl;
322337
Env.CheckPartsLocations(MakeLogoBlobId(step, data[step].size()));
323338
UNIT_ASSERT_VALUES_EQUAL(Env.SendGet(step, data[step].size())->Get()->Responses[0].Buffer.ConvertToString(), data[step]);
324339
}
@@ -336,7 +351,7 @@ Y_UNIT_TEST_SUITE(VDiskBalancing) {
336351
TStopOneNodeTest{TTestEnv(9, TBlobStorageGroupType::ErasureMirror3dc), GenData(100)}.RunTest();
337352
}
338353
Y_UNIT_TEST(TestStopOneNode_Block42_HugeBlob) {
339-
TStopOneNodeTest{TTestEnv(8, TBlobStorageGroupType::Erasure4Plus2Block), GenData(521_KB)}.RunTest();
354+
TStopOneNodeTest{TTestEnv(8, TBlobStorageGroupType::Erasure4Plus2Block), GenData(521_KB * 6)}.RunTest();
340355
}
341356
Y_UNIT_TEST(TestStopOneNode_Mirror3dc_HugeBlob) {
342357
TStopOneNodeTest{TTestEnv(9, TBlobStorageGroupType::ErasureMirror3dc), GenData(521_KB)}.RunTest();

ydb/core/blobstorage/ut_blobstorage/lib/env.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ struct TEnvironmentSetup {
275275
// NKikimrServices::LOCAL,
276276
// NActorsServices::INTERCONNECT,
277277
// NActorsServices::INTERCONNECT_SESSION,
278+
// NKikimrServices::BS_VDISK_BALANCING,
278279
};
279280
for (const auto& comp : debug) {
280281
Runtime->SetLogPriority(comp, NLog::PRI_DEBUG);

ydb/core/blobstorage/ut_blobstorage/ut_balancing/ya.make

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
UNITTEST_FOR(ydb/core/blobstorage/ut_blobstorage)
2-
SKIP_TEST(VDisks balancing is not implemented yet)
32

43
SIZE(MEDIUM)
54

5+
FORK_SUBTESTS()
6+
67
TIMEOUT(600)
78

89
SRCS(

ydb/core/blobstorage/ut_vdisk/lib/prepare.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ TDefaultVDiskSetup::TDefaultVDiskSetup() {
236236
cfg->SyncJobTimeout = TDuration::Seconds(20);
237237
cfg->RunSyncer = true;
238238
cfg->ReplTimeInterval = TDuration::Seconds(10);
239-
cfg->RunHandoff = true;
240239
cfg->SkeletonFrontQueueBackpressureCheckMsgId = false;
241240
};
242241
AddConfigModifier(modifier);

ydb/core/blobstorage/ut_vdisk/lib/setup.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ struct TFastVDiskSetupHndOff : public TFastVDiskSetup {
6666
TFastVDiskSetupHndOff() {
6767
auto modifier = [] (NKikimr::TVDiskConfig *cfg) {
6868
cfg->HullCompLevelRateThreshold = 0.01; // to compact very few chunks from level 0
69-
cfg->RunHandoff = false; // do not run handoff
7069
};
7170
AddConfigModifier(modifier);
7271
}
@@ -82,12 +81,7 @@ struct TFastVDiskSetupCompacted : public TFastVDiskSetup {
8281
};
8382

8483
struct TFastVDiskSetupCompactedHndOff : public TFastVDiskSetupCompacted {
85-
TFastVDiskSetupCompactedHndOff() {
86-
auto modifier = [] (NKikimr::TVDiskConfig *cfg) {
87-
cfg->RunHandoff = false; // do not run handoff
88-
};
89-
AddConfigModifier(modifier);
90-
}
84+
TFastVDiskSetupCompactedHndOff() = default;
9185
};
9286

9387
struct TFastCompactionGCNoSyncVDiskSetup : public TFastVDiskSetup {

ydb/core/blobstorage/ut_vdisk/lib/test_synclog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class TSyncLogTestWriteActor : public TActorBootstrapped<TSyncLogTestWriteActor>
170170
VDiskConfig = vDiskInstance.Cfg;
171171
TestCtx->SelfVDiskId = groupInfo->GetVDiskId(VCtx->ShortSelfVDisk);
172172

173-
Db = MakeIntrusive<TDb>(VDiskConfig, groupInfo, VCtx);
173+
Db = MakeIntrusive<TDb>(VDiskConfig, VCtx);
174174

175175
ctx.Send(VDiskConfig->BaseInfo.PDiskActorID,
176176
new NPDisk::TEvYardInit(2, TestCtx->SelfVDiskId, VDiskConfig->BaseInfo.PDiskGuid));

ydb/core/blobstorage/vdisk/anubis_osiris/blobstorage_anubis_osiris.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
namespace NKikimr {
88

9+
// prepared data to insert to Hull Database
10+
struct THullDbInsert {
11+
TLogoBlobID Id;
12+
TIngress Ingress;
13+
};
14+
915
struct TAnubisOsirisPutRecoveryLogRec;
1016

1117
////////////////////////////////////////////////////////////////////////////
@@ -47,12 +53,6 @@ namespace NKikimr {
4753
return !IsAnubis();
4854
}
4955

50-
// prepared data to insert to Hull Database
51-
struct THullDbInsert {
52-
TLogoBlobID Id;
53-
TIngress Ingress;
54-
};
55-
5656
// return data to insert to Hull Database, we create ingress according to whether this
5757
// blob is Anubis or Osiris record
5858
THullDbInsert PrepareInsert(const TBlobStorageGroupInfo::TTopology *top,

0 commit comments

Comments
 (0)