Repository navigation
[data][actor-only][12/n] Drop actor restarts: release dead actors, key by Ray actor id - #67708
iamjustinhsu wants to merge 4 commits into
Conversation
f08082f to
f3e3887
Compare
There was a problem hiding this comment.
Code Review
This pull request simplifies actor lifecycle management in the actor-only backend of Ray Data by disabling Ray Core actor restarts and removing actor relocation logic. Dead actors are now immediately released and replaced by the sizer, with their work redone via lineage recovery. Additionally, current_size is renamed to total_size to accurately represent the inclusion of draining actors, and logical actor IDs are replaced with standard Ray actor IDs. Feedback on these changes highlights a risk of infinite retry loops for persistent non-UDF startup failures (such as runtime_env errors) due to the selective charging of the init death budget. It is also recommended to sync draining priorities after refreshing the state to ensure the output queue's priorities are current and to prevent delayed prioritization.
| def _on_actor_init_death(self, error: Exception) -> None: | ||
| """Charge ``max_consecutive_actor_init_deaths`` only for deaths where | ||
| the actor's ``__init__`` raised: a broken UDF fails every replacement, | ||
| so it must exhaust the budget and fail the dataset. A process or node | ||
| loss while starting (OOM, preemption, chaos) is not the UDF's fault; | ||
| the pool already dropped the pending actor and the sizer re-places it. | ||
| """ | ||
| if isinstance(error, RayActorError) and error.actor_init_failed: | ||
| super()._on_actor_init_death(error) | ||
| return |
There was a problem hiding this comment.
Overriding _on_actor_init_death to only charge max_consecutive_actor_init_deaths when error.actor_init_failed is True introduces a risk of infinite retry loops for persistent, non-UDF startup failures.
For example, if a runtime_env has a bad dependency or typo, the actor creation will persistently fail during environment setup (before __init__ runs), resulting in actor_init_failed being False. Since these failures won't be charged against the budget, the sizer will continuously attempt to replace the actor indefinitely, hanging the job.
Consider charging the budget or having a separate threshold/mechanism to detect and fail on persistent non-UDF startup failures (such as runtime_env setup errors).
| def refresh_state(self): | ||
| """Updates internal state""" | ||
| """Updates internal state. The pool refresh releases dead actors and | ||
| tears down fully-drained ones; priorities are synced first so the | ||
| draining set it reads is current.""" | ||
| info = self.get_actor_info() | ||
| if info.pending > 0: | ||
| self.actor_pool.reset_output_limit() | ||
| self._sync_draining_priorities() | ||
| return super().refresh_state() |
There was a problem hiding this comment.
Calling _sync_draining_priorities() before super().refresh_state() means that the output queue's priorities are synced with the draining set before the pool refresh runs.
This introduces two issues:
- Delayed prioritization for newly draining actors: During
super().refresh_state(), the pool refresh might identify newly draining actors (e.g., due to node preemption in_drain_actors_on_draining_nodes()). Because the priorities were already synced, these newly draining actors won't have their blocks prioritized in the output queue until the next scheduling step. - Stale priorities for finalized actors: Any draining actors that are fully drained and torn down during
super().refresh_state()will remain in the prioritized set of the queue until the next step, rather than being cleaned up immediately.
Calling _sync_draining_priorities() after super().refresh_state() ensures that the output queue's priorities are perfectly in sync with the actual draining actors at the end of the state refresh.
| def refresh_state(self): | |
| """Updates internal state""" | |
| """Updates internal state. The pool refresh releases dead actors and | |
| tears down fully-drained ones; priorities are synced first so the | |
| draining set it reads is current.""" | |
| info = self.get_actor_info() | |
| if info.pending > 0: | |
| self.actor_pool.reset_output_limit() | |
| self._sync_draining_priorities() | |
| return super().refresh_state() | |
| def refresh_state(self): | |
| """Updates internal state. The pool refresh releases dead actors and | |
| tears down fully-drained ones, then priorities are synced so the | |
| draining set is current.""" | |
| info = self.get_actor_info() | |
| if info.pending > 0: | |
| self.actor_pool.reset_output_limit() | |
| ret = super().refresh_state() | |
| self._sync_draining_priorities() | |
| return ret |
f3e3887 to
1ed8c00
Compare
1ed8c00 to
66b0184
Compare
ce80d98 to
80a628c
Compare
f6192b1 to
dec7266
Compare
dec7266 to
8dd3ee7
Compare
90b8dde to
a02f244
Compare
a02f244 to
c8a541b
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c8a541b. Configure here.
b0fbd06 to
6485a49
Compare
6485a49 to
97f3e2a
Compare
97f3e2a to
23a6ea8
Compare
0f00029 to
3fa9975
Compare
…y by Ray actor id The actor-only backend relied on Ray core to restart dead actors (`max_restarts=-1`, inherited from the task-backend operator). That forced a RESTARTING state, actor relocation, and a uuid "logical actor id" through the actor pool, the ResourceBank and the sizer. It also conflicts with Ray Data lineage recovery: core restarts actors that Data should replace, and a restarted actor's outputs can't be rebuilt by Data. New model: **a dead actor is gone.** The pool releases it, the sizer places a replacement, and (in 13/n) Data lineage recovery redoes the lost work. - **No core restarts.** Actor-only actors get `max_restarts=0`. A user `max_restarts != 0`, from `ray_remote_args` or a `ray_remote_args_fn`, is rejected as unsupported. `max_task_retries` stays `-1` unless the user sets it, so `retry_exceptions` / `actor_task_retry_on_errors` still retry on a live actor. - **Restart and relocation code removed:** the RESTARTING handling in the pool, `_relocate_actor`, the bank's relocation path (`evict_actor` / `adopt_actor` / `_release_refs_on_node` and the migration branch of `on_maybe_register_actor`), the `core_restart` drain-cancel cause, and the `RAY_DATA_REFRESH_ACTOR_STATE` flag. `maybe_register_actor(node_id=...)` now asserts an actor never changes node. - **Dead actors are released.** Before, a dead actor that wasn't draining stayed in the pool and the sizer kept counting it. Now any dead actor is released and deregistered from the bank. A task failing with an actor-death error releases the actor at once; `ActorUnavailableError` does not. - **Ray actor id replaces the logical id.** Actors never restart, so the actor-only backend keys actors by their Ray actor id (hex), typed as a new `ActorId`. The worker reports the same id. The task backend keeps `LogicalActorId`. - **`max_consecutive_actor_init_deaths` now applies here,** but only to deaths where the actor's `__init__` raised (`actor_init_failed`), i.e. a broken UDF. A process or node lost while starting is not charged; the sizer re-places the actor. Before, the scheduling loop swallowed the budget error. - **Draining:** `process_draining_actors` runs inside `refresh_actor_state`, and the output-queue priority sync runs first in `refresh_state`. - **Placement:** actors are placed with hard node affinity (`soft=False`). If the node goes away first, the pending-actor expiry frees the claim. - **Rename:** `current_size` → `total_size`. Known gap until 13/n: with core restarts off and Data lineage recovery not yet wired in, an actor death fails the dataset. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: iamjustinhsu <[email protected]> Co-authored-by: sampan <[email protected]> Co-authored-by: Prasad Palkar <[email protected]>
Signed-off-by: iamjustinhsu <[email protected]>
3fa9975 to
4d6f727
Compare
…ao/12-drop-actor-restarts Signed-off-by: iamjustinhsu <[email protected]>
| assert actor_info.node_id == node_id, ( | ||
| f"actor {actor_id} registered on {actor_info.node_id} " | ||
| f"was seen on {node_id}" |
There was a problem hiding this comment.
nit: An actor reported on a different node now causes the executor to fail hard, due to this assert on the scheduling path. Just making sure this is intended?
…ao/12-drop-actor-restarts Signed-off-by: iamjustinhsu <[email protected]>

Summary
Stop relying on Ray core to restart actor-only actors. A dead actor is released, and the sizer places a replacement. Actors are now keyed by Ray actor ID instead of a logical UUID.
Part 12 of 12 of the Ray Data actor-only backend stack. Stacked on #67707; review only the top commit. Everything here is gated behind
RAY_DATA_ACTOR_ONLY_BACKEND(off by default) unless noted under After.Before
max_restarts=-1, which forces the pool,ResourceBankand sizer to handle a RESTARTING state, actor relocation, and a "logical actor id".After
max_restarts=0; a usermax_restarts != 0is rejected.max_task_retriesstays-1.ActorId).max_consecutive_actor_init_deathsapplies, but only to__init__failures.RAY_DATA_REFRESH_ACTOR_STATEflag.flowchart TD subgraph Before subgraph BS[Subsystem: execution] subgraph BC[Component: experimental actor pool] B1[actor dies] --> B2["core restart (max_restarts=-1)"] --> B3[RESTARTING / relocate / logical id] end end end subgraph After subgraph AS[Subsystem: execution] subgraph AC[Component: experimental actor pool] A1[actor dies] --> A2[release + deregister from ResourceBank] --> A3[sizer places replacement] end end end class B2,B3 removed class A2,A3 added classDef removed fill:#ffcdd2,stroke:#c62828,color:#000 classDef added fill:#c8e6c9,stroke:#2e7d32,color:#000 classDef changed fill:#fff9c4,stroke:#f9a825,color:#000Subsystems
execution (behavioral change, flag-gated), resource allocation (sizer and
ResourceBankbookkeeping), API (rejectsmax_restarts != 0under the flag)Testing
RAY_DATA_ACTOR_ONLY_BACKEND=1 pytest python/ray/data/tests/actor_only: 373 passed.pre-commit runon changed files: clean.master, in the same environment and order:test_streaming_executor.py test_stats.py test_operator_fusion.py test_map.py test_map_operator.py test_actor_pool_map_operator.py test_actor_autoscaler.py test_resource_manager.py test_split.py test_lineage_reconstruction.py test_rate_based_cluster_autoscaler.py test_default_cluster_autoscaler_v2.py unit/datasource_v2/test_list_files_op.py.test_default_cluster_autoscaler_v2.pyerrors are aray.initreuse from test ordering, and the file passes 41/41 run alone).Notes
gh pr list --repo ray-project/ray --state open --search "actor-only").🤖 Generated with Claude Code