Skip to content

[data][actor-only][12/n] Drop actor restarts: release dead actors, key by Ray actor id - #67708

Open
iamjustinhsu wants to merge 4 commits into
iamjustinhsu/ao/11-classic-dashboard-metricsfrom
iamjustinhsu/ao/12-drop-actor-restarts
Open

iamjustinhsu wants to merge 4 commits into
iamjustinhsu/ao/11-classic-dashboard-metricsfrom
iamjustinhsu/ao/12-drop-actor-restarts

Conversation

@iamjustinhsu

Copy link
Copy Markdown
Contributor

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

  • Actor-only actors inherit max_restarts=-1, which forces the pool, ResourceBank and sizer to handle a RESTARTING state, actor relocation, and a "logical actor id".
  • A dead actor that isn't draining stays in the pool and is still counted.
  • This conflicts with Ray Data lineage recovery.

After

  • Actor-only actors get max_restarts=0; a user max_restarts != 0 is rejected. max_task_retries stays -1.
  • Dead actors are released and deregistered. An actor-death task error releases the actor at once.
  • Actors are keyed by Ray actor ID (ActorId).
  • max_consecutive_actor_init_deaths applies, but only to __init__ failures.
  • Removed: the restart and relocation code, and the RAY_DATA_REFRESH_ACTOR_STATE flag.
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:#000
Loading

Subsystems

execution (behavioral change, flag-gated), resource allocation (sizer and ResourceBank bookkeeping), API (rejects max_restarts != 0 under the flag)

Testing

  • RAY_DATA_ACTOR_ONLY_BACKEND=1 pytest python/ray/data/tests/actor_only: 373 passed.
  • pre-commit run on changed files: clean.
  • Whole-stack regression: the same Ray Data suites ran on this branch (the top of the stack) and on unmodified 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.
    • This branch: 1201 passed, 22 failed, 39 errors, 2 skipped. Master: 1201 passed, 22 failed, 39 errors, 1 skipped.
    • The failing and erroring tests are the same 61 on both, so the stack adds no new failures. They come from the local environment (for example, the 39 test_default_cluster_autoscaler_v2.py errors are a ray.init reuse from test ordering, and the file passes 41/41 run alone).

Notes

  • Not a duplicate: no open ray-project/ray PR covers the actor-only backend (checked with gh pr list --repo ray-project/ray --state open --search "actor-only").
  • AI assistance (Claude Code) was used for this change. I have reviewed every changed line.

🤖 Generated with Claude Code

@iamjustinhsu
iamjustinhsu added this pull request to stack #67709 November 2, 2026 21:02
@iamjustinhsu
iamjustinhsu removed this pull request from stack #67709 November 2, 2026 21:05
@iamjustinhsu
iamjustinhsu added this pull request to stack #67710 November 2, 2026 21:05
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/12-drop-actor-restarts branch from f08082f to f3e3887 Compare November 2, 2026 21:10
@iamjustinhsu iamjustinhsu added the go add ONLY when ready to merge, run all tests label Nov 2, 2026
@iamjustinhsu
iamjustinhsu marked this pull request as ready for review November 2, 2026 21:16
@iamjustinhsu
iamjustinhsu requested a review from a team as a code owner November 2, 2026 21:16

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +353 to +362
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

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).

Comment on lines 1124 to 1132
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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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:

  1. 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.
  2. 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.

Suggested change
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

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@ray-gardener ray-gardener Bot added the data Ray Data-related issues label Nov 3, 2026
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/12-drop-actor-restarts branch from f3e3887 to 1ed8c00 Compare November 3, 2026 20:09

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/12-drop-actor-restarts branch from 1ed8c00 to 66b0184 Compare November 3, 2026 23:10

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/12-drop-actor-restarts branch 2 times, most recently from ce80d98 to 80a628c Compare November 6, 2026 00:57

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/12-drop-actor-restarts branch 2 times, most recently from f6192b1 to dec7266 Compare November 6, 2026 20:34
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/12-drop-actor-restarts branch from dec7266 to 8dd3ee7 Compare November 10, 2026 19:01
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/12-drop-actor-restarts branch 2 times, most recently from 90b8dde to a02f244 Compare November 12, 2026 17:04
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/12-drop-actor-restarts branch from a02f244 to c8a541b Compare November 13, 2026 02:38

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/12-drop-actor-restarts branch 2 times, most recently from b0fbd06 to 6485a49 Compare November 17, 2026 23:54
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/12-drop-actor-restarts branch from 6485a49 to 97f3e2a Compare November 19, 2026 00:41
@richardliaw
richardliaw force-pushed the iamjustinhsu/ao/12-drop-actor-restarts branch from 97f3e2a to 23a6ea8 Compare November 19, 2026 19:52
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/12-drop-actor-restarts branch 3 times, most recently from 0f00029 to 3fa9975 Compare November 19, 2026 23:22
iamjustinhsu and others added 2 commits November 19, 2026 15:23
…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]>
@richardliaw
richardliaw force-pushed the iamjustinhsu/ao/12-drop-actor-restarts branch from 3fa9975 to 4d6f727 Compare November 19, 2026 23:23
@ayushk7102
ayushk7102 self-requested a review November 25, 2026 23:00
…ao/12-drop-actor-restarts

Signed-off-by: iamjustinhsu <[email protected]>

@ayushk7102 ayushk7102 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment on lines +793 to +795
assert actor_info.node_id == node_id, (
f"actor {actor_id} registered on {actor_info.node_id} "
f"was seen on {node_id}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants