Skip to content

Commit 7e044ef

Browse files
authored
Add deadlines for each stage of patching (#5677)
1 parent 0671f74 commit 7e044ef

File tree

7 files changed

+410
-44
lines changed

7 files changed

+410
-44
lines changed

ydb/core/blobstorage/dsproxy/dsproxy_patch.cpp

Lines changed: 200 additions & 14 deletions
Large diffs are not rendered by default.

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

Lines changed: 71 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ enum class ENaivePatchCase {
110110
ErrorOnPut,
111111
};
112112

113+
#define CASE_TO_RETURN_STRING(cs) \
114+
case cs: return #cs \
115+
// end CASE_TO_RETURN_STRING
116+
TString ToString(ENaivePatchCase cs) {
117+
switch (cs) {
118+
CASE_TO_RETURN_STRING(ENaivePatchCase::Ok);
119+
CASE_TO_RETURN_STRING(ENaivePatchCase::ErrorOnGetItem);
120+
CASE_TO_RETURN_STRING(ENaivePatchCase::ErrorOnGet);
121+
CASE_TO_RETURN_STRING(ENaivePatchCase::ErrorOnPut);
122+
}
123+
}
124+
113125
NKikimrProto::EReplyStatus GetPatchResultStatus(ENaivePatchCase naiveCase) {
114126
switch (naiveCase) {
115127
case ENaivePatchCase::Ok:
@@ -156,6 +168,17 @@ enum class EVPatchCase {
156168
Custom,
157169
};
158170

171+
TString ToString(EVPatchCase cs) {
172+
switch (cs) {
173+
CASE_TO_RETURN_STRING(EVPatchCase::Ok);
174+
CASE_TO_RETURN_STRING(EVPatchCase::OneErrorAndAllPartExistInStart);
175+
CASE_TO_RETURN_STRING(EVPatchCase::OnePartLostInStart);
176+
CASE_TO_RETURN_STRING(EVPatchCase::DeadGroupInStart);
177+
CASE_TO_RETURN_STRING(EVPatchCase::ErrorDuringVPatchDiff);
178+
CASE_TO_RETURN_STRING(EVPatchCase::Custom);
179+
}
180+
}
181+
159182
NKikimrProto::EReplyStatus GetPatchResultStatus(EVPatchCase vpatchCase) {
160183
switch (vpatchCase) {
161184
case EVPatchCase::Ok:
@@ -249,6 +272,15 @@ enum class EMovedPatchCase {
249272
Error
250273
};
251274

275+
TString ToString(EMovedPatchCase cs) {
276+
switch (cs) {
277+
CASE_TO_RETURN_STRING(EMovedPatchCase::Ok);
278+
CASE_TO_RETURN_STRING(EMovedPatchCase::Error);
279+
}
280+
}
281+
282+
#undef CASE_TO_RETURN_STRING
283+
252284
NKikimrProto::EReplyStatus GetPatchResultStatus(EMovedPatchCase movedCase) {
253285
switch (movedCase) {
254286
case EMovedPatchCase::Ok:
@@ -289,7 +321,7 @@ void ReceivePatchResult(TTestBasicRuntime &runtime, const TTestArgs &args, NKiki
289321
}
290322

291323
void ConductGet(TTestBasicRuntime &runtime, const TTestArgs &args, ENaivePatchCase naiveCase) {
292-
CTEST << "ConductGet: Start\n";
324+
CTEST << "ConductGet: Start NaiveCase: " << ToString(naiveCase) << "\n";
293325
NKikimrProto::EReplyStatus resultStatus = GetGetResultStatus(naiveCase);
294326
TAutoPtr<IEventHandle> handle;
295327
TEvBlobStorage::TEvGet *get = runtime.GrabEdgeEventRethrow<TEvBlobStorage::TEvGet>(handle);
@@ -328,10 +360,10 @@ TString MakePatchedBuffer(const TTestArgs &args) {
328360
void ConductPut(TTestBasicRuntime &runtime, const TTestArgs &args, ENaivePatchCase naiveCase) {
329361
NKikimrProto::EReplyStatus resultStatus = GetPutResultStatus(naiveCase);
330362
if (resultStatus == NKikimrProto::UNKNOWN) {
331-
CTEST << "ConductPut: Skip\n";
363+
CTEST << "ConductPut: Skip NaiveCase: " << ToString(naiveCase) << "\n";
332364
return;
333365
}
334-
CTEST << "ConductPut: Start\n";
366+
CTEST << "ConductPut: Start NaiveCase: " << ToString(naiveCase) << "\n";
335367
TAutoPtr<IEventHandle> handle;
336368
TEvBlobStorage::TEvPut *put = runtime.GrabEdgeEventRethrow<TEvBlobStorage::TEvPut>(handle);
337369
UNIT_ASSERT_VALUES_EQUAL(put->Id, args.PatchedId);
@@ -346,22 +378,35 @@ void ConductPut(TTestBasicRuntime &runtime, const TTestArgs &args, ENaivePatchCa
346378
}
347379

348380
void ConductNaivePatch(TTestBasicRuntime &runtime, const TTestArgs &args, ENaivePatchCase naiveCase) {
349-
CTEST << "ConductNaivePatch: Start\n";
381+
CTEST << "ConductNaivePatch: Start NaiveCase: " << ToString(naiveCase) << Endl;
350382
ConductGet(runtime, args, naiveCase);
351383
ConductPut(runtime, args, naiveCase);
352384
NKikimrProto::EReplyStatus resultStatus = GetPatchResultStatus(naiveCase);
353385
ReceivePatchResult(runtime, args, resultStatus);
354386
CTEST << "ConductNaivePatch: Finish\n";
355387
}
356388

389+
template <typename InnerType>
390+
TString ToString(const TVector<InnerType> &lst) {
391+
TStringBuilder bld;
392+
bld << '[';
393+
for (ui32 idx = 0; idx < lst.size(); ++idx) {
394+
if (idx) {
395+
bld << ", ";
396+
}
397+
bld << lst[idx];
398+
}
399+
bld << ']';
400+
return bld;
401+
}
357402

358403
void ConductVPatchStart(TTestBasicRuntime &runtime, const TDSProxyEnv &env, const TTestArgs &args,
359-
EVPatchCase naiveCase, TVDiskPointer vdiskPointer)
404+
EVPatchCase vpatchCase, TVDiskPointer vdiskPointer)
360405
{
361406
auto [vdiskIdx, idxInSubgroup] = vdiskPointer.GetIndecies(env, args.OriginalId.Hash());
362-
CTEST << "ConductVPatchStart: Start vdiskIdx# " << vdiskIdx << " idxInSubgroup# " << idxInSubgroup << "\n";
407+
CTEST << "ConductVPatchStart: Start vdiskIdx# " << vdiskIdx << " idxInSubgroup# " << idxInSubgroup << " VPatchCase: " << ToString(vpatchCase) << "\n";
363408
TVDiskID vdisk = env.Info->GetVDiskInSubgroup(idxInSubgroup, args.OriginalId.Hash());
364-
auto [status, parts] = GetVPatchFoundPartsStatus(env, args, naiveCase, vdiskPointer);
409+
auto [status, parts] = GetVPatchFoundPartsStatus(env, args, vpatchCase, vdiskPointer);
365410

366411
auto start = runtime.GrabEdgeEventRethrow<TEvBlobStorage::TEvVPatchStart>({env.VDisks[vdiskIdx]});
367412
auto &startRecord = start->Get()->Record;
@@ -376,21 +421,22 @@ void ConductVPatchStart(TTestBasicRuntime &runtime, const TDSProxyEnv &env, cons
376421
for (auto partId : parts) {
377422
foundParts->AddPart(partId);
378423
}
424+
CTEST << "ConductVPatchStart: Send FoundParts vdiskIdx# " << vdiskIdx << " idxInSubgroup# " << idxInSubgroup << "parts# " << ToString(parts) << "\n";
379425
SendByHandle(runtime, start, std::move(foundParts));
380426
CTEST << "ConductVPatchStart: Finish vdiskIdx# " << vdiskIdx << " idxInSubgroup# " << idxInSubgroup << "\n";
381427
}
382428

383429
void ConductVPatchDiff(TTestBasicRuntime &runtime, const TDSProxyEnv &env, const TTestArgs &args,
384-
EVPatchCase naiveCase, TVDiskPointer vdiskPointer)
430+
EVPatchCase vpatchCase, TVDiskPointer vdiskPointer)
385431
{
386432
auto [vdiskIdx, idxInSubgroup] = vdiskPointer.GetIndecies(env, args.PatchedId.Hash());
387433
TVDiskID vdisk = env.Info->GetVDiskInSubgroup(idxInSubgroup, args.PatchedId.Hash());
388-
NKikimrProto::EReplyStatus resultStatus = GetVPatchResultStatus(env, args, naiveCase, vdiskPointer);
434+
NKikimrProto::EReplyStatus resultStatus = GetVPatchResultStatus(env, args, vpatchCase, vdiskPointer);
389435
if (resultStatus == NKikimrProto::UNKNOWN) {
390-
CTEST << "ConductVPatchDiff: Skip vdiskIdx# " << vdiskIdx << " idxInSubgroup# " << idxInSubgroup << "\n";
436+
CTEST << "ConductVPatchDiff: Skip vdiskIdx# " << vdiskIdx << " idxInSubgroup# " << idxInSubgroup << " VPatchCase: " << ToString(vpatchCase) << "\n";
391437
return;
392438
}
393-
CTEST << "ConductVPatchDiff: Start vdiskIdx# " << vdiskIdx << " idxInSubgroup# " << idxInSubgroup << "\n";
439+
CTEST << "ConductVPatchDiff: Start vdiskIdx# " << vdiskIdx << " idxInSubgroup# " << idxInSubgroup << " VPatchCase: " << ToString(vpatchCase) << "\n";
394440

395441
auto diffEv = runtime.GrabEdgeEventRethrow<TEvBlobStorage::TEvVPatchDiff>({env.VDisks[vdiskIdx]});
396442
auto &diffRecord = diffEv->Get()->Record;
@@ -415,6 +461,7 @@ void ConductVPatchDiff(TTestBasicRuntime &runtime, const TDSProxyEnv &env, const
415461
}
416462

417463
void ConductFailedVPatch(TTestBasicRuntime &runtime, const TDSProxyEnv &env, const TTestArgs &args) {
464+
return; // disabled vpatch
418465
CTEST << "ConductFailedVPatch: Start\n";
419466
for (ui32 idxInSubgroup = 0; idxInSubgroup < args.GType.BlobSubgroupSize(); ++idxInSubgroup) {
420467
TVDiskPointer vdisk = TVDiskPointer::GetVDiskIdx(idxInSubgroup);
@@ -429,7 +476,7 @@ void ConductFailedVPatch(TTestBasicRuntime &runtime, const TDSProxyEnv &env, con
429476

430477

431478
void ConductVMovedPatch(TTestBasicRuntime &runtime, const TTestArgs &args, EMovedPatchCase movedCase) {
432-
CTEST << "ConductVMovedPatch: Start\n";
479+
CTEST << "ConductVMovedPatch: Start MovedPatchCase: " << ToString(movedCase) << Endl;
433480
NKikimrProto::EReplyStatus resultStatus = GetVMovedPatchResultStatus(movedCase);
434481
TAutoPtr<IEventHandle> handle;
435482
TEvBlobStorage::TEvVMovedPatch *vPatch = runtime.GrabEdgeEventRethrow<TEvBlobStorage::TEvVMovedPatch>(handle);
@@ -459,7 +506,7 @@ void ConductVMovedPatch(TTestBasicRuntime &runtime, const TTestArgs &args, EMove
459506
void ConductMovedPatch(TTestBasicRuntime &runtime, const TDSProxyEnv &env, const TTestArgs &args,
460507
EMovedPatchCase movedCase)
461508
{
462-
CTEST << "ConductMovedPatch: Start\n";
509+
CTEST << "ConductMovedPatch: Start MovedPatchCase: " << ToString(movedCase) << Endl;
463510
ConductFailedVPatch(runtime, env, args);
464511
ConductVMovedPatch(runtime, args, movedCase);
465512
NKikimrProto::EReplyStatus resultStatus = GetPatchResultStatus(movedCase);
@@ -481,7 +528,8 @@ void ConductFallbackPatch(TTestBasicRuntime &runtime, const TTestArgs &args) {
481528
void ConductVPatchEvents(TTestBasicRuntime &runtime, const TDSProxyEnv &env, const TTestArgs &args,
482529
EVPatchCase vpatchCase)
483530
{
484-
CTEST << "ConductVPatchEvents: Start\n";
531+
return; // disabled vpatch
532+
CTEST << "ConductVPatchEvents: Start VPatchCase: " << ToString(vpatchCase) << Endl;
485533
for (ui32 idxInSubgroup = 0; idxInSubgroup < args.GType.BlobSubgroupSize(); ++idxInSubgroup) {
486534
TVDiskPointer vdisk = TVDiskPointer::GetVDiskIdx(idxInSubgroup);
487535
ConductVPatchStart(runtime, env, args, vpatchCase, vdisk);
@@ -496,7 +544,7 @@ void ConductVPatchEvents(TTestBasicRuntime &runtime, const TDSProxyEnv &env, con
496544
void ConductVPatch(TTestBasicRuntime &runtime, const TDSProxyEnv &env, const TTestArgs &args,
497545
EVPatchCase vpatchCase)
498546
{
499-
CTEST << "ConductFallbackPatch: Start\n";
547+
CTEST << "ConductFallbackPatch: Start VPatchCase: " << ToString(vpatchCase) << Endl;
500548
ConductVPatchEvents(runtime, env, args, vpatchCase);
501549
NKikimrProto::EReplyStatus resultStatus = GetPatchResultStatus(vpatchCase);
502550
if (resultStatus == NKikimrProto::UNKNOWN) {
@@ -620,17 +668,18 @@ void RunGeneralTest(void(*runner)(TTestBasicRuntime &runtime, const TTestArgs &a
620668
Y_UNIT_TEST_NAIVE(ErrorOnPut, erasure) \
621669
Y_UNIT_TEST_MOVED(Ok, erasure) \
622670
Y_UNIT_TEST_MOVED(Error, erasure) \
623-
Y_UNIT_TEST_VPATCH(Ok, erasure) \
624-
Y_UNIT_TEST_VPATCH(OneErrorAndAllPartExistInStart, erasure) \
625-
Y_UNIT_TEST_VPATCH(OnePartLostInStart, erasure) \
626-
Y_UNIT_TEST_VPATCH(DeadGroupInStart, erasure) \
627-
Y_UNIT_TEST_VPATCH(ErrorDuringVPatchDiff, erasure) \
628671
Y_UNIT_TEST_SECURED(Ok, erasure) \
629672
Y_UNIT_TEST_SECURED(ErrorOnGetItem, erasure) \
630673
Y_UNIT_TEST_SECURED(ErrorOnGet, erasure) \
631674
Y_UNIT_TEST_SECURED(ErrorOnPut, erasure) \
632675
// end Y_UNIT_TEST_PATCH_PACK
633676

677+
// Y_UNIT_TEST_VPATCH(Ok, erasure)
678+
// Y_UNIT_TEST_VPATCH(OneErrorAndAllPartExistInStart, erasure)
679+
// Y_UNIT_TEST_VPATCH(OnePartLostInStart, erasure)
680+
// Y_UNIT_TEST_VPATCH(DeadGroupInStart, erasure)
681+
// Y_UNIT_TEST_VPATCH(ErrorDuringVPatchDiff, erasure)
682+
634683
Y_UNIT_TEST_PATCH_PACK(ErasureNone)
635684
Y_UNIT_TEST_PATCH_PACK(Erasure4Plus2Block)
636685
Y_UNIT_TEST_PATCH_PACK(ErasureMirror3dc)
@@ -712,6 +761,7 @@ EFaultToleranceCase GetFaultToleranceCaseForBlock4Plus2(const TDSProxyEnv &env,
712761
}
713762
}
714763
}
764+
return EFaultToleranceCase::Fallback; // disabled vpatch
715765
if (layout.CountEffectiveReplicas(env.Info->Type) == env.Info->Type.TotalPartCount()) {
716766
return EFaultToleranceCase::Ok;
717767
} else {
@@ -736,6 +786,7 @@ EFaultToleranceCase GetFaultToleranceCaseForMirror3dc(const TDSProxyEnv &env, co
736786
for (ui32 dcIdx = 0; dcIdx < dcCnt; ++dcIdx) {
737787
x2cnt += (replInDc[dcIdx] >= 2);
738788
}
789+
return EFaultToleranceCase::Fallback; // disabled vpatch
739790
if ((replInDc[0] && replInDc[1] && replInDc[2]) || x2cnt >= 2) {
740791
return EFaultToleranceCase::Ok;
741792
} else {

ydb/core/blobstorage/vdisk/common/vdisk_events.h

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,7 @@ namespace NKikimr {
15701570
if (deadline != TInstant::Max()) {
15711571
this->Record.MutableMsgQoS()->SetDeadlineSeconds((ui32)deadline.Seconds());
15721572
}
1573-
this->Record.MutableMsgQoS()->SetExtQueueId(HandleClassToQueueId(NKikimrBlobStorage::AsyncBlob));
1573+
this->Record.MutableMsgQoS()->SetExtQueueId(NKikimrBlobStorage::PutAsyncBlob);
15741574
}
15751575

15761576
bool GetIgnoreBlock() const {
@@ -1950,6 +1950,25 @@ namespace NKikimr {
19501950
}
19511951
Record.MutableMsgQoS()->SetExtQueueId(NKikimrBlobStorage::EVDiskQueueId::GetFastRead);
19521952
}
1953+
1954+
TString ToString() const {
1955+
return ToString(this->Record);
1956+
}
1957+
1958+
static TString ToString(const NKikimrBlobStorage::TEvVPatchStart &record) {
1959+
TStringStream str;
1960+
TLogoBlobID originalId = LogoBlobIDFromLogoBlobID(record.GetOriginalBlobId());
1961+
TLogoBlobID patchedId = LogoBlobIDFromLogoBlobID(record.GetPatchedBlobId());
1962+
str << "{TEvVPatchStart";
1963+
str << " OriginalBlobId# " << originalId.ToString();
1964+
str << " PatchedBlobId# " << patchedId.ToString();
1965+
if (record.HasMsgQoS()) {
1966+
str << " ";
1967+
TEvBlobStorage::TEvVPut::OutMsgQos(record.GetMsgQoS(), str);
1968+
}
1969+
str << "}";
1970+
return str.Str();
1971+
}
19531972
};
19541973

19551974
struct TEvBlobStorage::TEvVPatchFoundParts
@@ -1995,6 +2014,25 @@ namespace NKikimr {
19952014
Record.SetStatus(status);
19962015
}
19972016

2017+
TString ToString() const {
2018+
return ToString(this->Record);
2019+
}
2020+
2021+
static TString ToString(const NKikimrBlobStorage::TEvVPatchFoundParts &record) {
2022+
TStringStream str;
2023+
TLogoBlobID originalId = LogoBlobIDFromLogoBlobID(record.GetOriginalBlobId());
2024+
TLogoBlobID patchedId = LogoBlobIDFromLogoBlobID(record.GetPatchedBlobId());
2025+
str << "{TEvVPatchFoundParts";
2026+
str << " OriginalBlobId# " << originalId.ToString();
2027+
str << " PatchedBlobId# " << patchedId.ToString();
2028+
if (record.HasMsgQoS()) {
2029+
str << " ";
2030+
TEvBlobStorage::TEvVPut::OutMsgQos(record.GetMsgQoS(), str);
2031+
}
2032+
str << "}";
2033+
return str.Str();
2034+
}
2035+
19982036
void MakeError(NKikimrProto::EReplyStatus status, const TString& errorReason,
19992037
const NKikimrBlobStorage::TEvVPatchStart &request) {
20002038
Record.SetErrorReason(errorReason);
@@ -2084,6 +2122,25 @@ namespace NKikimr {
20842122
}
20852123
return result;
20862124
}
2125+
2126+
TString ToString() const {
2127+
return ToString(this->Record);
2128+
}
2129+
2130+
static TString ToString(const NKikimrBlobStorage::TEvVPatchDiff &record) {
2131+
TStringStream str;
2132+
TLogoBlobID originalId = LogoBlobIDFromLogoBlobID(record.GetOriginalPartBlobId());
2133+
TLogoBlobID patchedId = LogoBlobIDFromLogoBlobID(record.GetPatchedPartBlobId());
2134+
str << "{TEvVPatchDiff";
2135+
str << " OriginalBlobId# " << originalId.ToString();
2136+
str << " PatchedBlobId# " << patchedId.ToString();
2137+
if (record.HasMsgQoS()) {
2138+
str << " ";
2139+
TEvBlobStorage::TEvVPut::OutMsgQos(record.GetMsgQoS(), str);
2140+
}
2141+
str << "}";
2142+
return str.Str();
2143+
}
20872144
};
20882145

20892146

@@ -2129,6 +2186,25 @@ namespace NKikimr {
21292186
}
21302187
return result;
21312188
}
2189+
2190+
TString ToString() const {
2191+
return ToString(this->Record);
2192+
}
2193+
2194+
static TString ToString(const NKikimrBlobStorage::TEvVPatchXorDiff &record) {
2195+
TStringStream str;
2196+
TLogoBlobID originalId = LogoBlobIDFromLogoBlobID(record.GetOriginalPartBlobId());
2197+
TLogoBlobID patchedId = LogoBlobIDFromLogoBlobID(record.GetPatchedPartBlobId());
2198+
str << "{TEvVPatchXorDiff";
2199+
str << " OriginalBlobId# " << originalId.ToString();
2200+
str << " PatchedBlobId# " << patchedId.ToString();
2201+
if (record.HasMsgQoS()) {
2202+
str << " ";
2203+
TEvBlobStorage::TEvVPut::OutMsgQos(record.GetMsgQoS(), str);
2204+
}
2205+
str << "}";
2206+
return str.Str();
2207+
}
21322208
};
21332209

21342210
struct TEvBlobStorage::TEvVPatchXorDiffResult

0 commit comments

Comments
 (0)