Repository navigation
[data][actor-only][13/n] Actor only backend integration with Data FT - #68042
iamjustinhsu wants to merge 3 commits into
Conversation
23e9a6e to
52b4456
Compare
There was a problem hiding this comment.
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.
| for borrower_id, borrower in sorted( | ||
| self._node_to_actor_states.get(state.actor_location, {}).items() | ||
| ): |
There was a problem hiding this comment.
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.
| 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]), | |
| ): |
52b4456 to
c8c355b
Compare
c8c355b to
099de69
Compare
0449d05 to
e928f23
Compare
e928f23 to
3b40139
Compare
3b40139 to
63baad6
Compare
| self._queued_child_input_refs[child_task_id] = { | ||
| ref.hex() # pyrefly: ignore[missing-attribute] | ||
| for ref in inputs.block_refs | ||
| } |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit 63baad6. Configure here.
There was a problem hiding this comment.
Can we fix this? Should be reasonable to clean up the entries when they are submitted, like we do for _batched_plans
63baad6 to
13f29b7
Compare
13f29b7 to
f94a46e
Compare
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]>
f94a46e to
f8bb510
Compare
There was a problem hiding this comment.
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).
❌ 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 |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit f8bb510. Configure here.
…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]>
…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
left a comment
There was a problem hiding this comment.
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 | ||
| } |
There was a problem hiding this comment.
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]] = {} |
There was a problem hiding this comment.
Can we use aliases here?
| 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]>


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
ObjectLostErrorgoes to lineage reconstruction. An actor death (RayActorError) fails the dataset under the actor-only backend.ResourceBankdoesn't charge or count it. An actor whose pull budget is used up only by blocks it is holding back can stall forever.After
RayActorErroron a lineage-tracked task goes to lineage reconstruction, likeObjectLostError, through one sharedrecover_or_count_lost_outputhelper.ActorUnavailableErrordoes not. Deferred metadata-fetch failures take the same path and report the failed task.LineageReconstructionErroraccepts any exception as its cause.ResourceBank. Release, a displaced copy, andclear_internal_output_queueundo the charge.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.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:#000Subsystems
execution (behavioral change: actor-death routing applies to all backends; the rest is flag-gated), resource allocation (
ResourceBankwithheld accounting, escape hatches), observability (dashboard panels)Testing
pre-commit runon changed files: clean (ruff, black, pydoclint, pyrefly). Because this PR touchestest_lineage_reconstruction.py, it also fixes a pyrefly error that was already in that file: an extraisinstance(..., LineageReconstructionError)assert lets pyrefly see.lost_error.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.PYTHONPATHso actor workers can import UDFs defined in the test modules.Notes
gh pr list --repo ray-project/ray --state open --search "actor-only").🤖 Generated with Claude Code