Xuanwo opened a new pull request, #8758:
URL: https://github.com/apache/opendal/pull/8758

   # Which issue does this PR close?
   
   No linked issue. This fixes a data-loss bug found while reviewing the 
`hdfs-native` rename path.
   
   # Rationale for this change
   
   `HdfsNativeCore::hdfs_rename` prepared the destination before verifying the 
source. It deleted an existing destination file, or created an empty 
destination file and its parent directories, and only then called HDFS rename. 
When the source did not exist, rename returned `NotFound` after the destination 
had already been destroyed or created.
   
   This produced two data-loss outcomes:
   
   - `missing -> existing`: the existing target file was deleted.
   - `missing -> absent`: a stray zero-byte target file was left behind, 
including missing parent directories.
   
   # What changes are included in this PR?
   
   - Stat the source before touching the destination. A missing source returns 
`NotFound` without modifying the target.
   - Reject a directory source with `IsADirectory`.
   - When the target exists, call HDFS `rename(..., true)` directly and let 
HDFS replace it atomically instead of deleting it first.
   - When the target is absent, create missing parent directories only after 
the source is known to be a file, then perform the rename.
   - Keep the existing `if_not_exists` behavior, including mapping a concurrent 
`AlreadyExists` from the no-replace rename to `ConditionNotMatch`.
   
   # Are there any user-facing changes?
   
   Yes, as a bug fix: `rename` from a nonexistent source now returns `NotFound` 
without deleting an existing target or creating a destination file. Normal 
overwrite and `if_not_exists` semantics are unchanged.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: pi coding agent
   - Model: group/deepseek
   - Effort: max
   - Role: Authored the code change and ran validation, including reproducing 
the bug against the real Docker HDFS fixture before the fix and verifying the 
full `hdfs_native` behavior suite after it.
   


-- 
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]

Reply via email to