Mola-maker opened a new issue, #9052:
URL: https://github.com/apache/opendal/issues/9052
### OpenDAL version or commit
main (57f8b75)
### Affected service or component
services/fs on Windows, with `atomic_write_dir` and `if_not_exists` writes
(`publish_staged_file` in `core/services/fs/src/core.rs`)
### Describe the bug
With `atomic_write_dir`, an `if_not_exists` write publishes the staged file
with `std::fs::hard_link` on non-Linux systems. Suppose the destination's
parent directory is replaced by a regular file before `close()`. Windows then
fails `hard_link` with `ERROR_INVALID_PARAMETER` (os error 87), which becomes a
**temporary** `Unexpected` error. Two things follow:
- `RetryLayer` retries `close()`, which can never succeed.
- The writer keeps the staged file on temporary errors, so it is never
removed from `atomic_write_dir`.
Linux (`rename_noreplace` → ENOTDIR) and macOS (`hard_link` → ENOTDIR) both
report a permanent `NotADirectory` and clean up the staged file. The
unconditional path on Windows also cleans up.
### Steps to Reproduce
Windows 11, main 57f8b75:
```rust
let op = Operator::new(Fs::default().root(root).atomic_write_dir(staging))?;
let mut w = op.writer_with("sub/f").if_not_exists(true).await?;
w.write("data").await?;
std::fs::remove_dir(root.join("sub"))?;
std::fs::write(root.join("sub"), b"blocker")?; // parent is now a file
w.close().await;
```
```
unconditional close Err(NotFound) temporary=false ... (os error 3)
staging files left: 0
if_not_exists close Err(Unexpected) temporary=true ... => invalid input
parameter, source: (os error 87)
staging files left: 1
```
### Actual Behavior
The error is temporary `Unexpected`, and the staged file is left behind.
### Expected Behavior
A permanent `NotADirectory`, as on Linux and macOS, and the staged file is
removed.
### Additional Context
If a higher ancestor is replaced instead, Windows returns
`ERROR_PATH_NOT_FOUND`. That error is already permanent and cleaned up; only
its kind differs. #9031 / #9032 cover that kind of mismatch for the other fs
paths.
### Reproduction confirmation
- [x] I reproduced this issue against the affected component. For a
service-specific report, I used the actual service rather than only a mock,
emulator, or source-code analysis.
### Are you willing to submit a PR to fix this bug?
- [x] Yes, I would like to submit a PR.
--
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]