Skip to content

Commit 25e82a5

Browse files
committed
.
1 parent 8b417e7 commit 25e82a5

5 files changed

+69
-20
lines changed

ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ namespace NPDisk {
3939

4040
LWTRACE_USING(BLOBSTORAGE_PROVIDER);
4141

42+
void CreatePDiskActor(
43+
TGenericExecutorThread& executorThread,
44+
const TIntrusivePtr<::NMonitoring::TDynamicCounters>& counters,
45+
const TIntrusivePtr<TPDiskConfig> &cfg,
46+
const NPDisk::TMainKey &mainKey,
47+
ui32 pDiskID, ui32 poolId, ui32 nodeId
48+
) {
49+
50+
TActorId actorId = executorThread.RegisterActor(CreatePDisk(cfg, mainKey, counters), TMailboxType::ReadAsFilled, poolId);
51+
52+
TActorId pDiskServiceId = MakeBlobStoragePDiskID(nodeId, pDiskID);
53+
54+
executorThread.ActorSystem->RegisterLocalService(pDiskServiceId, actorId);
55+
}
56+
4257
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4358
// PDisk Actor
4459
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -993,29 +1008,48 @@ class TPDiskActor : public TActorBootstrapped<TPDiskActor> {
9931008
return;
9941009
}
9951010

1011+
if (PendingRestartResponse) {
1012+
PendingRestartResponse(restartAllowed, ev->Get()->Details);
1013+
PendingRestartResponse = {};
1014+
}
1015+
9961016
if (restartAllowed) {
997-
MainKey = ev->Get()->MainKey;
1017+
NPDisk::TMainKey newMainKey = ev->Get()->MainKey;
1018+
9981019
SecureWipeBuffer((ui8*)ev->Get()->MainKey.Keys.data(), sizeof(NPDisk::TKey) * ev->Get()->MainKey.Keys.size());
1020+
9991021
LOG_NOTICE_S(*TlsActivationContext, NKikimrServices::BS_PDISK, "PDiskId# " << PDisk->PDiskId
10001022
<< " Going to restart PDisk since recieved TEvAskWardenRestartPDiskResult");
10011023

1024+
const TActorIdentity& thisActorId = SelfId();
1025+
ui32 nodeId = thisActorId.NodeId();
1026+
ui32 poolId = thisActorId.PoolID();
1027+
ui32 pdiskId = PDisk->PDiskId;
1028+
10021029
PDisk->Stop();
10031030

1031+
TIntrusivePtr<TPDiskConfig> actorCfg = std::move(Cfg);
1032+
10041033
auto& newCfg = ev->Get()->Config;
1034+
10051035
if (newCfg) {
1006-
Y_VERIFY_S(Cfg->PDiskId == PDisk->PDiskId,
1007-
"New config's PDiskId# " << newCfg->PDiskId << " is not equal to real PDiskId# " << PDisk->PDiskId);
1008-
Cfg = std::move(newCfg);
1036+
Y_VERIFY_S(newCfg->PDiskId == pdiskId,
1037+
"New config's PDiskId# " << newCfg->PDiskId << " is not equal to real PDiskId# " << pdiskId);
1038+
1039+
actorCfg = std::move(newCfg);
10091040
}
10101041

1011-
StartPDiskThread();
1042+
const TActorContext& actorCtx = ActorContext();
10121043

1013-
Send(ev->Sender, new TEvBlobStorage::TEvNotifyWardenPDiskRestarted(PDisk->PDiskId));
1014-
}
1044+
auto& counters = AppData(actorCtx)->Counters;
10151045

1016-
if (PendingRestartResponse) {
1017-
PendingRestartResponse(restartAllowed, ev->Get()->Details);
1018-
PendingRestartResponse = {};
1046+
TGenericExecutorThread& executorThread = actorCtx.ExecutorThread;
1047+
1048+
PassAway();
1049+
1050+
CreatePDiskActor(executorThread, counters, actorCfg, newMainKey, pdiskId, poolId, nodeId);
1051+
1052+
Send(ev->Sender, new TEvBlobStorage::TEvNotifyWardenPDiskRestarted(pdiskId));
10191053
}
10201054
}
10211055

@@ -1290,10 +1324,7 @@ IActor* CreatePDisk(const TIntrusivePtr<TPDiskConfig> &cfg, const NPDisk::TMainK
12901324

12911325
void TRealPDiskServiceFactory::Create(const TActorContext &ctx, ui32 pDiskID,
12921326
const TIntrusivePtr<TPDiskConfig> &cfg, const NPDisk::TMainKey &mainKey, ui32 poolId, ui32 nodeId) {
1293-
TActorId actorId = ctx.ExecutorThread.RegisterActor(
1294-
CreatePDisk(cfg, mainKey, AppData(ctx)->Counters), TMailboxType::ReadAsFilled, poolId);
1295-
TActorId pDiskServiceId = MakeBlobStoragePDiskID(nodeId, pDiskID);
1296-
ctx.ExecutorThread.ActorSystem->RegisterLocalService(pDiskServiceId, actorId);
1327+
CreatePDiskActor(ctx.ExecutorThread, AppData(ctx)->Counters, cfg, mainKey, pDiskID, poolId, nodeId);
12971328
}
12981329

12991330
} // NKikimr

ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ void TPDisk::Stop() {
305305
LOG_NOTICE_S(*ActorSystem, NKikimrServices::BS_PDISK, "PDiskId# " << PDiskId
306306
<< " shutdown owner info# " << StartupOwnerInfo());
307307
}
308+
308309
BlockDevice->Stop();
309310

