Skip to content

[data][actor-only][13/n] Actor only backend integration with Data FT - #68042

Open
iamjustinhsu wants to merge 3 commits into
iamjustinhsu/ao/12-drop-actor-restartsfrom
iamjustinhsu/ao/13-ft-integration
Open

iamjustinhsu wants to merge 3 commits into
iamjustinhsu/ao/12-drop-actor-restartsfrom
iamjustinhsu/ao/13-ft-integration

Conversation

@iamjustinhsu

Copy link
Copy Markdown
Contributor

Summary

Recover the actor-only backend's lost work through Ray Data lineage reconstruction (#66220). Since 12/n a dead actor isn't restarted, so its lost work, and blocks lost with a node, are rebuilt by Data instead.

Part 13 of 14 of the Ray Data actor-only backend stack. Stacked on #67708; review only the top commit. Everything here is gated behind RAY_DATA_ACTOR_ONLY_BACKEND (off by default) unless noted under After.

Before

  • On a lineage-tracked task, only ObjectLostError goes to lineage reconstruction. An actor death (RayActorError) fails the dataset under the actor-only backend.
  • Deferred metadata-fetch failures report the operator name, not the failed task.
  • A block re-made during reconstruction is held back until its child's whole input set is back, but the ResourceBank doesn't charge or count it. An actor whose pull budget is used up only by blocks it is holding back can stall forever.

After

  • On every backend: RayActorError on a lineage-tracked task goes to lineage reconstruction, like ObjectLostError, through one shared recover_or_count_lost_output helper. ActorUnavailableError does not. Deferred metadata-fetch failures take the same path and report the failed task. LineageReconstructionError accepts any exception as its cause.
  • The actor-only backend refuses to start when the job has Data lineage reconstruction off, because nothing else can recover a node loss. Plans that reconstruction can't handle (split, union, mix, limit) still run, with reconstruction off for that dataset.
  • Held-back blocks are charged to the producing actor and counted as withheld in the ResourceBank. Release, a displaced copy, and clear_internal_output_queue undo the charge.
  • New escape hatch, relieve_withheld_wedges, runs before the output-limit walk. It gives a wedged actor room for what it holds plus one block: first free object store on its node, then unused budget lent by actors on the same node, and it oversubscribes only when those can't cover it once their outputs drain. Grants are returned when the outputs are released or the actor dies.
  • The existing output-limit escape hatch uses the same reservation and borrowing.
  • New dashboard panels for escape-hatch grants, withheld outputs, and actors stalled on withheld outputs.
flowchart TD
    subgraph Before
        subgraph BS[Subsystem: execution]
            subgraph BC[Component: streaming executor task errors]
                B1[ObjectLostError] --> B2[lineage reconstruction]
                B3[RayActorError] --> B4[dataset fails]
            end
        end
    end
    subgraph After
        subgraph AS[Subsystem: execution]
            subgraph AC[Component: streaming executor task errors]
                A1[ObjectLostError] --> A5[recover_or_count_lost_output] --> A2[lineage reconstruction]
                A3[RayActorError] --> A5
            end
        end
        subgraph AR[Subsystem: resource allocation]
            subgraph ARC[Component: ResourceBank + escape hatches]
                A6[withheld blocks charged to producing actor] --> A7[relieve_withheld_wedges]
            end
        end
        A2 --> A6
    end
    class B4 removed
    class A5,A6,A7 added
    class A3 changed
    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: actor-death routing applies to all backends; the rest is flag-gated), resource allocation (ResourceBank withheld accounting, escape hatches), observability (dashboard panels)

Testing

  • pre-commit run on changed files: clean (ruff, black, pydoclint, pyrefly). Because this PR touches test_lineage_reconstruction.py, it also fixes a pyrefly error that was already in that file: an extra isinstance(..., LineageReconstructionError) assert lets pyrefly see .lost_error.
  • Each test file this PR changes or adds, run on its own (as CI runs them) at this branch:
    • actor_only/test_actor_only_lineage_recovery.py (new): 4 passed. Covers a lost output being rebuilt and a dead actor's work being redone, both with every row exactly once, refusal to start with reconstruction off, and a limit plan running without reconstruction.
    • actor_only/test_withheld_deadlock.py (new): 12 passed.
    • actor_only/test_experimental_actor_pool.py: 75 passed, 22 subtests passed.
    • actor_only/test_experimental_actor_pool_integration.py: 14 passed.
    • actor_only/test_actor_only_e2e.py: 7 passed.
    • actor_only/test_resource_bank.py: 36 passed. test_output_limit_escape_hatch.py: 11 passed. test_node_aware_experimental_actor_pool.py: 6 passed. test_actor_only_metrics.py: 5 passed.
    • test_lineage_reconstruction.py: 32 passed.
    • test_streaming_executor.py: 57 passed.
  • The actor-only tests need the test directory on PYTHONPATH so actor workers can import UDFs defined in the test modules.

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 force-pushed the iamjustinhsu/ao/13-ft-integration branch from 23e9a6e to 52b4456 Compare November 10, 2026 19:01
@iamjustinhsu
iamjustinhsu marked this pull request as ready for review November 10, 2026 19:24
@iamjustinhsu
iamjustinhsu requested a review from a team as a code owner November 10, 2026 19:24

