@@ -39,6 +39,21 @@ namespace NPDisk {
3939
4040LWTRACE_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
12911325void 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
0 commit comments