Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix leased worker leak bug if lease worker requests that are still waiting to be scheduled when GCS restarts #9719

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add part code
  • Loading branch information
灵洵 committed Jul 28, 2020
commit 03f67a853f9c71070ce3cfe89fc769fdb90f3f64
7 changes: 6 additions & 1 deletion src/ray/core_worker/reference_count.cc
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,12 @@ bool ReferenceCounter::SetDeleteCallback(
return false;
}

// RAY_CHECK(!it->second.on_delete) << object_id;
// NOTE: In two cases, `GcsActorManager` will send `WaitForActorOutOfScope` request more
// than once, causing the delete callback to be set repeatedly.
// 1.If actors have not been registered successfully before GCS restarts, gcs client
// will resend the registration request after GCS restarts.
// 2.After GCS restarts, GCS will sent `WaitForActorOutOfScope` request to owned actors
ffbin marked this conversation as resolved.
Show resolved Hide resolved
// again.
it->second.on_delete = callback;
return true;
}
Expand Down
20 changes: 18 additions & 2 deletions src/ray/gcs/gcs_server/gcs_actor_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,19 @@ void GcsActorManager::LoadInitialData(const EmptyCallback &done) {
named_actors_.emplace(actor->GetName(), actor->GetActorID());
}

if (actor->GetState() == ray::rpc::ActorTableData::ALIVE) {
if (item.second.state() == ray::rpc::ActorTableData::DEPENDENCIES_UNREADY) {
const auto &owner = actor->GetOwnerAddress();
const auto &owner_node = ClientID::FromBinary(owner.raylet_id());
const auto &owner_worker = WorkerID::FromBinary(owner.worker_id());
RAY_CHECK(unresolved_actors_[owner_node][owner_worker]
.emplace(actor->GetActorID())
.second);
if (!actor->IsDetached() && worker_client_factory_) {
// This actor is owned. Send a long polling request to the actor's
// owner to determine when the actor should be removed.
PollOwnerForActorOutOfScope(actor);
}
} else if (item.second.state() == ray::rpc::ActorTableData::ALIVE) {
created_actors_[actor->GetNodeID()].emplace(actor->GetWorkerID(),
actor->GetActorID());
}
Expand Down Expand Up @@ -960,7 +972,11 @@ void GcsActorManager::LoadInitialData(const EmptyCallback &done) {
<< ", and the number of created actors is " << created_actors_.size();
for (auto &item : registered_actors_) {
auto &actor = item.second;
if (actor->GetState() != ray::rpc::ActorTableData::ALIVE) {
if (actor->GetState() != ray::rpc::ActorTableData::ALIVE &&
actor->GetState() != ray::rpc::ActorTableData::DEPENDENCIES_UNREADY) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to `PENDING_CREATION or RESTARTING"? That will be more explicit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

// We should not reschedule actors in state of `ALIVE`.
// We could not reschedule actors in state of `DEPENDENCIES_UNREADY` because the
// dependencies of them may not have been resolved yet.
RAY_LOG(DEBUG) << "Rescheduling a non-alive actor, actor id = "
<< actor->GetActorID() << ", state = " << actor->GetState();
gcs_actor_scheduler_->Reschedule(actor);
Expand Down