@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 implements lineage reconstruction support for the actor-only backend in Ray Data, introducing a deadlock detection mechanism for withheld reconstruction outputs and updating the actor pool to dynamically grant and manage output headroom. It also adds corresponding metrics, dashboard panels, and comprehensive tests. A critical issue was identified in actor_pool.py where sorting _node_to_actor_states items directly will cause a runtime TypeError because ActorID objects are not comparable; a key function should be used to sort by string representation instead.

Comment on lines +1719 to +1721
for borrower_id, borrower in sorted(
self._node_to_actor_states.get(state.actor_location, {}).items()
):

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

Sorting self._node_to_actor_states.get(...).items() directly will raise a TypeError at runtime because ActorID objects in Ray are not directly comparable (they do not implement comparison operators like <). To prevent this runtime crash, specify a key function in sorted() that converts the ActorID to a string (or another comparable representation) for sorting.

Suggested change
for borrower_id, borrower in sorted(
self._node_to_actor_states.get(state.actor_location, {}).items()
):
for borrower_id, borrower in sorted(
self._node_to_actor_states.get(state.actor_location, {}).items(),
key=lambda item: str(item[0]),
):

@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/13-ft-integration branch from 52b4456 to c8c355b Compare November 10, 2026 21: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.

@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/13-ft-integration branch 3 times, most recently from 0449d05 to e928f23 Compare November 13, 2026 22:36

@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/13-ft-integration branch from e928f23 to 3b40139 Compare November 17, 2026 23:54

@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/13-ft-integration branch from 3b40139 to 63baad6 Compare November 19, 2026 00:41

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

