diff options
author | alexvru <alexvru@ydb.tech> | 2022-10-28 13:20:12 +0300 |
---|---|---|
committer | alexvru <alexvru@ydb.tech> | 2022-10-28 13:20:12 +0300 |
commit | 5f4f0d7775ea9bc0abd2e10f21823900202bf880 (patch) | |
tree | 0eab2135b4195fca9b71b8989f10c48a6d22b1f3 | |
parent | 15d014b82db58bc2964edbc39a38649dbc5b2d26 (diff) | |
download | ydb-5f4f0d7775ea9bc0abd2e10f21823900202bf880.tar.gz |
Add extra Y_VERIFY in PassAway
-rw-r--r-- | library/cpp/actors/core/actor.cpp | 2 | ||||
-rw-r--r-- | library/cpp/actors/core/actorsystem.h | 1 | ||||
-rw-r--r-- | library/cpp/actors/core/executor_pool_base.cpp | 4 | ||||
-rw-r--r-- | library/cpp/actors/core/executor_pool_base.h | 1 | ||||
-rw-r--r-- | library/cpp/actors/core/executor_pool_united.cpp | 1 | ||||
-rw-r--r-- | library/cpp/actors/core/executor_thread.cpp | 5 | ||||
-rw-r--r-- | library/cpp/actors/core/executor_thread.h | 2 | ||||
-rw-r--r-- | library/cpp/actors/testlib/test_runtime.cpp | 4 | ||||
-rw-r--r-- | ydb/core/actorlib_impl/actor_tracker.cpp | 2 | ||||
-rw-r--r-- | ydb/core/util/testactorsys.cpp | 5 | ||||
-rw-r--r-- | ydb/core/util/testactorsys.h | 6 |
11 files changed, 27 insertions, 6 deletions
diff --git a/library/cpp/actors/core/actor.cpp b/library/cpp/actors/core/actor.cpp index 3be4043168..8863205860 100644 --- a/library/cpp/actors/core/actor.cpp +++ b/library/cpp/actors/core/actor.cpp @@ -175,7 +175,7 @@ namespace NActors { void IActor::PassAway() { auto& cx = *TlsActivationContext; - cx.ExecutorThread.UnregisterActor(&cx.Mailbox, SelfActorId.LocalId()); + cx.ExecutorThread.UnregisterActor(&cx.Mailbox, SelfActorId); } double IActor::GetElapsedTicksAsSeconds() const { diff --git a/library/cpp/actors/core/actorsystem.h b/library/cpp/actors/core/actorsystem.h index dc0bdc370f..3a47cc1603 100644 --- a/library/cpp/actors/core/actorsystem.h +++ b/library/cpp/actors/core/actorsystem.h @@ -65,6 +65,7 @@ namespace NActors { // for workers virtual ui32 GetReadyActivation(TWorkerContext& wctx, ui64 revolvingCounter) = 0; virtual void ReclaimMailbox(TMailboxType::EType mailboxType, ui32 hint, TWorkerId workerId, ui64 revolvingCounter) = 0; + virtual TMailboxHeader *ResolveMailbox(ui32 hint) = 0; /** * Schedule one-shot event that will be send at given time point in the future. diff --git a/library/cpp/actors/core/executor_pool_base.cpp b/library/cpp/actors/core/executor_pool_base.cpp index 6d48b3d32f..fe46d56fdc 100644 --- a/library/cpp/actors/core/executor_pool_base.cpp +++ b/library/cpp/actors/core/executor_pool_base.cpp @@ -41,6 +41,10 @@ namespace NActors { MailboxTable->ReclaimMailbox(mailboxType, hint, revolvingWriteCounter); } + TMailboxHeader *TExecutorPoolBaseMailboxed::ResolveMailbox(ui32 hint) { + return MailboxTable->Get(hint); + } + ui64 TExecutorPoolBaseMailboxed::AllocateID() { return ActorSystem->AllocateIDSpace(1); } diff --git a/library/cpp/actors/core/executor_pool_base.h b/library/cpp/actors/core/executor_pool_base.h index 70c85e90c0..6514978238 100644 --- a/library/cpp/actors/core/executor_pool_base.h +++ b/library/cpp/actors/core/executor_pool_base.h @@ -23,6 +23,7 @@ namespace NActors { TExecutorPoolBaseMailboxed(ui32 poolId, ui32 maxActivityType); ~TExecutorPoolBaseMailboxed(); void ReclaimMailbox(TMailboxType::EType mailboxType, ui32 hint, TWorkerId workerId, ui64 revolvingWriteCounter) override; + TMailboxHeader *ResolveMailbox(ui32 hint) override; bool Send(TAutoPtr<IEventHandle>& ev) override; bool SendWithContinuousExecution(TAutoPtr<IEventHandle>& ev) override; TActorId Register(IActor* actor, TMailboxType::EType mailboxType, ui64 revolvingWriteCounter, const TActorId& parentId) override; diff --git a/library/cpp/actors/core/executor_pool_united.cpp b/library/cpp/actors/core/executor_pool_united.cpp index 8e8cff089b..def7a2f335 100644 --- a/library/cpp/actors/core/executor_pool_united.cpp +++ b/library/cpp/actors/core/executor_pool_united.cpp @@ -863,6 +863,7 @@ namespace NActors { // Should never be called void ReclaimMailbox(TMailboxType::EType, ui32, TWorkerId, ui64) override { Y_FAIL(); } + TMailboxHeader *ResolveMailbox(ui32) override { Y_FAIL(); } void Schedule(TInstant, TAutoPtr<IEventHandle>, ISchedulerCookie*, TWorkerId) override { Y_FAIL(); } void Schedule(TMonotonic, TAutoPtr<IEventHandle>, ISchedulerCookie*, TWorkerId) override { Y_FAIL(); } void Schedule(TDuration, TAutoPtr<IEventHandle>, ISchedulerCookie*, TWorkerId) override { Y_FAIL(); } diff --git a/library/cpp/actors/core/executor_thread.cpp b/library/cpp/actors/core/executor_thread.cpp index 8321210d96..ffe2382b38 100644 --- a/library/cpp/actors/core/executor_thread.cpp +++ b/library/cpp/actors/core/executor_thread.cpp @@ -61,8 +61,9 @@ namespace NActors { return Ctx.Executor->Register(actor, mailbox, hint, parentId ? parentId : CurrentRecipient); } - void TExecutorThread::UnregisterActor(TMailboxHeader* mailbox, ui64 localActorId) { - IActor* actor = mailbox->DetachActor(localActorId); + void TExecutorThread::UnregisterActor(TMailboxHeader* mailbox, TActorId actorId) { + Y_VERIFY_DEBUG(actorId.PoolID() == ExecutorPool->PoolId && ExecutorPool->ResolveMailbox(actorId.Hint()) == mailbox); + IActor* actor = mailbox->DetachActor(actorId.LocalId()); Ctx.DecrementActorsAliveByActivity(actor->GetActivityType()); DyingActors.push_back(THolder(actor)); } diff --git a/library/cpp/actors/core/executor_thread.h b/library/cpp/actors/core/executor_thread.h index 6cb6208abd..8597336bd1 100644 --- a/library/cpp/actors/core/executor_thread.h +++ b/library/cpp/actors/core/executor_thread.h @@ -42,7 +42,7 @@ namespace NActors { TActorId RegisterActor(IActor* actor, TMailboxType::EType mailboxType = TMailboxType::HTSwap, ui32 poolId = Max<ui32>(), const TActorId& parentId = TActorId()); TActorId RegisterActor(IActor* actor, TMailboxHeader* mailbox, ui32 hint, const TActorId& parentId = TActorId()); - void UnregisterActor(TMailboxHeader* mailbox, ui64 localActorId); + void UnregisterActor(TMailboxHeader* mailbox, TActorId actorId); void DropUnregistered(); const std::vector<THolder<IActor>>& GetUnregistered() const { return DyingActors; } diff --git a/library/cpp/actors/testlib/test_runtime.cpp b/library/cpp/actors/testlib/test_runtime.cpp index 578dff353e..b14892f67d 100644 --- a/library/cpp/actors/testlib/test_runtime.cpp +++ b/library/cpp/actors/testlib/test_runtime.cpp @@ -307,6 +307,10 @@ namespace NActors { Node->MailboxTable->ReclaimMailbox(mailboxType, hint, revolvingCounter); } + TMailboxHeader *ResolveMailbox(ui32 hint) override { + return Node->MailboxTable->Get(hint); + } + void Schedule(TInstant deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie *cookie, TWorkerId workerId) override { DoSchedule(deadline, ev, cookie, workerId); } diff --git a/ydb/core/actorlib_impl/actor_tracker.cpp b/ydb/core/actorlib_impl/actor_tracker.cpp index 99787dfce1..51bab61580 100644 --- a/ydb/core/actorlib_impl/actor_tracker.cpp +++ b/ydb/core/actorlib_impl/actor_tracker.cpp @@ -77,7 +77,7 @@ namespace NActors { // we have finished processing the query; send TEvPoisonTaken message and Die if (currentValue == StopBit && RegisteredActors.empty()) { ctx.Send(KillerActorId, new TEvents::TEvPoisonTaken); - ctx.ExecutorThread.UnregisterActor(&ctx.Mailbox, ctx.SelfID.LocalId()); + ctx.ExecutorThread.UnregisterActor(&ctx.Mailbox, ctx.SelfID); } } diff --git a/ydb/core/util/testactorsys.cpp b/ydb/core/util/testactorsys.cpp index de8e6e928f..2c5c0bded5 100644 --- a/ydb/core/util/testactorsys.cpp +++ b/ydb/core/util/testactorsys.cpp @@ -27,6 +27,11 @@ public: Y_FAIL(); } + TMailboxHeader *ResolveMailbox(ui32 hint) override { + const auto it = Context->Mailboxes.find({NodeId, PoolId, hint}); + return it != Context->Mailboxes.end() ? &it->second.Header : nullptr; + } + void Schedule(TInstant deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie, NActors::TWorkerId /*workerId*/) override { Context->Schedule(deadline, ev, cookie, NodeId); } diff --git a/ydb/core/util/testactorsys.h b/ydb/core/util/testactorsys.h index ab12d5c704..af46b14ab6 100644 --- a/ydb/core/util/testactorsys.h +++ b/ydb/core/util/testactorsys.h @@ -17,6 +17,8 @@ namespace NKikimr { +class TTestExecutorPool; + class TTestActorSystem { class TTestSchedulerThread : public ISchedulerThread { TTestActorSystem *Context; @@ -158,6 +160,8 @@ class TTestActorSystem { } }; + friend class TTestExecutorPool; + public: std::function<bool(ui32, std::unique_ptr<IEventHandle>&)> FilterFunction; std::function<bool(ui32, std::unique_ptr<IEventHandle>&, ISchedulerCookie*, TInstant)> FilterEnqueue; @@ -641,7 +645,7 @@ public: ActorName.erase(nameIt); // unregister actor through the executor - info->ExecutorThread->UnregisterActor(&mbox.Header, actorId.LocalId()); + info->ExecutorThread->UnregisterActor(&mbox.Header, actorId); // terminate unregistered actor info->ExecutorThread->DropUnregistered(); |