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 core worker crash bug when multi-thread create actors #9674

Merged
merged 1 commit into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 5 additions & 3 deletions src/ray/core_worker/actor_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ bool ActorManager::AddActorHandle(std::unique_ptr<ActorHandle> actor_handle,
auto actor_notification_callback =
std::bind(&ActorManager::HandleActorStateNotification, this,
std::placeholders::_1, std::placeholders::_2);

RAY_CHECK_OK(gcs_client_->Actors().AsyncSubscribe(
actor_id, actor_notification_callback, nullptr));
{
absl::MutexLock lock(&gcs_client_mutex_);
RAY_CHECK_OK(gcs_client_->Actors().AsyncSubscribe(
actor_id, actor_notification_callback, nullptr));
}

if (!RayConfig::instance().gcs_actor_service_enabled()) {
RAY_CHECK(reference_counter_->SetDeleteCallback(
Expand Down
7 changes: 5 additions & 2 deletions src/ray/core_worker/actor_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,11 @@ class ActorManager {
void HandleActorStateNotification(const ActorID &actor_id,
const gcs::ActorTableData &actor_data);

/// GCS client
std::shared_ptr<gcs::GcsClient> gcs_client_;
/// Mutex to protect the gcs_client_ field.
/// NOTE: Now gcs client is not thread safe, so we add lock protection.
mutable absl::Mutex gcs_client_mutex_;
/// GCS client.
std::shared_ptr<gcs::GcsClient> gcs_client_ GUARDED_BY(gcs_client_mutex_);

/// Interface to submit tasks directly to other actors.
std::shared_ptr<CoreWorkerDirectActorTaskSubmitterInterface> direct_actor_submitter_;
Expand Down