Xuanwo opened a new pull request, #8908: URL: https://github.com/apache/opendal/pull/8908
# Which issue does this PR close? None. The failure path was found while reviewing `AsyncWriter`; the reproduction and evidence are included below and in the new tests. # Rationale for this change `AsyncWriter` wraps an `opendal::Writer`, whose `close` can fail after the service staged data. `AsyncFileWriter::complete` returned that error without aborting the writer, and `AsyncArrowWriter::close(mut self)` consumes the arrow writer, so the caller no longer has a handle for `AsyncWriter::abort`. The leak reproduces with `services::Fs` and `atomic_write_dir`: when the final rename fails, `FsWriter::close` returns an error and leaves the staged file in the staging directory. Object stores keep the multipart upload instead. A failed `AsyncFileWriter::write` is equally terminal for the parquet file. In parquet 59.3.3, `AsyncArrowWriter::do_write` takes the encoded row group with `mem::take`, passes it to `write`, and drops it when `write` fails, after the row group was already recorded as flushed. Retrying cannot reproduce those bytes, so the write path needs the same cleanup. `ParquetObjectWriter` (deprecated in 59.2) does not call abort either, so this is an OpenDAL-side cleanup rather than a parquet requirement. # What changes are included in this PR? - Abort the underlying writer when `write` or `complete` fails, then return the original error. The abort error is discarded, consistent with `dav-server` and `unftp-sbe`, and because some writers cannot abort (for example non-staged `Fs` writes), where reporting it would mask the cause. - Record a successful abort on `AsyncWriter`. A repeated `abort` becomes a no-op, and `write`/`complete` fail instead of reaching a writer whose staged state is gone. Without this, OpenDAL's multipart writer would start a new upload on the next close and publish a truncated file, because abort clears its upload id. - Add two regression tests with `services::Fs` and `atomic_write_dir`: one fails the final rename during `close`, the other injects a write failure with a test layer that forwards the first write. Both assert that the staging directory is empty afterwards. Both fail on the unfixed code with the staged file left behind. # Are there any user-facing changes? In `parquet_opendal`: failed writes and closes now release staged files and multipart uploads instead of leaking them, and `AsyncWriter::abort` is idempotent. An aborted `AsyncWriter` cannot be reused. # Breaking changes # AI Usage Statement - Harness: pi coding agent - Model: DeepSeek - Effort: max - Role: Inspected the parquet and OpenDAL writer contracts, wrote the regression tests and the fix, and verified the result with formatting, clippy, unit tests, and rustdoc checks. Assumption: cleanup depends on the service supporting abort; when abort is unsupported or fails, the original error is still returned and no cleanup is possible. -- 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]
