[SPARK-58750][CORE] Tolerate FileAlreadyExistsException from checkpoint part file rename - #57976
Open
james-willis wants to merge 1 commit into
Open
[SPARK-58750][CORE] Tolerate FileAlreadyExistsException from checkpoint part file rename#57976james-willis wants to merge 1 commit into
james-willis wants to merge 1 commit into
Conversation
…nt part file rename
james-willis
marked this pull request as ready for review
August 12, 2026 20:09
james-willis
marked this pull request as draft
August 12, 2026 20:30
james-willis
marked this pull request as ready for review
August 12, 2026 22:58
Contributor
Author
|
maybe @viirya or @dongjoon-hyun would be good reviewers on this. |
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.
What changes were proposed in this pull request?
ReliableCheckpointRDD.writePartitionToCheckpointFilerenames the attempt-temp file onto the final part file and only handles a rename that reports failure by returningfalse(HDFS semantics). This PR additionally catchesFileAlreadyExistsExceptionfrom that rename and routes it into the same existing handling: if the final part file exists, another attempt of this task already committed it, so the temp file is deleted and the write is treated as successful. If the destination does not exist, the existingcheckpointFailedToSaveErroris still thrown.Why are the changes needed?
Since HADOOP-16721 (Hadoop 3.3.1), S3A deliberately raises
FileAlreadyExistsExceptionwhen the rename destination is an existing file, instead of returningfalseas HDFS does. ABFS behaves the same way. The Hadoop FileSystem specification does not guarantee HDFS-stylefalsereporting.Under speculative execution (or a zombie attempt racing a retry), two attempts of the same checkpoint task race to rename onto the same final part file. On HDFS the loser sees
rename() == falseand Spark correctly treats it as "some other copy of this task must've finished before us". On S3A/ABFS the loser gets an unhandledFileAlreadyExistsException, which fails the task — and because the destination now permanently exists, every retry of that task fails on the same rename, sospark.task.maxFailuresis always exhausted and the job aborts, even though the checkpoint data was written successfully by the winning attempt.Observed in production (Spark 4.0.1, Hadoop 3.4.1,
spark.speculation=true):See SPARK-58750 for full details. Structured Streaming's
CheckpointFileManagerwas already hardened for divergent rename semantics; the RDD checkpoint writer is the remaining caller assuming HDFS semantics.Does this PR introduce any user-facing change?
No. RDD checkpointing to S3A/ABFS under speculative execution (or task retry after a committed rename) now succeeds instead of unrecoverably failing the job, which is the bug fix itself.
How was this patch tested?
Added a regression test to
CheckpointStorageSuitethat writes the same checkpoint partition from two task attempts against aFileSystemmimicking S3A's rename semantics (raisesFileAlreadyExistsExceptionwhen the destination file exists). Without the fix, the second attempt throws and would fail the task; with the fix, it succeeds and exactly one committed part file remains, with the attempt-temp file cleaned up.Ran
build/sbt "core/testOnly org.apache.spark.CheckpointStorageSuite"locally.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (model claude-fable-5)