-
Notifications
You must be signed in to change notification settings - Fork 7.1k
[core] fix detached actor being unexpectedly killed #53562
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
Merged
edoakes
merged 3 commits into
ray-project:master
from
rueian:fix-detached-actor-killed-on-owner-exit
Jun 24, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
|
|
||
| #include <memory> | ||
| #include <string> | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| #include "ray/raylet/worker.h" | ||
|
|
@@ -29,9 +30,9 @@ class MockWorker : public WorkerInterface { | |
| MockWorker(WorkerID worker_id, int port, int runtime_env_hash = 0) | ||
| : worker_id_(worker_id), | ||
| port_(port), | ||
| is_detached_actor_(false), | ||
| runtime_env_hash_(runtime_env_hash), | ||
| job_id_(JobID::FromInt(859)) {} | ||
| job_id_(JobID::FromInt(859)), | ||
| proc_(Process::CreateNewDummy()) {} | ||
|
|
||
| WorkerID WorkerId() const override { return worker_id_; } | ||
|
|
||
|
|
@@ -47,6 +48,11 @@ class MockWorker : public WorkerInterface { | |
| task_ = assigned_task; | ||
| task_assign_time_ = absl::Now(); | ||
| root_detached_actor_id_ = assigned_task.GetTaskSpecification().RootDetachedActorId(); | ||
| const auto &task_spec = assigned_task.GetTaskSpecification(); | ||
| SetJobId(task_spec.JobId()); | ||
| SetBundleId(task_spec.PlacementGroupBundleId()); | ||
| SetOwnerAddress(task_spec.CallerAddress()); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make the MockWorker::SetAssignedTask align with the real one. |
||
| AssignTaskId(task_spec.TaskId()); | ||
| }; | ||
|
|
||
| absl::Time GetAssignedTaskTime() const override { return task_assign_time_; }; | ||
|
|
@@ -85,9 +91,9 @@ class MockWorker : public WorkerInterface { | |
| void MarkUnblocked() override { blocked_ = false; } | ||
| bool IsBlocked() const override { return blocked_; } | ||
|
|
||
| Process GetProcess() const override { return Process::CreateNewDummy(); } | ||
| Process GetProcess() const override { return proc_; } | ||
| StartupToken GetStartupToken() const override { return 0; } | ||
| void SetProcess(Process proc) override { RAY_CHECK(false) << "Method unused"; } | ||
| void SetProcess(Process proc) override { proc_ = std::move(proc); } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This allows us to inject a Process into a MockWorker. |
||
|
|
||
| Language GetLanguage() const override { | ||
| RAY_CHECK(false) << "Method unused"; | ||
|
|
@@ -119,16 +125,16 @@ class MockWorker : public WorkerInterface { | |
| RAY_CHECK(false) << "Method unused"; | ||
| return ""; | ||
| } | ||
| void MarkDetachedActor() override { is_detached_actor_ = true; } | ||
| bool IsDetachedActor() const override { return is_detached_actor_; } | ||
rueian marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| bool IsDetachedActor() const override { | ||
| return task_.GetTaskSpecification().IsDetachedActor(); | ||
| } | ||
|
|
||
| const std::shared_ptr<ClientConnection> Connection() const override { | ||
| RAY_CHECK(false) << "Method unused"; | ||
| return nullptr; | ||
| } | ||
| const rpc::Address &GetOwnerAddress() const override { | ||
| RAY_CHECK(false) << "Method unused"; | ||
| return address_; | ||
| } | ||
| const rpc::Address &GetOwnerAddress() const override { return address_; } | ||
|
|
||
| void ActorCallArgWaitComplete(int64_t tag) override { | ||
| RAY_CHECK(false) << "Method unused"; | ||
|
|
@@ -184,7 +190,6 @@ class MockWorker : public WorkerInterface { | |
| std::vector<double> borrowed_cpu_instances_; | ||
| std::optional<bool> is_gpu_; | ||
| std::optional<bool> is_actor_worker_; | ||
| bool is_detached_actor_; | ||
| BundleID bundle_id_; | ||
| bool blocked_ = false; | ||
| RayTask task_; | ||
|
|
@@ -193,6 +198,7 @@ class MockWorker : public WorkerInterface { | |
| TaskID task_id_; | ||
| JobID job_id_; | ||
| ActorID root_detached_actor_id_; | ||
| Process proc_; | ||
| }; | ||
|
|
||
| } // namespace raylet | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All unit tests should be written against an API and not an implementation. See discussion here for more context.
Are all of these EXPECT_CALLs strictly necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test will still pass without those assertions, but without any of them, there will be GMOCK WARNINGs like this:
Do you think we should still remove those assertions and keep those warnings?