From c5aa1eb042237094a361cbe2c1f5bdaf944d928b Mon Sep 17 00:00:00 2001 From: SangBin Cho Date: Wed, 8 Jul 2020 10:55:47 -0700 Subject: [PATCH] [GCS Actor Management] Fix a dashboard doesn't show the correct actor state. (#9275) * Fix a bug. * Address code review. * Remove an unnecessary comment. --- src/ray/gcs/gcs_server/gcs_actor_manager.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ray/gcs/gcs_server/gcs_actor_manager.cc b/src/ray/gcs/gcs_server/gcs_actor_manager.cc index e1dce49b0..37224c65e 100644 --- a/src/ray/gcs/gcs_server/gcs_actor_manager.cc +++ b/src/ray/gcs/gcs_server/gcs_actor_manager.cc @@ -533,7 +533,6 @@ void GcsActorManager::DestroyActor(const ActorID &actor_id) { // happen if the owner of the actor dies while there are still callers. // TODO(swang): We can skip this step and delete the actor table entry // entirely if the callers check directly whether the owner is still alive. - actor->UpdateAddress(rpc::Address()); auto mutable_actor_table_data = actor->GetMutableActorTableData(); mutable_actor_table_data->set_state(rpc::ActorTableData::DEAD); auto actor_table_data = @@ -625,7 +624,6 @@ void GcsActorManager::ReconstructActor(const ActorID &actor_id, bool need_resche RAY_CHECK(actor != nullptr); auto node_id = actor->GetNodeID(); auto worker_id = actor->GetWorkerID(); - actor->UpdateAddress(rpc::Address()); auto mutable_actor_table_data = actor->GetMutableActorTableData(); // If the need_reschedule is set to false, then set the `remaining_restarts` to 0 // so that the actor will never be rescheduled. @@ -646,14 +644,18 @@ void GcsActorManager::ReconstructActor(const ActorID &actor_id, bool need_resche if (remaining_restarts != 0) { mutable_actor_table_data->set_num_restarts(++num_restarts); mutable_actor_table_data->set_state(rpc::ActorTableData::RESTARTING); + const auto actor_table_data = actor->GetActorTableData(); + // Make sure to reset the address before flushing to GCS. Otherwise, + // GCS will mistakenly consider this lease request succeeds when restarting. + actor->UpdateAddress(rpc::Address()); mutable_actor_table_data->clear_resource_mapping(); // The backend storage is reliable in the future, so the status must be ok. RAY_CHECK_OK(gcs_table_storage_->ActorTable().Put( actor_id, *mutable_actor_table_data, - [this, actor_id, mutable_actor_table_data](Status status) { - RAY_CHECK_OK(gcs_pub_sub_->Publish( - ACTOR_CHANNEL, actor_id.Hex(), - mutable_actor_table_data->SerializeAsString(), nullptr)); + [this, actor_id, actor_table_data](Status status) { + RAY_CHECK_OK(gcs_pub_sub_->Publish(ACTOR_CHANNEL, actor_id.Hex(), + actor_table_data.SerializeAsString(), + nullptr)); })); gcs_actor_scheduler_->Schedule(actor); } else {