Repository navigation
[Data] 2-phase commit for checkpointing with prefix trie recovery - #61821
Merged
alexeykudinkin merged 2 commits intoMar 19, 2026
Merged
Conversation
…non-filebased datasink checkpointing - Remove metadata storage in checkpoint parquet files; use checkpoint filename = data file basename instead - Replace per-checkpoint metadata-based recovery with prefix trie recovery - Pass data_file_dir and data_file_filesystem through the recovery call chain - Simplify write_pending_checkpoint() signature - Add deterministic FilenameProvider.get_filename_for_task() - Add warning for checkpointing with non-file datasinks (at-least-once semantics) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and well-thought-out simplification of the 2-phase commit recovery logic in Ray Data. By moving to deterministic filenames and a prefix trie for cleanup, the new approach is more robust and easier to maintain. The introduction of a 2-phase commit for file-based datasinks is a key part of this. The code is well-structured, with clear separation of concerns in the planner, writer, and filter components, and the deprecation of older APIs is handled clearly. The extensive test suite, covering various failure and recovery scenarios, provides strong confidence in the correctness of this critical functionality. I have a couple of minor suggestions for improvement.
Signed-off-by: xgui <[email protected]>
owenowenisme
approved these changes
Mar 19, 2026
alexeykudinkin
approved these changes
Mar 19, 2026
ryanaoleary
pushed a commit
to ryanaoleary/ray
that referenced
this pull request
Mar 25, 2026
…y-project#61821) Signed-off-by: ryanaoleary <[email protected]>
Lucas61000
pushed a commit
to Lucas61000/ray
that referenced
this pull request
May 15, 2026
1 of 5 tasks
richardliaw
pushed a commit
that referenced
this pull request
May 28, 2026
…63606) ## Why are these changes needed? `_clean_pending_checkpoints_task` in `checkpoint_filter.py` uses `FileSelector` without `allow_not_found=True` when listing checkpoint files: ```python ckpt_files = checkpoint_filesystem.get_file_info( FileSelector(checkpoint_path_unwrapped, recursive=False) ) ``` On S3, listing a non-existent prefix returns an empty result. On Azure Blob Storage, it raises `FileNotFoundError`. This breaks `CheckpointConfig` on Azure for first-run scenarios where the checkpoint directory does not yet exist. The data file listing in the same function already correctly uses `allow_not_found=True`: ```python data_files = data_file_filesystem.get_file_info( FileSelector(data_file_dir_unwrapped, recursive=True, allow_not_found=True) ) ``` Similarly, the `load_checkpoint` method in `CheckpointManager` also uses `allow_not_found=True` for its own `FileSelector` call. This was introduced in #61821 which was only tested on S3. ## Fix Add `allow_not_found=True` to the `FileSelector` call in `_clean_pending_checkpoints_task`. ## Related issue number N/A ## Checks - [x] I've signed the [Contributor License Agreement](https://docs.google.com/forms/d/e/1FAIpQLSfAMq5v7-hRKRvNaRDhx_WP1W0IKTm7lBvpBlOrLAsNP2MKIQ/viewform). - [ ] I've run `scripts/format.sh` to lint the changes in this PR. - [ ] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ ] I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` (if applicable). - [ ] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ *This PR was authored with Cursor assistance.* Made with [Cursor](https://cursor.com) --------- Signed-off-by: Michael Pryor <[email protected]> Co-authored-by: Cursor <[email protected]>
Rruop
pushed a commit
to Rruop/ray
that referenced
this pull request
May 29, 2026
- Expand Table 1 from 239 to 264 entries (add Dashboard + Core commits) - Rebuild Table 1 in correct branch commit order - Add fork point analysis (d60d131) - Add Revert pair documentation - Add 2.54.x cherry-pick correspondence table - Add Build/compilation risk analysis (Bazel 7, gRPC) - Add PR ray-project#60295, PR ray-project#61821, and Issue ray-project#63544 detailed analysis - Add Table 2: all 344 missing Core/Data/Dashboard commits - Add Table 3: 80 commits not covered by Table 1 Co-Authored-By: Claude Opus 4.5 <[email protected]>
rueian
pushed a commit
to rueian/ray
that referenced
this pull request
Jun 4, 2026
…ay-project#63606) ## Why are these changes needed? `_clean_pending_checkpoints_task` in `checkpoint_filter.py` uses `FileSelector` without `allow_not_found=True` when listing checkpoint files: ```python ckpt_files = checkpoint_filesystem.get_file_info( FileSelector(checkpoint_path_unwrapped, recursive=False) ) ``` On S3, listing a non-existent prefix returns an empty result. On Azure Blob Storage, it raises `FileNotFoundError`. This breaks `CheckpointConfig` on Azure for first-run scenarios where the checkpoint directory does not yet exist. The data file listing in the same function already correctly uses `allow_not_found=True`: ```python data_files = data_file_filesystem.get_file_info( FileSelector(data_file_dir_unwrapped, recursive=True, allow_not_found=True) ) ``` Similarly, the `load_checkpoint` method in `CheckpointManager` also uses `allow_not_found=True` for its own `FileSelector` call. This was introduced in ray-project#61821 which was only tested on S3. ## Fix Add `allow_not_found=True` to the `FileSelector` call in `_clean_pending_checkpoints_task`. ## Related issue number N/A ## Checks - [x] I've signed the [Contributor License Agreement](https://docs.google.com/forms/d/e/1FAIpQLSfAMq5v7-hRKRvNaRDhx_WP1W0IKTm7lBvpBlOrLAsNP2MKIQ/viewform). - [ ] I've run `scripts/format.sh` to lint the changes in this PR. - [ ] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ ] I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` (if applicable). - [ ] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ *This PR was authored with Cursor assistance.* Made with [Cursor](https://cursor.com) --------- Signed-off-by: Michael Pryor <[email protected]> Co-authored-by: Cursor <[email protected]>
limarkdcunha
pushed a commit
to limarkdcunha/ray
that referenced
this pull request
Jun 30, 2026
…ay-project#63606) ## Why are these changes needed? `_clean_pending_checkpoints_task` in `checkpoint_filter.py` uses `FileSelector` without `allow_not_found=True` when listing checkpoint files: ```python ckpt_files = checkpoint_filesystem.get_file_info( FileSelector(checkpoint_path_unwrapped, recursive=False) ) ``` On S3, listing a non-existent prefix returns an empty result. On Azure Blob Storage, it raises `FileNotFoundError`. This breaks `CheckpointConfig` on Azure for first-run scenarios where the checkpoint directory does not yet exist. The data file listing in the same function already correctly uses `allow_not_found=True`: ```python data_files = data_file_filesystem.get_file_info( FileSelector(data_file_dir_unwrapped, recursive=True, allow_not_found=True) ) ``` Similarly, the `load_checkpoint` method in `CheckpointManager` also uses `allow_not_found=True` for its own `FileSelector` call. This was introduced in ray-project#61821 which was only tested on S3. ## Fix Add `allow_not_found=True` to the `FileSelector` call in `_clean_pending_checkpoints_task`. ## Related issue number N/A ## Checks - [x] I've signed the [Contributor License Agreement](https://docs.google.com/forms/d/e/1FAIpQLSfAMq5v7-hRKRvNaRDhx_WP1W0IKTm7lBvpBlOrLAsNP2MKIQ/viewform). - [ ] I've run `scripts/format.sh` to lint the changes in this PR. - [ ] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ ] I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` (if applicable). - [ ] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ *This PR was authored with Cursor assistance.* Made with [Cursor](https://cursor.com) --------- Signed-off-by: Michael Pryor <[email protected]> Co-authored-by: Cursor <[email protected]>
400Ping
pushed a commit
to 400Ping/ray
that referenced
this pull request
Aug 18, 2026
…ay-project#63606) ## Why are these changes needed? `_clean_pending_checkpoints_task` in `checkpoint_filter.py` uses `FileSelector` without `allow_not_found=True` when listing checkpoint files: ```python ckpt_files = checkpoint_filesystem.get_file_info( FileSelector(checkpoint_path_unwrapped, recursive=False) ) ``` On S3, listing a non-existent prefix returns an empty result. On Azure Blob Storage, it raises `FileNotFoundError`. This breaks `CheckpointConfig` on Azure for first-run scenarios where the checkpoint directory does not yet exist. The data file listing in the same function already correctly uses `allow_not_found=True`: ```python data_files = data_file_filesystem.get_file_info( FileSelector(data_file_dir_unwrapped, recursive=True, allow_not_found=True) ) ``` Similarly, the `load_checkpoint` method in `CheckpointManager` also uses `allow_not_found=True` for its own `FileSelector` call. This was introduced in ray-project#61821 which was only tested on S3. ## Fix Add `allow_not_found=True` to the `FileSelector` call in `_clean_pending_checkpoints_task`. ## Related issue number N/A ## Checks - [x] I've signed the [Contributor License Agreement](https://docs.google.com/forms/d/e/1FAIpQLSfAMq5v7-hRKRvNaRDhx_WP1W0IKTm7lBvpBlOrLAsNP2MKIQ/viewform). - [ ] I've run `scripts/format.sh` to lint the changes in this PR. - [ ] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ ] I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` (if applicable). - [ ] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ *This PR was authored with Cursor assistance.* Made with [Cursor](https://cursor.com) --------- Signed-off-by: Michael Pryor <[email protected]> Co-authored-by: Cursor <[email protected]> Signed-off-by: 400Ping <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
This PR introduces 2-phase commit (2PC) for Ray Data checkpointing and then simplifies the recovery algorithm using a prefix trie. Together these changes eliminate duplicate data files on failure recovery and provide exactly-once write semantics for file-based datasinks.
Part 1: 2-phase commit for checkpointing to avoid duplicates
Previously, checkpoints were written after data files. If a task failed between writing data and writing the checkpoint, recovery would re-write the same data — producing duplicates. 2PC fixes this:
.pending.parquet) containing the expected data file prefix.pending.parquet→.parquet)On recovery, pending checkpoints identify uncommitted data files that should be deleted before retrying.
For non-file datasinks (SQL, MongoDB, etc.), falls back to post-write checkpointing with at-least-once semantics (with warning).
Part 2: Simplify recovery with prefix trie
Removes metadata storage in checkpoint parquet files (
DATA_FILE_DIR_METADATA_KEY,DATA_FILE_PREFIX_METADATA_KEY) and replaces per-checkpoint metadata-based recovery with a simpler algorithm:PrefixTriefrom their basenames (strip.pending.parquet)Other changes
data_file_dir/data_file_filesystemthroughPlanner → LoadCheckpointCallback → BatchBasedCheckpointFilterso recovery can locate data files without reading checkpoint metadataFilenameProvider.get_filename_for_task()so checkpoint ID matches data file prefix. Deprecateget_filename_for_block()andget_filename_for_row()write_pending_checkpoint()signature: takes only(id_column_data, checkpoint_id)instead of also requiringdata_file_diranddata_file_prefixRowBasedFileDatasink) derive per-row filenames from the task filename via_split_base_and_ext, ensuring all files from one task share a common prefix for recoveryWhy write checkpoint before data?
pq.write_tableis not atomic — if the process is killed mid-write, the file may exist on disk but be corrupted. Writing the pending checkpoint first and renaming it after the data write succeeds ensures we can always detect and clean up incomplete writes.Test plan
test_filename_provider.pyfor newget_filename_for_task()APIRowBasedFileDatasink🤖 Generated with Claude Code