diff --git a/src/ray/gcs/gcs_server/gcs_actor_manager.cc b/src/ray/gcs/gcs_server/gcs_actor_manager.cc index ef2ecf88a..9bdd26b17 100644 --- a/src/ray/gcs/gcs_server/gcs_actor_manager.cc +++ b/src/ray/gcs/gcs_server/gcs_actor_manager.cc @@ -572,8 +572,7 @@ void GcsActorManager::DestroyActor(const ActorID &actor_id) { // Remove actor from `named_actors_` if its name is not empty. if (!actor->GetName().empty()) { auto it = named_actors_.find(actor->GetName()); - if (it != named_actors_.end()) { - RAY_CHECK(it->second == actor->GetActorID()); + if (it != named_actors_.end() && it->second == actor->GetActorID()) { named_actors_.erase(it); } } @@ -824,11 +823,11 @@ void GcsActorManager::ReconstructActor(const ActorID &actor_id, bool need_resche // Remove actor from `named_actors_` if its name is not empty. if (!actor->GetName().empty()) { auto it = named_actors_.find(actor->GetName()); - if (it != named_actors_.end()) { - RAY_CHECK(it->second == actor->GetActorID()); + if (it != named_actors_.end() && it->second == actor->GetActorID()) { named_actors_.erase(it); } } + mutable_actor_table_data->set_state(rpc::ActorTableData::DEAD); // The backend storage is reliable in the future, so the status must be ok. RAY_CHECK_OK(gcs_table_storage_->ActorTable().Put( diff --git a/src/ray/gcs/gcs_server/gcs_actor_manager.h b/src/ray/gcs/gcs_server/gcs_actor_manager.h index c74a8d814..289b23284 100644 --- a/src/ray/gcs/gcs_server/gcs_actor_manager.h +++ b/src/ray/gcs/gcs_server/gcs_actor_manager.h @@ -317,8 +317,8 @@ class GcsActorManager : public rpc::ActorInfoHandler { /// state associated with the actor and marks the actor as dead. For owned /// actors, this should be called when all actor handles have gone out of /// scope or the owner has died. - /// TODO: For detached actors, this should be called when the application - /// deregisters the actor. + /// NOTE: This method can be called multiple times in out-of-order and should be + /// idempotent. void DestroyActor(const ActorID &actor_id); /// Get unresolved actors that were submitted from the specified node.