Skip to content

[Data] (Data fault tolerance) Rework lineage reconstruction + streaming executor integration tests to prevent flakiness - #68049

Merged
richardliaw merged 7 commits into
ray-project:masterfrom
ayushk7102:fix_lr_tests
Nov 20, 2026
Merged

richardliaw merged 7 commits into
ray-project:masterfrom
ayushk7102:fix_lr_tests

Conversation

@ayushk7102

Copy link
Copy Markdown
Contributor

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.

@ayushk7102
ayushk7102 requested a review from a team as a code owner November 10, 2026 23:24
@ayushk7102 ayushk7102 changed the title [Data] Rework lineage reconstruction tests [Data] (Data fault tolerance) Rework lineage reconstruction tests Nov 10, 2026

@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 refactors the lineage reconstruction tests by separating them into integration tests in test_lineage_reconstruction.py and unit tests in test_lineage_reconstruction_executor.py. The integration tests introduce several end-to-end test pipelines. However, some of these tests use helper functions that mutate the global DataContext without including the restore_data_context fixture, which can lead to state leakage and test flakiness.

@ayushk7102 ayushk7102 changed the title [Data] (Data fault tolerance) Rework lineage reconstruction tests [Data] (Data fault tolerance) Rework lineage reconstruction + streaming executor integration tests Nov 10, 2026
@ayushk7102 ayushk7102 changed the title [Data] (Data fault tolerance) Rework lineage reconstruction + streaming executor integration tests [Data] (Data fault tolerance) Rework lineage reconstruction + streaming executor integration tests to prevent flakiness Nov 10, 2026
@ray-gardener ray-gardener Bot added the data Ray Data-related issues label Nov 11, 2026

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

The change to make tests more deterministic makes sense. I left two clarification questions.

Comment on lines +64 to +65
task.mark_aborted(error)
task.mark_aborted(error)

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.

Maybe a dumb question, why is mark_aborted invoked twice here?

@NightWing1998 NightWing1998 Nov 16, 2026 •

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.

I think its testing even if you call abort twice, it does not repeated and the done callback only has one instance (next line verifies that only a single object exists in the array)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That is right. I've added a comment to explain this along with a second assert to confirm that this comes from the first call to mark aborted

)


def test_flag_off_disables_data_lineage_reconstruction(

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.

We're removing a lot of cases from before. Why don't we need them anymore?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A lot of the cases have been removed because make assertions about private state, which can be brittle. For e.g. we were asserting the number of reconstructions based on the objects found ready in each poll of the streaming executor.

That being said I've removed the brittle assertions and added this test back as well as test_joined_plans_sharing_a_child_release_it_once because these were testing new logic


task.mark_aborted(error)
task.mark_aborted(error)
assert done_calls == [{"error": error, "aborted_for_reconstruction": False}]

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: maybe we can have the dict be returned from a std func or base constant which makes it easy for maintaining both the task done callback on L32 and other instances of comparing this object.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, added a helper which creates this object

@NightWing1998 NightWing1998 added the go add ONLY when ready to merge, run all tests label Nov 19, 2026
@iamjustinhsu
iamjustinhsu enabled auto-merge (squash) November 19, 2026 19:34
@richardliaw

Copy link
Copy Markdown
Contributor

merge conflict @ayushk7102

Signed-off-by: Ayush Kumar <[email protected]>

# Conflicts:
#	python/ray/data/tests/test_lineage_reconstruction.py
@github-actions
github-actions Bot disabled auto-merge November 19, 2026 23:24
@richardliaw
richardliaw merged commit e356ae4 into ray-project:master Nov 20, 2026
6 checks passed
iamjustinhsu added a commit that referenced this pull request Nov 25, 2026
…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]>
iamjustinhsu added a commit that referenced this pull request Nov 25, 2026
…ests into jhsu/generalize-lineage-tracker-for-intermediate-available-inputs

Brings master's #68049 test rework up from 6/n. Re-applies this
branch's test changes on top:
- _lose takes reconstruction_plan_ids and gives its task a no-op cancel
  callback; stamp_seed_reconstruction_task is now
  stamp_reconstruction_task.
- Adds test_failed_child_rerun_re_injects_a_seed_whose_rerun_is_still_streaming
  next to #68049's test_lost_reconstruction_task_is_re_traced_under_its_plan,
  which it extends to a seed re-run that is still streaming.
- In the executor unit tests, _abortable_task takes cancel_callback, the
  mark-aborted test expects one cancel, register_task_failed returns a
  dict, and the LineageReconstructionError assertions match this branch.

#68049's test_lost_reconstruction_task_is_re_traced_under_its_plan now
reports the consumer re-run's loss through _lose: losing a task cancels
it, and the real task's streaming generator is a mock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: iamjustinhsu <[email protected]>
iamjustinhsu added a commit that referenced this pull request Nov 25, 2026
Brings the rest of the stack up to date, including master's #68049 test
rework from 6/n. Conflicts resolve to this branch's side:
- operator_sizer.py, test_operator_sizer.py and tick.py (deleted here):
  this branch replaced the _held_actors_by_op / _grow_to_held bookkeeping
  and the SizingTicker with op_status Held statuses, and already has the
  incoming warmup wait on ops awaiting their first input.
- groupby_benchmark.py: this branch's newer version, whose
  _query_prometheus and benchmark_job_config helpers exist in
  benchmark.py.

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

4 participants