diff options
author | a-sumin <a-sumin@yandex-team.com> | 2023-06-07 15:51:22 +0300 |
---|---|---|
committer | a-sumin <a-sumin@yandex-team.com> | 2023-06-07 15:51:22 +0300 |
commit | 668b4b0738d0884b52e9212ea4ea1b78e5056937 (patch) | |
tree | def96e2a92e5e116fa2975d9c8fdcb519649d4e9 | |
parent | cb91ffc1454a6cc69c96fbba4f532454dc4cf747 (diff) | |
download | ydb-668b4b0738d0884b52e9212ea4ea1b78e5056937.tar.gz |
Fix memory leak in TActorSystem
20 files changed, 138 insertions, 91 deletions
diff --git a/library/cpp/actors/core/actor.h b/library/cpp/actors/core/actor.h index d12266b0c5..32d9d0c6af 100644 --- a/library/cpp/actors/core/actor.h +++ b/library/cpp/actors/core/actor.h @@ -876,6 +876,7 @@ namespace NActors { template <ESendingType SendingType> TActorId IActor::Register(IActor* actor, TMailboxType::EType mailboxType, ui32 poolId) const noexcept { + Y_VERIFY(actor); return TlsActivationContext->ExecutorThread.RegisterActor<SendingType>(actor, mailboxType, poolId, SelfActorId); } @@ -883,6 +884,7 @@ namespace NActors { template <ESendingType SendingType> TActorId TActorSystem::Register(IActor* actor, TMailboxType::EType mailboxType, ui32 executorPool, ui64 revolvingCounter, const TActorId& parentId) { + Y_VERIFY(actor); Y_VERIFY(executorPool < ExecutorPoolCount, "executorPool# %" PRIu32 ", ExecutorPoolCount# %" PRIu32, (ui32)executorPool, (ui32)ExecutorPoolCount); if constexpr (SendingType == ESendingType::Common) { diff --git a/library/cpp/actors/core/actorsystem.cpp b/library/cpp/actors/core/actorsystem.cpp index e6df9c2ee0..81a2dd6446 100644 --- a/library/cpp/actors/core/actorsystem.cpp +++ b/library/cpp/actors/core/actorsystem.cpp @@ -20,6 +20,37 @@ namespace NActors { LWTRACE_USING(ACTORLIB_PROVIDER); + TActorSetupCmd::TActorSetupCmd() + : MailboxType(TMailboxType::HTSwap) + , PoolId(0) + , Actor(nullptr) + { + } + + TActorSetupCmd::TActorSetupCmd(TActorSetupCmd&&) = default; + TActorSetupCmd& TActorSetupCmd::operator=(TActorSetupCmd&&) = default; + TActorSetupCmd::~TActorSetupCmd() = default; + + TActorSetupCmd::TActorSetupCmd(IActor* actor, TMailboxType::EType mailboxType, ui32 poolId) + : MailboxType(mailboxType) + , PoolId(poolId) + , Actor(actor) + { + } + + TActorSetupCmd::TActorSetupCmd(std::unique_ptr<IActor> actor, TMailboxType::EType mailboxType, ui32 poolId) + : MailboxType(mailboxType) + , PoolId(poolId) + , Actor(std::move(actor)) + { + } + + void TActorSetupCmd::Set(std::unique_ptr<IActor> actor, TMailboxType::EType mailboxType, ui32 poolId) { + MailboxType = mailboxType; + PoolId = poolId; + Actor = std::move(actor); + } + struct TActorSystem::TServiceMap : TNonCopyable { NActors::TServiceMap<TActorId, TActorId, TActorId::THash> LocalMap; TTicketLock Lock; @@ -236,12 +267,12 @@ namespace NActors { // setup interconnect proxies { - const TInterconnectSetup& setup = SystemSetup->Interconnect; + TInterconnectSetup& setup = SystemSetup->Interconnect; Interconnect.Reset(new TActorId[InterconnectCount + 1]); for (ui32 i = 0, e = InterconnectCount; i != e; ++i) { - const TActorSetupCmd& x = setup.ProxyActors[i]; + TActorSetupCmd& x = setup.ProxyActors[i]; if (x.Actor) { - Interconnect[i] = Register(x.Actor, x.MailboxType, x.PoolId, i); + Interconnect[i] = Register(x.Actor.release(), x.MailboxType, x.PoolId, i); Y_VERIFY(!!Interconnect[i]); } } @@ -251,8 +282,8 @@ namespace NActors { // setup local services { for (ui32 i = 0, e = (ui32)SystemSetup->LocalServices.size(); i != e; ++i) { - const std::pair<TActorId, TActorSetupCmd>& x = SystemSetup->LocalServices[i]; - const TActorId xid = Register(x.second.Actor, x.second.MailboxType, x.second.PoolId, i); + std::pair<TActorId, TActorSetupCmd>& x = SystemSetup->LocalServices[i]; + const TActorId xid = Register(x.second.Actor.release(), x.second.MailboxType, x.second.PoolId, i); Y_VERIFY(!!xid); if (!!x.first) RegisterLocalService(x.first, xid); diff --git a/library/cpp/actors/core/actorsystem.h b/library/cpp/actors/core/actorsystem.h index 9db3075ccf..0740c70b13 100644 --- a/library/cpp/actors/core/actorsystem.h +++ b/library/cpp/actors/core/actorsystem.h @@ -64,27 +64,20 @@ namespace NActors { struct TActorSetupCmd { TMailboxType::EType MailboxType; ui32 PoolId; - IActor* Actor; + std::unique_ptr<IActor> Actor; - TActorSetupCmd() - : MailboxType(TMailboxType::HTSwap) - , PoolId(0) - , Actor(nullptr) - { - } + TActorSetupCmd(); + TActorSetupCmd(const TActorSetupCmd&) = delete; + TActorSetupCmd(TActorSetupCmd&&); + TActorSetupCmd& operator=(const TActorSetupCmd&) = delete; + TActorSetupCmd& operator=(TActorSetupCmd&&); + TActorSetupCmd(std::unique_ptr<IActor> actor, TMailboxType::EType mailboxType, ui32 poolId); + ~TActorSetupCmd(); - TActorSetupCmd(IActor* actor, TMailboxType::EType mailboxType, ui32 poolId) - : MailboxType(mailboxType) - , PoolId(poolId) - , Actor(actor) - { - } + // For legacy code, please do not use + TActorSetupCmd(IActor* actor, TMailboxType::EType mailboxType, ui32 poolId); - void Set(IActor* actor, TMailboxType::EType mailboxType, ui32 poolId) { - MailboxType = mailboxType; - PoolId = poolId; - Actor = actor; - } + void Set(std::unique_ptr<IActor> actor, TMailboxType::EType mailboxType, ui32 poolId); }; using TProxyWrapperFactory = std::function<TActorId(TActorSystem*, ui32)>; diff --git a/library/cpp/actors/interconnect/poller_actor.cpp b/library/cpp/actors/interconnect/poller_actor.cpp index 04e17c24ab..1646aa7016 100644 --- a/library/cpp/actors/interconnect/poller_actor.cpp +++ b/library/cpp/actors/interconnect/poller_actor.cpp @@ -288,7 +288,7 @@ namespace NActors { } IActor* CreatePollerActor() { - return new TPollerActor; + return new TPollerActor(); } } diff --git a/library/cpp/actors/testlib/test_runtime.cpp b/library/cpp/actors/testlib/test_runtime.cpp index 6fedca1cd2..e093b2e6bf 100644 --- a/library/cpp/actors/testlib/test_runtime.cpp +++ b/library/cpp/actors/testlib/test_runtime.cpp @@ -751,7 +751,7 @@ namespace NActors { VERBOSE = verbose; } - void TTestActorRuntimeBase::AddLocalService(const TActorId& actorId, const TActorSetupCmd& cmd, ui32 nodeIndex) { + void TTestActorRuntimeBase::AddLocalService(const TActorId& actorId, TActorSetupCmd cmd, ui32 nodeIndex) { Y_VERIFY(!IsInitialized); Y_VERIFY(nodeIndex < NodeCount); auto node = Nodes[nodeIndex + FirstNodeId]; @@ -760,8 +760,8 @@ namespace NActors { Nodes[nodeIndex + FirstNodeId] = node; } - node->LocalServicesActors[actorId] = cmd.Actor; - node->LocalServices.push_back(std::make_pair(actorId, cmd)); + node->LocalServicesActors[actorId] = cmd.Actor.get(); + node->LocalServices.push_back(std::make_pair(actorId, TTestActorSetupCmd(std::move(cmd)))); } void TTestActorRuntimeBase::InitNodes() { @@ -1684,7 +1684,9 @@ namespace NActors { const auto& interconnectCounters = GetCountersForComponent(node->DynamicCounters, "interconnect"); - setup->LocalServices = node->LocalServices; + for (const auto& cmd : node->LocalServices) { + setup->LocalServices.emplace_back(cmd.first, TActorSetupCmd(cmd.second.Actor, cmd.second.MailboxType, cmd.second.PoolId)); + } setup->Interconnect.ProxyActors.resize(FirstNodeId + NodeCount); const TActorId nameserviceId = GetNameserviceActorId(); @@ -1734,8 +1736,8 @@ namespace NActors { NActors::TLoggerActor *loggerActor = new NActors::TLoggerActor(node->LogSettings, logBackend, GetCountersForComponent(node->DynamicCounters, "utils")); NActors::TActorSetupCmd loggerActorCmd(loggerActor, NActors::TMailboxType::Simple, node->GetLoggerPoolId()); - std::pair<NActors::TActorId, NActors::TActorSetupCmd> loggerActorPair(node->LogSettings->LoggerActorId, loggerActorCmd); - setup->LocalServices.push_back(loggerActorPair); + std::pair<NActors::TActorId, NActors::TActorSetupCmd> loggerActorPair(node->LogSettings->LoggerActorId, std::move(loggerActorCmd)); + setup->LocalServices.push_back(std::move(loggerActorPair)); } return THolder<TActorSystem>(new TActorSystem(setup, node->GetAppData(), node->LogSettings)); diff --git a/library/cpp/actors/testlib/test_runtime.h b/library/cpp/actors/testlib/test_runtime.h index 0c1e4207cc..12c99ba8e6 100644 --- a/library/cpp/actors/testlib/test_runtime.h +++ b/library/cpp/actors/testlib/test_runtime.h @@ -42,6 +42,26 @@ const TDuration DEFAULT_DISPATCH_TIMEOUT = NSan::PlainOrUnderSanitizer( namespace NActors { struct THeSingleSystemEnv { }; + struct TTestActorSetupCmd { // like TActorSetupCmd, but not owning the Actor + TTestActorSetupCmd(IActor* actor, TMailboxType::EType mailboxType, ui32 poolId) + : MailboxType(mailboxType) + , PoolId(poolId) + , Actor(actor) + { + } + + TTestActorSetupCmd(TActorSetupCmd cmd) + : MailboxType(cmd.MailboxType) + , PoolId(cmd.PoolId) + , Actor(cmd.Actor.release()) + { + } + + TMailboxType::EType MailboxType; + ui32 PoolId; + IActor* Actor; + }; + struct TEventMailboxId { TEventMailboxId() : NodeId(0) @@ -236,7 +256,7 @@ namespace NActors { TMonotonic GetCurrentMonotonicTime() const; void UpdateCurrentTime(TInstant newTime); void AdvanceCurrentTime(TDuration duration); - void AddLocalService(const TActorId& actorId, const TActorSetupCmd& cmd, ui32 nodeIndex = 0); + void AddLocalService(const TActorId& actorId, TActorSetupCmd cmd, ui32 nodeIndex = 0); virtual void Initialize(); ui32 GetNodeId(ui32 index = 0) const; ui32 GetNodeCount() const; @@ -574,7 +594,7 @@ namespace NActors { TIntrusivePtr<NInterconnect::TPollerThreads> Poller; volatile ui64* ActorSystemTimestamp; volatile ui64* ActorSystemMonotonic; - TVector<std::pair<TActorId, TActorSetupCmd> > LocalServices; + TVector<std::pair<TActorId, TTestActorSetupCmd>> LocalServices; TMap<TActorId, IActor*> LocalServicesActors; TMap<IActor*, TActorId> ActorToActorId; THolder<TMailboxTable> MailboxTable; diff --git a/ydb/core/actorlib_impl/load_network.cpp b/ydb/core/actorlib_impl/load_network.cpp index 49632381bf..679ca802b7 100644 --- a/ydb/core/actorlib_impl/load_network.cpp +++ b/ydb/core/actorlib_impl/load_network.cpp @@ -90,10 +90,10 @@ namespace IC_Load { const NKikimr::TAppData* appData, ui32 totalNodesCount) { - auto actor = new TLoadNetwork(setup->NodeId, totalNodesCount); + auto actor = std::make_unique<TLoadNetwork>(setup->NodeId, totalNodesCount); setup->LocalServices.emplace_back( GetLoadNetworkActorID(setup->NodeId), - NActors::TActorSetupCmd(actor, + NActors::TActorSetupCmd(std::move(actor), NActors::TMailboxType::Simple, appData->UserPoolId)); } diff --git a/ydb/core/blobstorage/backpressure/queue_backpressure_client_ut.cpp b/ydb/core/blobstorage/backpressure/queue_backpressure_client_ut.cpp index 93ac198c9a..805c537f73 100644 --- a/ydb/core/blobstorage/backpressure/queue_backpressure_client_ut.cpp +++ b/ydb/core/blobstorage/backpressure/queue_backpressure_client_ut.cpp @@ -173,7 +173,7 @@ public: pDiskConfig->SectorMap = SectorMap; pDiskConfig->EnableSectorEncryption = !pDiskConfig->SectorMap; TActorSetupCmd pDiskSetup(CreatePDisk(pDiskConfig.Get(), MainKey, Counters), TMailboxType::Revolving, 0); - setup->LocalServices.emplace_back(PDiskId, pDiskSetup); + setup->LocalServices.emplace_back(PDiskId, std::move(pDiskSetup)); //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // BlobStorage group info @@ -205,7 +205,7 @@ public: IActor* vDisk = CreateVDisk(vDiskConfig, Info, Counters); TActorSetupCmd vDiskSetup(vDisk, TMailboxType::Revolving, 0); - setup->LocalServices.emplace_back(VDiskActorId, vDiskSetup); + setup->LocalServices.emplace_back(VDiskActorId, std::move(vDiskSetup)); //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Filter @@ -239,7 +239,7 @@ public: NActors::TLoggerActor *loggerActor = new NActors::TLoggerActor{logSettings, NActors::CreateStderrBackend(), Counters}; NActors::TActorSetupCmd loggerActorCmd{loggerActor, NActors::TMailboxType::Simple, 2}; - setup->LocalServices.emplace_back(loggerActorId, loggerActorCmd); + setup->LocalServices.emplace_back(loggerActorId, std::move(loggerActorCmd)); AppData.reset(new TAppData(0, 1, 2, 1, TMap<TString, ui32>(), nullptr, nullptr, nullptr, nullptr)); ActorSystem.reset(new TActorSystem{setup, AppData.get(), logSettings}); diff --git a/ydb/core/blobstorage/dsproxy/ut_fat/dsproxy_ut.cpp b/ydb/core/blobstorage/dsproxy/ut_fat/dsproxy_ut.cpp index 6560fa4ec8..0bcfb640ef 100644 --- a/ydb/core/blobstorage/dsproxy/ut_fat/dsproxy_ut.cpp +++ b/ydb/core/blobstorage/dsproxy/ut_fat/dsproxy_ut.cpp @@ -4092,11 +4092,11 @@ public: } TActorSetupCmd profilerSetup(CreateProfilerActor(nullptr, "."), TMailboxType::Simple, 0); - setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(MakeProfilerID(nodeId), profilerSetup)); + setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(MakeProfilerID(nodeId), std::move(profilerSetup))); const TActorId nameserviceId = GetNameserviceActorId(); TActorSetupCmd nameserviceSetup(CreateNameserverTable(nameserverTable), TMailboxType::Simple, 0); - setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(nameserviceId, nameserviceSetup)); + setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(nameserviceId, std::move(nameserviceSetup))); return setup; } @@ -4140,8 +4140,8 @@ public: NActors::CreateStderrBackend(), counters.GetSubgroup("counters", "utils")); NActors::TActorSetupCmd loggerActorCmd(loggerActor, NActors::TMailboxType::Simple, 2); - std::pair<NActors::TActorId, NActors::TActorSetupCmd> loggerActorPair(loggerActorId, loggerActorCmd); - setup->LocalServices.push_back(loggerActorPair); + std::pair<NActors::TActorId, NActors::TActorSetupCmd> loggerActorPair(loggerActorId, std::move(loggerActorCmd)); + setup->LocalServices.push_back(std::move(loggerActorPair)); return logSettings; } @@ -4191,7 +4191,7 @@ public: std::unique_ptr<IActor> proxyActor{CreateBlobStorageGroupProxyConfigured(TIntrusivePtr(bsInfo), false, dsProxyNodeMon, TIntrusivePtr(storagePoolCounters), args.EnablePutBatching, DefaultEnableVPatch)}; TActorSetupCmd bsproxySetup(proxyActor.release(), TMailboxType::Revolving, 3); - setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(env->ProxyId, bsproxySetup)); + setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(env->ProxyId, std::move(bsproxySetup))); TTempDir tempDir; NPDisk::TKey mainKey = 123; @@ -4231,7 +4231,7 @@ public: TActorSetupCmd pDiskSetup( CreatePDisk(pDiskConfig.Get(), mainKeys, counters), TMailboxType::Revolving, 0); - setup2->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(pdiskId, pDiskSetup)); + setup2->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(pdiskId, std::move(pDiskSetup))); TVDiskConfig::TBaseInfo baseInfo( env->VDiskIds[i], @@ -4255,13 +4255,13 @@ public: IActor* vDisk = CreateVDisk(vDiskConfig, bsInfo, counters); TActorSetupCmd vDiskSetup(vDisk, TMailboxType::Revolving, 0); - setup2->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(env->VDisks[i], vDiskSetup)); + setup2->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(env->VDisks[i], std::move(vDiskSetup))); } } TActorSetupCmd proxyTestSetup(new T(env->ProxyId, bsInfo.Get(), env, args.Parametrs), TMailboxType::Revolving, 0); - setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(env->ProxyTestId, proxyTestSetup)); + setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(env->ProxyTestId, std::move(proxyTestSetup))); ////////////////////////////////////////////////////////////////////////////// GetServiceCounters(counters, "utils"); diff --git a/ydb/core/blobstorage/incrhuge/ut/incrhuge_basic_ut.cpp b/ydb/core/blobstorage/incrhuge/ut/incrhuge_basic_ut.cpp index 5c8c06992d..dde622a865 100644 --- a/ydb/core/blobstorage/incrhuge/ut/incrhuge_basic_ut.cpp +++ b/ydb/core/blobstorage/incrhuge/ut/incrhuge_basic_ut.cpp @@ -67,7 +67,7 @@ public: ui64 pDiskCategory = 0; TIntrusivePtr<TPDiskConfig> pDiskConfig = new TPDiskConfig(Path, PDiskGuid, 1, pDiskCategory); TActorSetupCmd pDiskSetup(CreatePDisk(pDiskConfig.Get(), MainKey, Counters), TMailboxType::Revolving, 0); - setup->LocalServices.emplace_back(PDiskId, pDiskSetup); + setup->LocalServices.emplace_back(PDiskId, std::move(pDiskSetup)); TActorId pdiskActorId; if (counter) { @@ -92,7 +92,7 @@ public: KeeperId = MakeIncrHugeKeeperId(1); TActorSetupCmd keeperSetup(CreateIncrHugeKeeper(settings), TMailboxType::Revolving, 0); - setup->LocalServices.emplace_back(KeeperId, keeperSetup); + setup->LocalServices.emplace_back(KeeperId, std::move(keeperSetup)); //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // LOGGER @@ -116,7 +116,7 @@ public: NActors::TLoggerActor *loggerActor = new NActors::TLoggerActor{logSettings, NActors::CreateStderrBackend(), Counters}; NActors::TActorSetupCmd loggerActorCmd{loggerActor, NActors::TMailboxType::Simple, 2}; - setup->LocalServices.emplace_back(loggerActorId, loggerActorCmd); + setup->LocalServices.emplace_back(loggerActorId, std::move(loggerActorCmd)); AppData.reset(new TAppData(0, 1, 2, 1, TMap<TString, ui32>(), nullptr, nullptr, nullptr, nullptr)); IoContext = std::make_shared<NPDisk::TIoContextFactoryOSS>(); AppData->IoContextFactory = IoContext.get(); diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actorsystem_creator.h b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actorsystem_creator.h index 349e00d0b8..524994a906 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actorsystem_creator.h +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actorsystem_creator.h @@ -51,10 +51,10 @@ public: NKikimrServices::EServiceKikimr_Name ); Counters = MakeIntrusive<::NMonitoring::TDynamicCounters>(); - NActors::TLoggerActor *loggerActor = new NActors::TLoggerActor(logSettings, NActors::CreateNullBackend(), + auto loggerActor = std::make_unique<NActors::TLoggerActor>(logSettings, NActors::CreateNullBackend(), GetServiceCounters(Counters, "utils")); - NActors::TActorSetupCmd loggerActorCmd(loggerActor, NActors::TMailboxType::Simple, 2); - setup->LocalServices.emplace_back(NActors::TActorId(1, "logger"), loggerActorCmd); + NActors::TActorSetupCmd loggerActorCmd(std::move(loggerActor), NActors::TMailboxType::Simple, 2); + setup->LocalServices.emplace_back(NActors::TActorId(1, "logger"), std::move(loggerActorCmd)); ActorSystem = std::make_unique<TActorSystem>(setup, AppData.get(), logSettings); ActorSystem->Start(); diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut_run.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut_run.cpp index 5b7243c4c1..1db5f67861 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut_run.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut_run.cpp @@ -58,7 +58,7 @@ void Run(TVector<IActor*> tests, TTestRunConfig runCfg) { const TActorId nameserviceId = GetNameserviceActorId(); TActorSetupCmd nameserviceSetup(CreateNameserverTable(nameserverTable), TMailboxType::Simple, 0); - setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(nameserviceId, nameserviceSetup)); + setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(nameserviceId, std::move(nameserviceSetup))); TString dataPath; if (!runCfg.TestContext->IsFormatedDiskExpected()) { @@ -91,12 +91,12 @@ void Run(TVector<IActor*> tests, TTestRunConfig runCfg) { NPDisk::TMainKey mainKey = {NPDisk::YdbDefaultPDiskSequence}; TActorSetupCmd pDiskSetup(CreatePDisk(pDiskConfig.Get(), mainKey, mainCounters), TMailboxType::Revolving, 0); - setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(pDiskId, pDiskSetup)); + setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(pDiskId, std::move(pDiskSetup))); for (ui32 i = 0; i < runCfg.Instances; ++i) { testIds[i] = MakeBlobStorageProxyID(1 + i); TActorSetupCmd testSetup(tests[i], TMailboxType::Revolving, 0); - setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(testIds[i], testSetup)); + setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(testIds[i], std::move(testSetup))); } AtomicSet(doneCounter, 0); @@ -133,8 +133,8 @@ void Run(TVector<IActor*> tests, TTestRunConfig runCfg) { IsLowVerbose ? NActors::CreateStderrBackend() : NActors::CreateNullBackend(), GetServiceCounters(counters, "utils")); NActors::TActorSetupCmd loggerActorCmd(loggerActor, NActors::TMailboxType::Simple, 2); - std::pair<NActors::TActorId, NActors::TActorSetupCmd> loggerActorPair(loggerActorId, loggerActorCmd); - setup1->LocalServices.push_back(loggerActorPair); + std::pair<NActors::TActorId, NActors::TActorSetupCmd> loggerActorPair(loggerActorId, std::move(loggerActorCmd)); + setup1->LocalServices.push_back(std::move(loggerActorPair)); ////////////////////////////////////////////////////////////////////////////// actorSystem1.Reset(new TActorSystem(setup1, &appData, logSettings)); diff --git a/ydb/core/blobstorage/ut_vdisk/lib/astest.h b/ydb/core/blobstorage/ut_vdisk/lib/astest.h index 99794a40d9..8aa7361289 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/astest.h +++ b/ydb/core/blobstorage/ut_vdisk/lib/astest.h @@ -63,7 +63,7 @@ inline void TTestWithActorSystem::Run(NActors::IActor *testActor) { const TActorId nameserviceId = GetNameserviceActorId(); TActorSetupCmd nameserviceSetup(CreateNameserverTable(nameserverTable), TMailboxType::Simple, 0); - setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(nameserviceId, nameserviceSetup)); + setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(nameserviceId, std::move(nameserviceSetup))); ///////////////////////// LOGGER /////////////////////////////////////////////// @@ -88,14 +88,14 @@ inline void TTestWithActorSystem::Run(NActors::IActor *testActor) { NActors::CreateStderrBackend(), Counters->GetSubgroup("logger", "counters")); NActors::TActorSetupCmd loggerActorCmd(loggerActor, NActors::TMailboxType::Simple, 0); - std::pair<NActors::TActorId, NActors::TActorSetupCmd> loggerActorPair(loggerActorId, loggerActorCmd); - setup1->LocalServices.push_back(loggerActorPair); + std::pair<NActors::TActorId, NActors::TActorSetupCmd> loggerActorPair(loggerActorId, std::move(loggerActorCmd)); + setup1->LocalServices.push_back(std::move(loggerActorPair)); ////////////////////////////////////////////////////////////////////////////// ///////////////////////// SETUP TEST ACTOR /////////////////////////////////// NActors::TActorId testActorId = NActors::TActorId(1, "test123"); TActorSetupCmd testActorSetup(testActor, TMailboxType::Simple, 0); - setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(testActorId, testActorSetup)); + setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(testActorId, std::move(testActorSetup))); ////////////////////////////////////////////////////////////////////////////// ///////////////////////// TYPE REGISTRY ////////////////////////////////////// diff --git a/ydb/core/blobstorage/ut_vdisk/lib/prepare.cpp b/ydb/core/blobstorage/ut_vdisk/lib/prepare.cpp index 013e4911c4..3aa50efb81 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/prepare.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/prepare.cpp @@ -164,7 +164,7 @@ void TAllPDisks::ActorSetupCmd(NActors::TActorSystemSetup *setup, ui32 node, const NPDisk::TMainKey mainKey = {NPDisk::YdbDefaultPDiskSequence}; TActorSetupCmd pDiskSetup(CreatePDisk(pDiskConfig.Get(), mainKey, counters), TMailboxType::Revolving, 0); - setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(inst.PDiskActorID, pDiskSetup)); + setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(inst.PDiskActorID, std::move(pDiskSetup))); } } @@ -215,7 +215,7 @@ void TAllVDisks::ActorSetupCmd(NActors::TActorSystemSetup *setup, NKikimr::TBlob TVDiskInstance &vdisk = VDisks[i]; if (vdisk.Initialized) { TActorSetupCmd vdiskSetup(CreateVDisk(vdisk.Cfg.Get(), groupInfo, counters), TMailboxType::Revolving, 0); - setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(vdisk.ActorID, vdiskSetup)); + setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(vdisk.ActorID, std::move(vdiskSetup))); } } } @@ -302,7 +302,7 @@ void TConfiguration::Prepare(IVDiskSetup *vdiskSetup, bool newPDisks, bool runRe const TActorId nameserviceId = GetNameserviceActorId(); TActorSetupCmd nameserviceSetup(CreateNameserverTable(nameserverTable), TMailboxType::Simple, 0); - setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(nameserviceId, nameserviceSetup)); + setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(nameserviceId, std::move(nameserviceSetup))); ui64 initOwnerRound = 1; // setup pdisks @@ -360,8 +360,8 @@ void TConfiguration::Prepare(IVDiskSetup *vdiskSetup, bool newPDisks, bool runRe NActors::CreateStderrBackend(), Counters->GetSubgroup("logger", "counters")); NActors::TActorSetupCmd loggerActorCmd(loggerActor, NActors::TMailboxType::Simple, 0); - std::pair<NActors::TActorId, NActors::TActorSetupCmd> loggerActorPair(loggerActorId, loggerActorCmd); - setup1->LocalServices.push_back(loggerActorPair); + std::pair<NActors::TActorId, NActors::TActorSetupCmd> loggerActorPair(loggerActorId, std::move(loggerActorCmd)); + setup1->LocalServices.push_back(std::move(loggerActorPair)); ////////////////////////////////////////////////////////////////////////////// ///////////////////////// MONITORING SETTINGS ///////////////////////////////// diff --git a/ydb/core/control/immediate_control_board_actor_ut.cpp b/ydb/core/control/immediate_control_board_actor_ut.cpp index 0cb9da2783..d703d0e3b8 100644 --- a/ydb/core/control/immediate_control_board_actor_ut.cpp +++ b/ydb/core/control/immediate_control_board_actor_ut.cpp @@ -97,19 +97,19 @@ static void Run(i64 instances = 1) { const TActorId nameserviceId = GetNameserviceActorId(); TActorSetupCmd nameserviceSetup(CreateNameserverTable(nameserverTable), TMailboxType::Simple, 0); - setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(nameserviceId, nameserviceSetup)); + setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(nameserviceId, std::move(nameserviceSetup))); // ICB Actor creation TActorId IcbActorId = MakeIcbId(setup->NodeId); TActorSetupCmd testSetup(CreateImmediateControlActor(appData.Icb, Counters), TMailboxType::Revolving, 0); - setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(IcbActorId, testSetup)); + setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(IcbActorId, std::move(testSetup))); THolder<TTestConfig> testConfig(new TTestConfig(IcbActorId, appData.Icb.Get())); for (ui32 i = 0; i < instances; ++i) { testIds[i] = MakeBlobStorageProxyID(1 + i); TActorSetupCmd testSetup(new T(testConfig.Get()), TMailboxType::Revolving, 0); - setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(testIds[i], testSetup)); + setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(testIds[i], std::move(testSetup))); } AtomicSet(DoneCounter, 0); @@ -137,8 +137,8 @@ static void Run(i64 instances = 1) { NActors::TLoggerActor *loggerActor = new NActors::TLoggerActor(logSettings, NActors::CreateStderrBackend(), GetServiceCounters(Counters, "utils")); NActors::TActorSetupCmd loggerActorCmd(loggerActor, NActors::TMailboxType::Simple, 2); - std::pair<NActors::TActorId, NActors::TActorSetupCmd> loggerActorPair(loggerActorId, loggerActorCmd); - setup->LocalServices.push_back(loggerActorPair); + std::pair<NActors::TActorId, NActors::TActorSetupCmd> loggerActorPair(loggerActorId, std::move(loggerActorCmd)); + setup->LocalServices.push_back(std::move(loggerActorPair)); ////////////////////////////////////////////////////////////////////////////// ActorSystem.Reset(new TActorSystem(setup, &appData, logSettings)); diff --git a/ydb/core/driver_lib/run/kikimr_services_initializers.cpp b/ydb/core/driver_lib/run/kikimr_services_initializers.cpp index 5379919c86..f0ce5d1870 100644 --- a/ydb/core/driver_lib/run/kikimr_services_initializers.cpp +++ b/ydb/core/driver_lib/run/kikimr_services_initializers.cpp @@ -1450,8 +1450,8 @@ void TLoggerInitializer::InitializeServices( // log settings must be initialized before calling this method NActors::TLoggerActor *loggerActor = new NActors::TLoggerActor(LogSettings, LogBackend, utilsCounters); NActors::TActorSetupCmd loggerActorCmd(loggerActor, NActors::TMailboxType::HTSwap, appData->IOPoolId); - std::pair<NActors::TActorId, NActors::TActorSetupCmd> loggerActorPair(LogSettings->LoggerActorId, loggerActorCmd); - setup->LocalServices.push_back(loggerActorPair); + std::pair<NActors::TActorId, NActors::TActorSetupCmd> loggerActorPair(LogSettings->LoggerActorId, std::move(loggerActorCmd)); + setup->LocalServices.push_back(std::move(loggerActorPair)); IActor *configurator; if (PathToConfigCacheFile && !appData->FeatureFlags.GetEnableConfigurationCache()) { @@ -1477,7 +1477,7 @@ void TSchedulerActorInitializer::InitializeServices( NActors::IActor *schedulerActor = CreateSchedulerActor(CreateSchedulerConfig(systemConfig.GetScheduler())); if (schedulerActor) { NActors::TActorSetupCmd schedulerActorCmd(schedulerActor, NActors::TMailboxType::ReadAsFilled, appData->SystemPoolId); - setup->LocalServices.emplace_back(MakeSchedulerActorId(), schedulerActorCmd); + setup->LocalServices.emplace_back(MakeSchedulerActorId(), std::move(schedulerActorCmd)); } } @@ -1493,7 +1493,7 @@ void TProfilerInitializer::InitializeServices( const TIntrusivePtr<::NMonitoring::TDynamicCounters> utilsCounters = GetServiceCounters(appData->Counters, "utils"); TActorSetupCmd profilerSetup(CreateProfilerActor(utilsCounters, "/var/tmp"), TMailboxType::HTSwap, 0); - setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(MakeProfilerID(NodeId), profilerSetup)); + setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(MakeProfilerID(NodeId), std::move(profilerSetup))); } // TResourceBrokerInitializer @@ -1522,7 +1522,7 @@ void TResourceBrokerInitializer::InitializeServices( auto counters = GetServiceCounters(appData->Counters, "tablets"); TActorSetupCmd actorSetup = { NResourceBroker::CreateResourceBrokerActor(config, counters), TMailboxType::ReadAsFilled, appData->UserPoolId }; - setup->LocalServices.push_back(std::make_pair(NResourceBroker::MakeResourceBrokerID(), actorSetup)); + setup->LocalServices.push_back(std::make_pair(NResourceBroker::MakeResourceBrokerID(), std::move(actorSetup))); } // TRestartsCountPublisher @@ -1618,7 +1618,7 @@ void TTabletMonitoringProxyInitializer::InitializeServices( proxyConfig.SetRetryLimitCount(Config.GetMonitoringConfig().GetTabletMonitoringRetries()); TActorSetupCmd tabletMonitoringProxySetup(NTabletMonitoringProxy::CreateTabletMonitoringProxy(std::move(proxyConfig)), TMailboxType::ReadAsFilled, appData->UserPoolId); - setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(NTabletMonitoringProxy::MakeTabletMonitoringProxyID(), tabletMonitoringProxySetup)); + setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(NTabletMonitoringProxy::MakeTabletMonitoringProxyID(), std::move(tabletMonitoringProxySetup))); } @@ -1633,11 +1633,11 @@ void TTabletCountersAggregatorInitializer::InitializeServices( const NKikimr::TAppData* appData) { { TActorSetupCmd tabletCountersAggregatorSetup(CreateTabletCountersAggregator(false), TMailboxType::ReadAsFilled, appData->UserPoolId); - setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(MakeTabletCountersAggregatorID(NodeId, false), tabletCountersAggregatorSetup)); + setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(MakeTabletCountersAggregatorID(NodeId, false), std::move(tabletCountersAggregatorSetup))); } { TActorSetupCmd tabletCountersAggregatorSetup(CreateTabletCountersAggregator(true), TMailboxType::ReadAsFilled, appData->UserPoolId); - setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(MakeTabletCountersAggregatorID(NodeId, true), tabletCountersAggregatorSetup)); + setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(MakeTabletCountersAggregatorID(NodeId, true), std::move(tabletCountersAggregatorSetup))); } } @@ -1651,7 +1651,7 @@ void TGRpcProxyStatusInitializer::InitializeServices( NActors::TActorSystemSetup* setup, const NKikimr::TAppData* appData) { TActorSetupCmd gRpcProxyStatusSetup(CreateGRpcProxyStatus(), TMailboxType::ReadAsFilled, appData->UserPoolId); - setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(MakeGRpcProxyStatusID(NodeId), gRpcProxyStatusSetup)); + setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(MakeGRpcProxyStatusID(NodeId), std::move(gRpcProxyStatusSetup))); } @@ -1852,7 +1852,7 @@ void TMessageBusServicesInitializer::InitializeServices(NActors::TActorSystemSet if (IActor* traceService = BusServer.CreateMessageBusTraceService()) { TActorSetupCmd messageBusTraceServiceSetup(traceService, TMailboxType::HTSwap, appData->IOPoolId); setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(NMessageBusTracer::MakeMessageBusTraceServiceID(), - messageBusTraceServiceSetup)); + std::move(messageBusTraceServiceSetup))); } } } @@ -2656,7 +2656,7 @@ void TTabletInfoInitializer::InitializeServices( NActors::TActorSystemSetup* setup, const NKikimr::TAppData* appData) { TActorSetupCmd tabletInfoSetup(NTabletInfo::CreateTabletInfo(), TMailboxType::ReadAsFilled, appData->UserPoolId); - setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(NTabletInfo::MakeTabletInfoID(), tabletInfoSetup)); + setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(NTabletInfo::MakeTabletInfoID(), std::move(tabletInfoSetup))); } TConfigValidatorsInitializer::TConfigValidatorsInitializer(const TKikimrRunConfig& runConfig) diff --git a/ydb/core/tablet_flat/test/libs/exec/events.h b/ydb/core/tablet_flat/test/libs/exec/events.h index b6aeb3e82f..5290010c7d 100644 --- a/ydb/core/tablet_flat/test/libs/exec/events.h +++ b/ydb/core/tablet_flat/test/libs/exec/events.h @@ -29,7 +29,7 @@ namespace NFake { TEvFire(ui32 level, const TActorId &alias, TActorSetupCmd cmd) : Level(level) , Alias(alias) - , Cmd(cmd) + , Cmd(std::move(cmd)) { } diff --git a/ydb/core/tablet_flat/test/libs/exec/leader.h b/ydb/core/tablet_flat/test/libs/exec/leader.h index 45683fadbb..430c12a6a9 100644 --- a/ydb/core/tablet_flat/test/libs/exec/leader.h +++ b/ydb/core/tablet_flat/test/libs/exec/leader.h @@ -47,7 +47,7 @@ namespace NFake { void Inbox(TAutoPtr<::NActors::IEventHandle> &eh) { if (auto *fire = eh->CastAsLocal<NFake::TEvFire>()) { - DoFire(fire->Level, fire->Alias, fire->Cmd); + DoFire(fire->Level, fire->Alias, std::move(fire->Cmd)); } else if (eh->CastAsLocal<TEvents::TEvGone>()) { HandleGone(eh->Sender); } else if (eh->CastAsLocal<TEvents::TEvPoison>()) { @@ -94,10 +94,10 @@ namespace NFake { } } - void DoFire(ui32 level, const TActorId &alias, TActorSetupCmd &cmd) + void DoFire(ui32 level, const TActorId &alias, TActorSetupCmd cmd) { if (level <= Edge && Levels[level].Alive) { - auto actor = Register(cmd.Actor, cmd.MailboxType, 0); + auto actor = Register(cmd.Actor.release(), cmd.MailboxType, 0); auto result = Childs.emplace(actor, level); Y_VERIFY(result.second, "Cannot register same actor twice"); diff --git a/ydb/core/testlib/actors/test_runtime.cpp b/ydb/core/testlib/actors/test_runtime.cpp index 553d915ce3..fddfaa24c7 100644 --- a/ydb/core/testlib/actors/test_runtime.cpp +++ b/ydb/core/testlib/actors/test_runtime.cpp @@ -108,8 +108,8 @@ namespace NActors { const auto* app0 = App0.Get(); if (!SingleSysEnv) { const TIntrusivePtr<::NMonitoring::TDynamicCounters> profilerCounters = NKikimr::GetServiceCounters(node->DynamicCounters, "utils"); - TActorSetupCmd profilerSetup(CreateProfilerActor(profilerCounters, "."), TMailboxType::Simple, 0); - node->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(MakeProfilerID(FirstNodeId + nodeIndex), profilerSetup)); + TTestActorSetupCmd profilerSetup{CreateProfilerActor(profilerCounters, "."), TMailboxType::Simple, 0}; + node->LocalServices.push_back(std::pair<TActorId, TTestActorSetupCmd>(MakeProfilerID(FirstNodeId + nodeIndex), profilerSetup)); } if (!UseRealThreads) { diff --git a/ydb/core/util/testactorsys.h b/ydb/core/util/testactorsys.h index d2f2707be7..43ab9beea7 100644 --- a/ydb/core/util/testactorsys.h +++ b/ydb/core/util/testactorsys.h @@ -109,8 +109,8 @@ class TTestActorSystem { TActorId CurrentRecipient; ui32 CurrentNodeId = 0; ui64 EventsProcessed = 0; - std::unordered_map<ui32, TPerNodeInfo> PerNodeInfo; TSingleThreadInterconnectMock InterconnectMock; + std::unordered_map<ui32, TPerNodeInfo> PerNodeInfo; std::set<TActorId> LoggerActorIds; static thread_local TTestActorSystem *CurrentTestActorSystem; @@ -237,15 +237,14 @@ public: // we create this actor for correct service lookup through ActorSystem setup->LocalServices.emplace_back(LoggerSettings_->LoggerActorId, TActorSetupCmd( - new TEdgeActor(__FILE__, __LINE__), TMailboxType::Simple, 0)); + std::make_unique<TEdgeActor>(__FILE__, __LINE__), TMailboxType::Simple, 0)); auto common = MakeIntrusive<TInterconnectProxyCommon>(); auto& proxyActors = setup->Interconnect.ProxyActors; proxyActors.resize(MaxNodeId + 1); for (const auto& [peerNodeId, peerInfo] : PerNodeInfo) { if (peerNodeId != nodeId) { - proxyActors[peerNodeId] = TActorSetupCmd(InterconnectMock.CreateProxyActor(nodeId, peerNodeId, - common).release(), TMailboxType::Simple, 0); + proxyActors[peerNodeId] = TActorSetupCmd(InterconnectMock.CreateProxyActor(nodeId, peerNodeId, common), TMailboxType::Simple, 0); } } |