self._queued_child_input_refs[child_task_id] = {
ref.hex() # pyrefly: ignore[missing-attribute]
for ref in inputs.block_refs
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Orphaned _queued_child_input_refs entries never cleaned on submission

Low Severity

_queued_child_input_refs[child_task_id] is populated when a reconstruction bundle is queued but never cleaned when the child task is submitted (unlike _batched_plans, which is popped in _lineage_for_submission). Entries accumulate for the operator's entire lifetime, cleaned only by clear_internal_output_queue. Under repeated reconstructions, the dict grows unboundedly with stale ref-hex sets.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 63baad6. Configure here.

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.

Can we fix this? Should be reasonable to clean up the entries when they are submitted, like we do for _batched_plans

@richardliaw
richardliaw requested review from a team as code owners November 19, 2026 19:52
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/13-ft-integration branch from 63baad6 to 13f29b7 Compare November 19, 2026 20:55
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/13-ft-integration branch from 13f29b7 to f94a46e Compare November 19, 2026 23:22
12/n stopped Ray Core from restarting actor-only actors. A dead
actor is released and the sizer replaces it, so its lost work, and any
blocks lost with a node, have to be rebuilt by Ray Data lineage
reconstruction (#66220). This PR wires that into the
actor-only backend.

**Recovery routing**
- On a lineage-tracked task, `RayActorError` (the actor died) now goes
to lineage reconstruction, like `ObjectLostError`. That applies in both
the default executor loop and the actor-only loop, through one shared
`recover_or_count_lost_output` helper. `ActorUnavailableError` does not.
- Deferred metadata-fetch failures go through the same routing. The
fetcher now reports the failed task instead of its operator name.
- The actor-only backend refuses to start when the job has Data
reconstruction off
(`JobConfig(_disable_job_level_lineage_reconstruction=True)` not set),
because nothing else can recover a node loss. Plans #66220 can't
reconstruct (split, union, mix, limit) still run, with reconstruction
off for that dataset.

**ResourceBank accounting**
- During reconstruction, a re-made block is withheld until its child's
whole input set is back. Withheld blocks are now charged to the
producing actor, and also counted as withheld, so they can be told apart
from output a consumer can drain. Release, a displaced copy, and
`clear_internal_output_queue` each undo the charge.
- A released input set goes into the output queue under the producing
actor's key (`_output_add_kwargs`), not the task index.

**Escape hatch for withheld-block wedges**
- An actor is wedged when its pull budget is exhausted only because of
blocks it is withholding. Nothing downstream can drain those blocks
until the set is complete, so it would stall forever.
- `relieve_withheld_wedges` runs before the existing output-limit walk.
It gives a wedged actor room for what it withholds plus one block:
1. free object store on its node, reserved in the bank so no other grant
counts it again;
2. then unused budget lent by other actors on the same node, whose caps
go down by the same amount;
3. if that's not enough, it waits while those actors' full budgets would
cover the rest once their outputs are consumed, and only oversubscribes
beyond that.
- Grants are kept on the actor and given back once its withheld outputs
are released, or when it dies (lenders get their budget back).
- The existing output-limit hatch now uses the same reservation and
borrowing. It still grants its one-block bump immediately when there's
no room.

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]>
@richardliaw
richardliaw force-pushed the iamjustinhsu/ao/13-ft-integration branch from f94a46e to f8bb510 Compare November 19, 2026 23:23

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

There are 2 total unresolved issues (including 1 from previous review).

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 f8bb510. Configure here.

for lender in lenders:
loan = granted_bytes_by_lender.get(lender.actor_id, 0)
lender.max_num_output_bytes -= loan
lender.lent_bytes += loan

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Lending unused budget can create deadlock

High Severity

grant_output_headroom treats any peer with unused output budget as a lender, including actors whose remaining occupancy is withheld reconstruction output. After the loan, that peer's cap equals withheld plus prebuffered, so _is_stuck_on_withheld becomes true and the actor can no longer emit the rest of the child's input set. stuck_peer_ids only affects the after-drain estimate, not who lends now, so the hatch can stall the producers a plan still needs.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f8bb510. Configure here.

richardliaw pushed a commit that referenced this pull request Nov 20, 2026
…ng executor integration tests to prevent flakiness (#68049)

## Description
This PR rewrites all of the integration tests for lineage reconstruction
as well as some unit tests, to fix flakiness in the test suite.

### Why
`test_lineage_reconstruction` was flaky in CI. This is because several
tests simulated a lost block with a `lose_output` fixture that
monkeypatched `DataOpTask.on_data_ready` to raise `ObjectLostError` on
the Nth time the executor polled a given task. The problem is that the
number of polls it takes to drain a task is non-deterministic. It
depends on whether metadata is fetched on a background thread or inline,
and on how fast tasks are submitted and finish. the task drained before
the Nth poll, so the loss never fired and an assertion based on the
number of reconstructions failed.

### Integration test changes
Rather than relying on executor poll timing/task completion time, we now
encode a failure into the data itself (i.e. a particular row will tell
the UDF to mock a lost block). A `map_batches` UDF raises
`ObjectLostError` when it sees a specific row, and the executor handles
that exactly like a block lost with its node. The end-to-end tests then
check that the loss actually happened, and every row comes back exactly
once. They cover linear, fan-in, fan-out, multi-operator, actor pool and
write pipelines, plus a block that's lost a second time while it's being
reconstructed.

### Unit test changes
I reworked all of the old lineage reconstruction unit tests that are
specific to the integration with the streaming executor. The purely unit
tests that don't need a Ray cluster moved to
`tests/unit/test_lineage_reconstruction_executor.py`.

No production code changes.

## Related issues
Related to #66220 and #66990.

## Additional information
I checked open PRs and nothing else rewrites these tests. #67366, #67885
and #68042 add tests to the same file, so whichever of us lands second
will need to rebase.

Testing: I ran the unit tests 30 times and the integration tests 6 times
(3 with the threaded metadata fetcher, 3 with the inline one).
Everything passed every time.

---------

Signed-off-by: Ayush Kumar <[email protected]>
@iamjustinhsu
iamjustinhsu removed request for a team November 20, 2026 18:43
@ayushk7102
ayushk7102 self-requested a review November 25, 2026 18:29
…ft-integration

Brings in master's #68049 (via 6/n), which reworked the lineage
reconstruction tests and moved the executor-side ones into
tests/unit/test_lineage_reconstruction_executor.py. Re-applies 13/n's
test changes on top:
- test_shared_child_is_batched_until_it_is_submitted keeps its
  dropped/released assertions, on #68049's always-queued version.
- The executor unit tests call the public fire_done_callbacks, and
  gain _route_lost_fetches with its two tests and the stricter
  LineageReconstructionError assertion.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

Changes look good, except for one bot comment and one nit

self._queued_child_input_refs[child_task_id] = {
ref.hex() # pyrefly: ignore[missing-attribute]
for ref in inputs.block_refs
}

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.

Can we fix this? Should be reasonable to clean up the entries when they are submitted, like we do for _batched_plans

# share a parent re-run withhold the same ref, so when a later plan
# joins the queued task, its popped refs can already be in that queued
# input: they are still needed, not dropped.
self._queued_child_input_refs: Dict[LineageTaskId, Set[str]] = {}

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.

Can we use aliases here?

Suggested change
self._queued_child_input_refs: Dict[LineageTaskId, Set[str]] = {}
self._queued_child_input_refs: Dict[LineageTaskId, Set[BlockId]] = {}

…ft-integration

Brings master's #68400 (re-run reconstruction tasks under their original
task index) up from 6/n. Both sides kept:
- MapOperator: this branch's _on_output_withheld hook and master's
  _context_task_idx.
- ExperimentalActorPoolMapOperator._create_task_context: master's inputs
  parameter, which the body passes to _context_task_idx, and this
  branch's docstring summary.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants