Repository navigation
[Core] Add job level configuration to enable/disable lineage reconstruction - #65487
Conversation
Signed-off-by: davik <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces the enable_object_reconstruction option to JobConfig, allowing individual jobs to opt out of lineage reconstruction even when it is enabled at the cluster level. The changes span Python configuration, protobuf definitions, and the C++ core worker context and reference counter. The review feedback highlights a potential race condition in WorkerContext::MaybeInitializeJobInfo where the job info could be initialized twice if multiple threads race between the reader and writer locks. Additionally, the reviewer notes that adding the pure virtual method SetLineagePinningEnabled to ReferenceCounterInterface may require updating mock implementations in tests to avoid compilation errors.
Signed-off-by: davik <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces a job-level configuration, enable_object_reconstruction, allowing jobs to opt-in or opt-out of lineage-based object reconstruction, overriding the cluster-level default. This is implemented by propagating the setting from JobConfig (Python and Protobuf) to the C++ WorkerContext and ReferenceCounter, making lineage_pinning_enabled_ dynamic and thread-safe via std::atomic<bool>. Feedback on the changes highlights a performance concern in WorkerContext::MaybeInitializeJobInfo, where acquiring a writer lock on every task execution on the hot path can cause lock contention. A double-checked locking pattern using a reader lock first is suggested to optimize this path.
…onfig test Signed-off-by: davik <[email protected]>
Yicheng-Lu-llll
left a comment
There was a problem hiding this comment.
Approving if we wants job level switch for now. Ideally Ray Data would turn this off for its own tasks at runtime, without users having to set it manually and bind it to the whole job lifecycle.
Two nits:
- ray job submit can't set this yet.
- could be better if tests could cover SetLineagePinningEnabled path for worker owned objects.
Signed-off-by: davik <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 0560a1d. Configure here.
Signed-off-by: davik <[email protected]>
…nly behavior Signed-off-by: davik <[email protected]>
Signed-off-by: davik <[email protected]>
|
a crime!! |
…uction (ray-project#65487) ## Description Lineage reconstruction is currently provided by default as part of ray. The feature provides the capability to automatically track and re-execute any lost progress. However, this comes at the sacrifice of additional overhead per object created and task submissions that are transparent to user level code. The drawbacks can be undesirable if the application layer has other needs for fault tolerance that lineage reconstruction in core is unable to provide. As part of the effort to create [application layer fault tolerance in Ray Data](ray-project/enhancements#74) in order to avoid split brain scheduling caused by lineage reconstruction, this PR introduces a job granularity config that enables users to configure whether they want to enable or disable ray data's application layer reconstruction mechanism. The new behavior affects the cluster as follows: | `_disable_job_level_lineage_reconstruction` | Behavior | |---|---| | **True** | Disables Core's lineage reconstruction, and enables Ray Data's fault tolerance mechanism described in ray-project/enhancements#74. | | **False** | Defers to the cluster-level lineage pinning environment variable for whether Core's lineage reconstruction is enabled, and disables Ray Data's fault tolerance mechanism | Crucially, disabling lineage reconstruction in Core does not prevent ray core from retrying ephemeral system failures that may be safely retried such as network drops or OOM retries. Disabling this category of retries can be configured via other configs within Ray. **Note**: Majority of the new lines in this PR comes from refactoring reference counter interface to use ``` /** * **/ ``` comment format. ## Related issues ## Additional information --------- Signed-off-by: davik <[email protected]> Co-authored-by: davik <[email protected]>
…uction (ray-project#65487) ## Description Lineage reconstruction is currently provided by default as part of ray. The feature provides the capability to automatically track and re-execute any lost progress. However, this comes at the sacrifice of additional overhead per object created and task submissions that are transparent to user level code. The drawbacks can be undesirable if the application layer has other needs for fault tolerance that lineage reconstruction in core is unable to provide. As part of the effort to create [application layer fault tolerance in Ray Data](ray-project/enhancements#74) in order to avoid split brain scheduling caused by lineage reconstruction, this PR introduces a job granularity config that enables users to configure whether they want to enable or disable ray data's application layer reconstruction mechanism. The new behavior affects the cluster as follows: | `_disable_job_level_lineage_reconstruction` | Behavior | |---|---| | **True** | Disables Core's lineage reconstruction, and enables Ray Data's fault tolerance mechanism described in ray-project/enhancements#74. | | **False** | Defers to the cluster-level lineage pinning environment variable for whether Core's lineage reconstruction is enabled, and disables Ray Data's fault tolerance mechanism | Crucially, disabling lineage reconstruction in Core does not prevent ray core from retrying ephemeral system failures that may be safely retried such as network drops or OOM retries. Disabling this category of retries can be configured via other configs within Ray. **Note**: Majority of the new lines in this PR comes from refactoring reference counter interface to use ``` /** * **/ ``` comment format. ## Related issues ## Additional information --------- Signed-off-by: davik <[email protected]> Co-authored-by: davik <[email protected]>
… streaming executor (#66220) ## Description Note: By default the changes introduced in this PR are a no-op in Ray Data. Data lineage reconstruction is enabled only when the job turns off Ray Core lineage reconstruction via the JobConfig (`JobConfig(_disable_job_level_lineage_reconstruction=True)`, #65487) This PR wires the lineage tracker introduced in #65519 and developed to support fan-in and fan-out tasks in #65642, #66136. This is a part of a larger effort to introduce lineage reconstruction as a first class construct in Ray Data for application-level fault tolerance. A more detailed proposal can be found on this Ray Enhancement Proposal (ray-project/enhancements#74) A task serves at most one reconstruction plan here; batching several plans onto one seed re-execution is a follow-up PR. ## Additional Information I've broken down the changes introduced in this PR at a higher level below. ### Concepts This is a representation of block lineage and how it dictates which tasks need to be submitted for reconstruction. <img width="3045" height="1400" alt="lineage_diagram" src="https://github.com/user-attachments/assets/b7164ae8-369e-4b68-87c2-665fe253bcca" /> As seen in the sketch above, lineage for a fan-out pipeline results in certain blocks being pruned as they are not required to reconstruct the lost object(s). Conversely, fan-in pipelines require a number of ancestor blocks to be reconstructed. This has a direct impact on the number of re-submitted tasks with Data lineage reconstruction. At a high level, the sketch below shows that lineage reconstruction and regular Ray Data task execution run in tandem during a pipeline. The main ideas to grasp are the following: - Blocks that are emitted by reconstruction tasks that are NOT part of a lost block's lineage are pruned, or NOT propagated downstream - Blocks produced by reconstruction tasks that are part of a lost block's lineage are withheld in a separate data structure (while accounting for their resource usage). When all reconstruction blocks in a dependency set are ready, they are bundled and added to the operator outqueue for a child reconstruction task to consume <img width="1946" height="1626" alt="fan_in_fan_out_LR" src="https://github.com/user-attachments/assets/9f1ecda1-cb38-48f7-a1f4-08f4e840e9d6" /> #### Building the lineage graph while the dataset executes 1. A `LineageTracker` instance is declared for the DAG's streaming executor 2. An operator that reads directly from an `InputDataBuffer` is a 'seed' operator. Its input is durable and resubmittable (a `ReadTask`/`FileManifest`, or the data itself for `from_*`), so it retains that bundle in a map in case it ever needs to re-submit seed tasks. The tracker stores IDs, never actual `RefBundle`s. 3. **On task submission**:`MapOperator._submit_data_task` registers any task to be submitted with the `LineageTracker`, keeping track of whether it's a fresh task or a reconstruction task, and assigning it a logical Ray Data task ID - A producing task registers each block that is produced with the `LineageTracker`, via `_output_ready_callback`. Specifically, a tuple of (producing task logical ID, output index). A consuming task during submission time (3.) looks up the above dependencies to add edges in the lineage graph 5. **On task completion**: The `LineageTracker` marks the task in the graph as complete. #### Triggering lineage reconstruction when any output block is lost 1. The callback `DataOpTask.on_data_ready` catches an `ObjectLostError`, and triggers data lineage reconstruction 2. The `LineageTracker` traces the lost object's lineage, back to its seed task, and opens a reconstruction plan for it (or folds to an existing plan, if already open) 3. The streaming executor aborts the lost task so its operator releases resources, these will be requested again by the triggered reconstruction tasks 4. The streaming executor also clears the completion state for the DAG (if necessary), and re-submits the seed task. #### Managing reconstructed blocks 1. As each reconstruction task emits blocks, check the reuse status of each block. `NEW` flows downstream as usual, `PRUNED`/`UNRELATED` is dropped these are not required to reconstruct lost objects, and `REUSED` is withheld so that it can be passed along to following reconstruction tasks 2. For a fan-in, the withheld objects must be released together, so that a downstream reconstruction task can accept inputs exactly as in its original attempt (maintaining the same order of blocks) ### Known Limitations in Current Implementation - No batching of seed tasks (if multiple reconstruction plans can be served by a single seed task). This is explicitly addressed in a follow up PR to enable batching of reconstruction plans. - Blocks lost after they're handed to an iterator (`iter_batches`, `iter_rows`, `take`, `take_all`) aren't reconstructed. This is going to be addressed as part of a follow up effort to integrate external consumers (e.g. Ray Train) with Data FT - No support for DAGs with shuffles. Lineage reconstruction for pipelines with `AllToAllOperator` / shuffles in the DAG needs to be scoped. We will work on this in the future. --------- Signed-off-by: Ayush Kumar <[email protected]> Signed-off-by: Ayush Kumar <[email protected]>
…rent stack before py calls (#67132) (#68023) ## Description Cherry-pick of #67132 (master commit 6077a8a) onto `releases/2.59.2`. #64772, which is in 2.59, re-anchors CPython 3.14's stack-protection bounds to the async actor's fiber stack on each task switch, to fix a memory leak. But the re-anchor runs after `task_execution_handler` has already made a Python call on the new fiber. That call can see the stale bounds and raise a spurious `RecursionError`, which crashes the actor worker with `Check failed: objects_valid 1 return objects expected, 1 returned. Object at idx 0 was not stored.` This is #66399 (P1). #67132 re-anchors the boundary to the current stack before any Python call in `task_execution_handler`. ## Related issues Related to #67132 and #66399. The same pick for 2.60.1 is #67996. ## Additional information ### Cherry-pick details Applied cleanly with `git cherry-pick -x`. It has the same 2 files, +287/-106, and the same `git patch-id --stable` as the master commit. No prerequisite commits are missing: - #64772 is on this branch; it merged to master before the 2.59 branch cut. - `_raylet.pyx` differs from master at 6077a8a by #66514, #65243 and #65487, which aren't on this branch. None of them touches `task_execution_handler`, the only function #67132 changes. - `test_asyncio.py` differs from master by tests that #66576 and #65243 add. #67132's two tests go after `test_async_actor_finalizes_objects_dropped_on_fiber`, which this branch has from #64772. Not a duplicate: this branch doesn't contain #67132, and no PR against `releases/2.59.2` references it. ### Testing | Command | Result | |---|---| | `pre-commit run --files python/ray/_raylet.pyx python/ray/tests/test_asyncio.py` | Passed, including cython-lint | I didn't run the tests locally. `_raylet.pyx` needs a full Ray build, which wasn't practical on my machine. Both new tests in `test_asyncio.py` skip below CPython 3.14. Premerge CI on this branch runs the core Python tests on 3.10, and postmerge also on 3.12, so it runs the rest of `test_asyncio.py` against the changed `task_execution_handler`, but not these two tests. AI assistance was used to prepare this cherry-pick. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: davik <[email protected]> Signed-off-by: Sai Miduthuri <[email protected]> Co-authored-by: Kunchen (David) Dai <[email protected]>

Description
Lineage reconstruction is currently provided by default as part of ray. The feature provides the capability to automatically track and re-execute any lost progress. However, this comes at the sacrifice of additional overhead per object created and task submissions that are transparent to user level code. The drawbacks can be undesirable if the application layer has other needs for fault tolerance that lineage reconstruction in core is unable to provide.
As part of the effort to create application layer fault tolerance in Ray Data in order to avoid split brain scheduling caused by lineage reconstruction, this PR introduces a job granularity config that enables users to configure whether they want to enable or disable ray data's application layer reconstruction mechanism.
The new behavior affects the cluster as follows:
_disable_job_level_lineage_reconstructionCrucially, disabling lineage reconstruction in Core does not prevent ray core from retrying ephemeral system failures that may be safely retried such as network drops or OOM retries. Disabling this category of retries can be configured via other configs within Ray.
Note: Majority of the new lines in this PR comes from refactoring reference counter interface to use
comment format.
Related issues
Additional information