310311
// BlockDevice is stopped, the data will NOT hit the disk.

ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl_log.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ void TPDisk::ProcessLogReadQueue() {
593593
case ERequestType::RequestLogReadContinue:
594594
{
595595
TLogReadContinue *read = static_cast<TLogReadContinue*>(req);
596+
596597
read->CompletionAction->CostNs = DriveModel.TimeForSizeNs(read->Size, read->Offset / Format.ChunkSize,
597598
TDriveModel::OP_TYPE_READ);
598599
auto traceId = read->SpanStack.GetTraceId();

ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,9 @@ Y_UNIT_TEST_SUITE(TPDiskTest) {
503503
TVDiskMock vdisk(&testCtx);
504504
vdisk.InitFull();
505505
vdisk.SendEvLogSync();
506-
testCtx.Send(new TEvBlobStorage::TEvAskWardenRestartPDiskResult(testCtx.GetPDisk()->PDiskId, testCtx.MainKey, true, nullptr));
507-
const auto evInitRes = testCtx.Recv<TEvBlobStorage::TEvNotifyWardenPDiskRestarted>();
506+
507+
testCtx.StartPDiskRestart();
508+
508509
vdisk.InitFull();
509510
vdisk.SendEvLogSync();
510511
}
@@ -928,8 +929,7 @@ Y_UNIT_TEST_SUITE(TPDiskTest) {
928929
while (writeLog() == NKikimrProto::OK) {}
929930
UNIT_ASSERT_VALUES_EQUAL(writeLog(), NKikimrProto::OUT_OF_SPACE);
930931

931-
testCtx.Send(new TEvBlobStorage::TEvAskWardenRestartPDiskResult(testCtx.GetPDisk()->PDiskId, testCtx.MainKey, true, nullptr));
932-
const auto evInitRes = testCtx.Recv<TEvBlobStorage::TEvNotifyWardenPDiskRestarted>();
932+
testCtx.StartPDiskRestart();
933933

934934
vdisk.InitFull();
935935
vdisk.SendEvLogSync();
@@ -943,8 +943,8 @@ Y_UNIT_TEST_SUITE(PDiskCompatibilityInfo) {
943943
using TCurrent = NKikimrConfig::TCurrentCompatibilityInfo;
944944
THolder<NPDisk::TEvYardInitResult> RestartPDisk(TActorTestContext& testCtx, ui32 pdiskId, TVDiskMock& vdisk, TCurrent* newInfo) {
945945
TCompatibilityInfoTest::Reset(newInfo);
946-
testCtx.Send(new TEvBlobStorage::TEvAskWardenRestartPDiskResult(pdiskId, testCtx.MainKey, true, nullptr));
947-
testCtx.Recv<TEvBlobStorage::TEvNotifyWardenPDiskRestarted>();
946+
Y_UNUSED(pdiskId);
947+
testCtx.StartPDiskRestart();
948948
testCtx.Send(new NPDisk::TEvYardInit(vdisk.OwnerRound.fetch_add(1), vdisk.VDiskID, testCtx.TestCtx.PDiskGuid));
949949
return testCtx.Recv<NPDisk::TEvYardInitResult>();
950950
}

ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut_env.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,25 @@ struct TActorTestContext {
125125
new NPDisk::TEvYardControl(NPDisk::TEvYardControl::GetPDiskPointer, nullptr),
126126
NKikimrProto::OK);
127127
PDisk = reinterpret_cast<NPDisk::TPDisk*>(evControlRes->Cookie);
128+
129+
PDiskActor = PDisk->PDiskActor;
128130
}
129131
return PDisk;
130132
}
133+
134+
void StartPDiskRestart() {
135+
Send(new TEvBlobStorage::TEvAskWardenRestartPDiskResult(GetPDisk()->PDiskId, MainKey, true, nullptr));
136+
const auto evInitRes = Recv<TEvBlobStorage::TEvNotifyWardenPDiskRestarted>();
137+
138+
if (!Settings.UsePDiskMock) {
139+
TActorId wellKnownPDiskActorId = MakeBlobStoragePDiskID(PDiskActor->NodeId(), PDisk->PDiskId);
140+
141+
PDisk = nullptr;
142+
143+
// We will temporarily use well know pdisk actor id, because restarted pdisk actor id is not yet known.
144+
PDiskActor = wellKnownPDiskActorId;
145+
}
146+
}
131147

132148
template<typename T>
133149
auto SafeRunOnPDisk(T&& f) {

0 commit comments

Comments
 (0)