pratham76 commented on PR #59777:
URL: https://github.com/apache/spark/pull/59777#issuecomment-6879307060

   Thanks @HeartSaVioR. To answer your question directly: no, we haven't proven 
that the rename returned success without moving the file. Here's what we have, 
and why I still think the check should be on by default.
   
   **What we observed** (3.5.x on ABFS, speculation off)
   - A batch was recorded in `commits/`, but one partition's `N.delta` was 
missing and `.N.delta.<uuid>.TID<n>.tmp` was left next to it.
   - No task failed and no error was raised. The query kept running on the 
in-memory state.
   - Every restart then failed reading `N.delta`, and the checkpoint could only 
be repaired by hand (we restored the orphaned temp file).
   
   **Why I think it should be the default**
   1. **The failure is silent and can't be recovered from.** `close()` trusts 
the rename as long as it doesn't throw 
([L155-L172](https://github.com/apache/spark/blob/c1cc110301f6f4007c9326cdea623ce79324df13/sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/checkpointing/CheckpointFileManager.scala#L155-L172)).
 If the final file isn't there, the batch commits anyway, and the problem only 
surfaces on a later restart, when the only fix is editing the checkpoint by 
hand. With the check on, that case fails the task before the batch is committed 
and a normal retry handles it.
   2. **Hadoop doesn't promise rename on object stores.** The FS spec says "For 
object stores, even with the same enclosing root, there is no guarantee file or 
directory rename is atomic" ([filesystem.md 
L615](https://github.com/apache/hadoop/blob/rel/release-3.5.0/hadoop-common-project/hadoop-common/src/site/markdown/filesystem/filesystem.md?plain=1#L615)),
 and `FileContext.rename` says "atomicity of rename is dependent on the file 
system implementation" 
([L1006-L1007](https://github.com/apache/hadoop/blob/rel/release-3.5.0/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java#L1006-L1007)).
 So the gap isn't specific to one vendor's contract. It's a guarantee Hadoop 
explicitly doesn't give, which Spark relies on 
([L219-L225](https://github.com/apache/spark/blob/c1cc110301f6f4007c9326cdea623ce79324df13/sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/checkpointing/CheckpointFileManager.scala#L219-L225)).
   3. **The cost is bounded.** It's one `exists()` per checkpoint file, made 
after the write and rename that already happened. Against a checkpoint that 
can't restart, I think the safe default is worth it, and deployments on HDFS or 
a store with a reliable rename can turn it off.
   4. **Users can't find the flag today.** It's `.internal()`, so a docs-only 
change would also need to make it public. Today users only find out about it 
after they've lost a checkpoint.
   
   **What the check doesn't cover**
   There's one path where a committed file can still go missing. State files 
are renamed with `OVERWRITE` 
([L154](https://github.com/apache/spark/blob/c1cc110301f6f4007c9326cdea623ce79324df13/sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/HDFSBackedStateStoreProvider.scala#L154),
 
[L389-L392](https://github.com/apache/spark/blob/c1cc110301f6f4007c9326cdea623ce79324df13/sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/checkpointing/CheckpointFileManager.scala#L389-L392)).
 Outside HDFS, Hadoop implements that as a non-atomic delete followed by a 
rename ([AbstractFileSystem 
L848-L897](https://github.com/apache/hadoop/blob/rel/release-3.5.0/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java#L848-L897)).
 A later attempt of the same task, for example on a decommissioned or lost 
executor, can delete the committed `N.delta` and die before its own rename. The 
check passes for the first attempt, and the second a
 ttempt never reaches it. I'd like to fix this separately under a new JIRA: 
rename without overwrite and treat an existing destination as success. That 
adds no requests. I've reproduced the sequence locally.
   
   If you're still against a global default, would either of these work for you?
   - Make the flag public and document it for object stores in 
`docs/cloud-integration.md`.
   - Enable it by default only for non-HDFS checkpoint locations.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to