Skip to content

Commit 0ee880e

Browse files
authored
DSProxyDiscover: fix bugs, more tests (#19764)
1 parent 9ac8c8c commit 0ee880e

File tree

8 files changed

+172
-95
lines changed

8 files changed

+172
-95
lines changed

ydb/core/blobstorage/dsproxy/dsproxy_discover.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -790,17 +790,6 @@ class TBlobStorageGroupDiscoverRequest : public TBlobStorageGroupRequestActor {
790790

791791
DSP_LOG_ALERT_S("BSD18", str.Str());
792792

793-
if (FromLeader) {
794-
Sleep(TDuration::Seconds(1));
795-
796-
str << " logacc# ";
797-
LogCtx.LogAcc.Output(str);
798-
str << " verboseNoData# ";
799-
str << msg->DebugInfo;
800-
801-
Y_ABORT_UNLESS(false, "%s", str.Str().data());
802-
}
803-
804793
IsGetDataDone = true;
805794
if (IsGetBlockDone) {
806795
DSP_LOG_ERROR_S("BSD19", "Handle TEvGetResult Die. status# "

ydb/core/blobstorage/dsproxy/dsproxy_discover_m3dc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,8 @@ class TBlobStorageGroupMirror3dcDiscoverRequest : public TBlobStorageGroupReques
502502
SendToQueue(std::move(query), 0);
503503
++RequestsInFlight;
504504
}
505+
} else {
506+
GetBlockFinished = true;
505507
}
506508

507509
// initial kick for workers -- send messages to corresponding VDisks

ydb/core/blobstorage/dsproxy/ut/dsproxy_counters_ut.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Y_UNIT_TEST(PutGeneratedSubrequestBytes) {
3737
SetupRuntime(runtime);
3838
TDSProxyEnv env;
3939
env.Configure(runtime, erasure, 1, 0);
40-
TTestState testState(runtime, erasure, env.Info);
40+
TTestState testState(runtime, env.Info);
4141

4242
TEvBlobStorage::TEvPut::ETactic tactic = TEvBlobStorage::TEvPut::TacticDefault;
4343
NKikimrBlobStorage::EPutHandleClass handleClass = NKikimrBlobStorage::TabletLog;
@@ -92,7 +92,7 @@ Y_UNIT_TEST(MultiPutGeneratedSubrequestBytes) {
9292
SetupRuntime(runtime);
9393
TDSProxyEnv env;
9494
env.Configure(runtime, erasure, 1, 0);
95-
TTestState testState(runtime, erasure, env.Info);
95+
TTestState testState(runtime, env.Info);
9696

9797
TEvBlobStorage::TEvPut::ETactic tactic = TEvBlobStorage::TEvPut::TacticDefault;
9898
NKikimrBlobStorage::EPutHandleClass handleClass = NKikimrBlobStorage::TabletLog;

ydb/core/blobstorage/dsproxy/ut/dsproxy_discover_ut.cpp

Lines changed: 98 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Y_UNIT_TEST(Block42Success) {
1919
SetupRuntime(runtime);
2020
TDSProxyEnv env;
2121
env.Configure(runtime, type, 0, 0, TBlobStorageGroupInfo::EEM_NONE);
22-
TTestState testState(runtime, type, env.Info);
22+
TTestState testState(runtime, env.Info);
2323

2424
const ui64 tabletId = 72075186224047637;
2525
TLogoBlobID blobId1(tabletId, 1, 1, 0, testState.BlobSize, 0);
@@ -37,6 +37,7 @@ Y_UNIT_TEST(Block42Success) {
3737
testState.HandleVGetsWithMock(8); // get the blob
3838

3939
TEvBlobStorage::TEvDiscoverResult::TPtr ev = testState.GrabEventPtr<TEvBlobStorage::TEvDiscoverResult>();
40+
UNIT_ASSERT_VALUES_EQUAL(ev->Get()->Status, NKikimrProto::OK);
4041
UNIT_ASSERT_VALUES_EQUAL(ev->Get()->Id, blobId2);
4142
}
4243

@@ -46,15 +47,14 @@ Y_UNIT_TEST(Block42SuccessLastBlobMissingParts) {
4647
SetupRuntime(runtime);
4748
TDSProxyEnv env;
4849
env.Configure(runtime, type, 0, 0, TBlobStorageGroupInfo::EEM_NONE);
49-
TTestState testState(runtime, type, env.Info);
50+
TTestState testState(runtime, env.Info);
5051

5152
const ui64 tabletId = 72075186224047637;
5253
TLogoBlobID blobId1(tabletId, 1, 1, 0, testState.BlobSize, 0);
5354
TLogoBlobID blobId2(tabletId, 1, 2, 0, testState.BlobSize, 0);
5455

5556
TGroupMock& groupMock = testState.GetGroupMock();
5657
groupMock.Put(blobId1, testState.BlobData);
57-
// FIXIT: if parts are 1 2 3 4 then 5 and 6 part are restored twice
5858
THashSet<ui32> selectedParts{3, 4, 5, 6};
5959
groupMock.Put(blobId2, testState.BlobData, 0, &selectedParts);
6060

@@ -67,6 +67,7 @@ Y_UNIT_TEST(Block42SuccessLastBlobMissingParts) {
6767
testState.HandleVPutsWithMock(2); // restore puts
6868

6969
TEvBlobStorage::TEvDiscoverResult::TPtr ev = testState.GrabEventPtr<TEvBlobStorage::TEvDiscoverResult>();
70+
UNIT_ASSERT_VALUES_EQUAL(ev->Get()->Status, NKikimrProto::OK);
7071
UNIT_ASSERT_VALUES_EQUAL(ev->Get()->Id, blobId2);
7172
}
7273

@@ -76,7 +77,7 @@ Y_UNIT_TEST(Block42SuccessLastBlobNotFullyWritten) {
7677
SetupRuntime(runtime);
7778
TDSProxyEnv env;
7879
env.Configure(runtime, type, 0, 0, TBlobStorageGroupInfo::EEM_NONE);
79-
TTestState testState(runtime, type, env.Info);
80+
TTestState testState(runtime, env.Info);
8081

8182
const ui64 tabletId = 72075186224047637;
8283
TLogoBlobID blobId1(tabletId, 1, 1, 0, testState.BlobSize, 0);
@@ -95,18 +96,17 @@ Y_UNIT_TEST(Block42SuccessLastBlobNotFullyWritten) {
9596
testState.HandleVGetsWithMock(8);
9697

9798
TEvBlobStorage::TEvDiscoverResult::TPtr ev = testState.GrabEventPtr<TEvBlobStorage::TEvDiscoverResult>();
99+
UNIT_ASSERT_VALUES_EQUAL(ev->Get()->Status, NKikimrProto::OK);
98100
UNIT_ASSERT_VALUES_EQUAL(ev->Get()->Id, blobId1);
99101
}
100102

101-
// FIXIT: this test crashes in DSProxy
102-
/*
103-
Y_UNIT_TEST(Block42ProxyCrashWhileGettingTheBlob) {
103+
Y_UNIT_TEST(Block42ErrorWhenBlobIsLostAfterDiscover) {
104104
TBlobStorageGroupType type(TErasureType::Erasure4Plus2Block);
105105
TTestBasicRuntime runtime;
106106
SetupRuntime(runtime);
107107
TDSProxyEnv env;
108108
env.Configure(runtime, type, 0, 0, TBlobStorageGroupInfo::EEM_NONE);
109-
TTestState testState(runtime, type, env.Info);
109+
TTestState testState(runtime, env.Info);
110110

111111
const ui64 tabletId = 72075186224047637;
112112
TLogoBlobID blobId1(tabletId, 1, 1, 0, testState.BlobSize, 0);
@@ -126,9 +126,97 @@ Y_UNIT_TEST(Block42ProxyCrashWhileGettingTheBlob) {
126126
testState.HandleVGetsWithMock(8);
127127

128128
TEvBlobStorage::TEvDiscoverResult::TPtr ev = testState.GrabEventPtr<TEvBlobStorage::TEvDiscoverResult>();
129-
UNIT_ASSERT_VALUES_EQUAL(ev->Get()->Id, blobId1);
129+
UNIT_ASSERT_VALUES_EQUAL(ev->Get()->Status, NKikimrProto::ERROR);
130+
}
131+
132+
Y_UNIT_TEST(Mirror3dcSuccess) {
133+
TBlobStorageGroupType type(TErasureType::ErasureMirror3dc);
134+
TTestBasicRuntime runtime;
135+
SetupRuntime(runtime);
136+
TDSProxyEnv env;
137+
env.Configure(runtime, type, 0, 0, TBlobStorageGroupInfo::EEM_NONE);
138+
TTestState testState(runtime, env.Info);
139+
140+
const ui64 tabletId = 72075186224047637;
141+
TLogoBlobID blobId1(tabletId, 1, 1, 0, testState.BlobSize, 0);
142+
TLogoBlobID blobId2(tabletId, 1, 2, 0, testState.BlobSize, 0);
143+
144+
TGroupMock& groupMock = testState.GetGroupMock();
145+
groupMock.Put(blobId1, testState.BlobData);
146+
groupMock.Put(blobId2, testState.BlobData);
147+
148+
auto discover = std::make_unique<TEvBlobStorage::TEvDiscover>(
149+
tabletId, 1, true, false, TInstant::Max(), 0, true);
150+
runtime.Send(new IEventHandle(env.RealProxyActorId, testState.EdgeActor, discover.release()), 0, true);
151+
152+
testState.HandleVGetsWithMock(9);
153+
testState.HandleVGetsWithMock(9);
154+
testState.HandleVPutsWithMock(1);
155+
156+
TEvBlobStorage::TEvDiscoverResult::TPtr ev = testState.GrabEventPtr<TEvBlobStorage::TEvDiscoverResult>();
157+
UNIT_ASSERT_VALUES_EQUAL(ev->Get()->Status, NKikimrProto::OK);
158+
UNIT_ASSERT_VALUES_EQUAL(ev->Get()->Id, blobId2);
159+
}
160+
161+
Y_UNIT_TEST(Mirror3dcSuccessLastBlobMissingParts) {
162+
TBlobStorageGroupType type(TErasureType::ErasureMirror3dc);
163+
TTestBasicRuntime runtime;
164+
SetupRuntime(runtime);
165+
TDSProxyEnv env;
166+
env.Configure(runtime, type, 0, 0, TBlobStorageGroupInfo::EEM_NONE);
167+
TTestState testState(runtime, env.Info);
168+
169+
const ui64 tabletId = 72075186224047637;
170+
TLogoBlobID blobId1(tabletId, 1, 1, 0, testState.BlobSize, 0);
171+
TLogoBlobID blobId2(tabletId, 1, 2, 0, testState.BlobSize, 0);
172+
173+
TGroupMock& groupMock = testState.GetGroupMock();
174+
groupMock.Put(blobId1, testState.BlobData);
175+
THashSet<ui32> selectedParts{1};
176+
groupMock.Put(blobId2, testState.BlobData, 0, &selectedParts);
177+
178+
auto discover = std::make_unique<TEvBlobStorage::TEvDiscover>(
179+
tabletId, 1, true, false, TInstant::Max(), 0, true);
180+
runtime.Send(new IEventHandle(env.RealProxyActorId, testState.EdgeActor, discover.release()), 0, true);
181+
182+
testState.HandleVGetsWithMock(9);
183+
testState.HandleVGetsWithMock(9);
184+
testState.HandleVPutsWithMock(3);
185+
186+
TEvBlobStorage::TEvDiscoverResult::TPtr ev = testState.GrabEventPtr<TEvBlobStorage::TEvDiscoverResult>();
187+
UNIT_ASSERT_VALUES_EQUAL(ev->Get()->Status, NKikimrProto::OK);
188+
UNIT_ASSERT_VALUES_EQUAL(ev->Get()->Id, blobId2);
189+
}
190+
191+
Y_UNIT_TEST(Mirror3dcErrorWhenBlobIsLostAfterDiscover) {
192+
TBlobStorageGroupType type(TErasureType::ErasureMirror3dc);
193+
TTestBasicRuntime runtime;
194+
SetupRuntime(runtime);
195+
TDSProxyEnv env;
196+
env.Configure(runtime, type, 0, 0, TBlobStorageGroupInfo::EEM_NONE);
197+
TTestState testState(runtime, env.Info);
198+
199+
const ui64 tabletId = 72075186224047637;
200+
TLogoBlobID blobId1(tabletId, 1, 1, 0, testState.BlobSize, 0);
201+
TLogoBlobID blobId2(tabletId, 1, 2, 0, testState.BlobSize, 0);
202+
203+
TGroupMock& groupMock = testState.GetGroupMock();
204+
groupMock.Put(blobId1, testState.BlobData);
205+
groupMock.Put(blobId2, testState.BlobData);
206+
207+
auto discover = std::make_unique<TEvBlobStorage::TEvDiscover>(
208+
tabletId, 1, true, false, TInstant::Max(), 0, true);
209+
runtime.Send(new IEventHandle(env.RealProxyActorId, testState.EdgeActor, discover.release()), 0, true);
210+
211+
testState.HandleVGetsWithMock(9);
212+
testState.GroupMock.SetError(TVDiskID(0, 1, 0, 0, 0), NKikimrProto::ERROR);
213+
testState.GroupMock.SetError(TVDiskID(0, 1, 1, 0, 0), NKikimrProto::NOT_YET);
214+
testState.GroupMock.SetError(TVDiskID(0, 1, 2, 0, 0), NKikimrProto::NOT_YET);
215+
testState.HandleVGetsWithMock(9);
216+
217+
TEvBlobStorage::TEvDiscoverResult::TPtr ev = testState.GrabEventPtr<TEvBlobStorage::TEvDiscoverResult>();
218+
UNIT_ASSERT_VALUES_EQUAL(ev->Get()->Status, NKikimrProto::ERROR);
130219
}
131-
*/
132220

133221
} // TDSProxyDiscover
134222

ydb/core/blobstorage/dsproxy/ut/dsproxy_put_ut.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void TestPutMaxPartCountOnHandoff(TErasureType::EErasureSpecies erasureSpecies)
3535
TBlobStorageGroupType groupType(erasureSpecies);
3636
const ui32 domainCount = groupType.BlobSubgroupSize();;
3737

38-
TGroupMock group(groupId, erasureSpecies, 1, domainCount, 1);
38+
TGroupMock group(groupId, erasureSpecies, domainCount, 1, 1);
3939
TIntrusivePtr<TGroupQueues> groupQueues = group.MakeGroupQueues();
4040

4141
TIntrusivePtr<::NMonitoring::TDynamicCounters> counters(new ::NMonitoring::TDynamicCounters());
@@ -393,7 +393,7 @@ void TestPutResultWithVDiskResults(TBlobStorageGroupType type, TMap<TVDiskID, NK
393393
SetupRuntime(runtime);
394394
TDSProxyEnv env;
395395
env.Configure(runtime, type, 0, 0);
396-
TTestState testState(runtime, type, env.Info);
396+
TTestState testState(runtime, env.Info);
397397

398398
TLogoBlobID blobId(72075186224047637, 1, 863, 1, 786, 24576);
399399
TStringBuilder dataBuilder;

ydb/core/blobstorage/dsproxy/ut/dsproxy_sequence_ut.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ Y_UNIT_TEST(TestBlock42PutWithChangingSlowDisk) {
425425
TBlobStorageGroupType type = {TErasureType::Erasure4Plus2Block};
426426
TTestBasicRuntime runtime(1, false);
427427
Setup(runtime, type);
428-
TTestState testState(runtime, type, DSProxyEnv.Info);
428+
TTestState testState(runtime, DSProxyEnv.Info);
429429

430430
TLogoBlobID blobId(72075186224047637, 1, 863, 1, 786, 24576);
431431

@@ -500,7 +500,7 @@ Y_UNIT_TEST(TestBlock42PutWithChangingSlowDisk) {
500500
void MakeTestMultiPutItemStatuses(TTestBasicRuntime &runtime, const TBlobStorageGroupType &type,
501501
const TBatchedVec<NKikimrProto::EReplyStatus> &statuses) {
502502
TString data("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
503-
TTestState testState(runtime, type, DSProxyEnv.Info);
503+
TTestState testState(runtime, DSProxyEnv.Info);
504504

505505
TVector<TLogoBlobID> blobIds = {
506506
TLogoBlobID(72075186224047637, 1, 863, 1, 786, 24576),
@@ -599,7 +599,7 @@ Y_UNIT_TEST(TestGivenBlock42GroupGenerationGreaterThanVDiskGenerations) {
599599
Setup(runtime, type);
600600

601601
TString data("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
602-
TTestState testState(runtime, type, DSProxyEnv.Info);
602+
TTestState testState(runtime, DSProxyEnv.Info);
603603

604604
TVector<TLogoBlobID> blobIds = {
605605
TLogoBlobID(72075186224047637, 1, 863, 1, 786, 24576),
@@ -649,7 +649,7 @@ Y_UNIT_TEST(TestGivenMirror3DCGetWithFirstSlowDisk) {
649649

650650
TLogoBlobID blobId = TLogoBlobID(72075186224047637, 1, 2194, 1, 142, 12288);
651651

652-
TTestState testState(runtime, type, DSProxyEnv.Info);
652+
TTestState testState(runtime, DSProxyEnv.Info);
653653

654654
TEvBlobStorage::TEvGet::TPtr ev = testState.CreateGetRequest({blobId}, false);
655655
TActorId getActorId = runtime.Register(DSProxyEnv.CreateGetRequestActor(ev, NKikimrBlobStorage::TabletLog).release());

ydb/core/blobstorage/dsproxy/ut/dsproxy_test_state_ut.h

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,17 @@ namespace NKikimr {
1111
struct TTestState {
1212
TTestActorRuntime &Runtime;
1313
TActorId EdgeActor;
14-
TBlobStorageGroupType Type;
15-
TGroupMock GroupMock;
1614
TIntrusivePtr<TBlobStorageGroupInfo> Info;
15+
TGroupMock GroupMock;
1716

1817
const ui32 BlobSize;
1918
TString BlobData;
2019

21-
TTestState(TTestActorRuntime &runtime, const TBlobStorageGroupType &type,
22-
TIntrusivePtr<TBlobStorageGroupInfo> &info, ui64 nodeIndex = 0, ui32 blobSize = 1024)
20+
TTestState(TTestActorRuntime &runtime, TIntrusivePtr<TBlobStorageGroupInfo> &info, ui64 nodeIndex = 0, ui32 blobSize = 1024)
2321
: Runtime(runtime)
2422
, EdgeActor(runtime.AllocateEdgeActor(nodeIndex))
25-
, Type(type)
26-
, GroupMock(0, Type.GetErasure(), Type.BlobSubgroupSize(), 1, info)
2723
, Info(info)
28-
, BlobSize(blobSize)
29-
{
30-
FillBlobData();
31-
}
32-
33-
TTestState(TTestActorRuntime &runtime, const TBlobStorageGroupType &type, ui64 nodeIndex = 0,
34-
ui32 failRealms = 1, ui32 blobSize = 1024)
35-
: Runtime(runtime)
36-
, EdgeActor(runtime.AllocateEdgeActor(nodeIndex))
37-
, Type(type)
38-
, GroupMock(0, Type.GetErasure(), failRealms, Type.BlobSubgroupSize(), 1)
39-
, Info(GroupMock.GetInfo())
24+
, GroupMock(0, info)
4025
, BlobSize(blobSize)
4126
{
4227
FillBlobData();
@@ -58,9 +43,9 @@ struct TTestState {
5843

5944
TPartLocation HandoffVDiskForBlobPart(TLogoBlobID blobId, ui64 handoffIdx) {
6045
Y_ABORT_UNLESS(blobId.PartId());
61-
Y_ABORT_UNLESS(handoffIdx < Type.Handoff());
46+
Y_ABORT_UNLESS(handoffIdx < Info->Type.Handoff());
6247
TLogoBlobID origBlobId(blobId, 0);
63-
TVDiskID vDiskId = Info->GetVDiskInSubgroup(Type.TotalPartCount() + handoffIdx, origBlobId.Hash());
48+
TVDiskID vDiskId = Info->GetVDiskInSubgroup(Info->Type.TotalPartCount() + handoffIdx, origBlobId.Hash());
6449
return {blobId, vDiskId};
6550
}
6651

0 commit comments

Comments
 (0)