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

   # Which issue does this PR close?
   
   No tracking issue; this is a verified state-handling bug in 
`MultipartWriter::abort`.
   
   # Rationale for this change
   
   `MultipartWriter::abort` left the writer in an inconsistent state in two 
cases:
   
   - Before `initiate_part`, a single buffered write lives in `self.cache`. 
`abort()` returned early without clearing that cache, unlike `OneShotWriter` 
and `PositionWriter`. A later `close()` could commit the aborted bytes through 
`write_once`, and a later `write()` could upload them as part 0.
   - After `abort_part` succeeded, `self.upload_id`, `self.parts`, and 
`self.next_part_number` were left populated. A second `abort()` reissued 
`abort_part` for an already-aborted upload, which object stores reject with 
`NotFound`/`NoSuchUpload`, and stale part bookkeeping remained.
   
   # What changes are included in this PR?
   
   `MultipartWriter::abort` now:
   
   - Clears pending tasks and the cache before checking whether an upload was 
initiated.
   - Keeps `self.upload_id` and the part bookkeeping when `abort_part` returns 
an error, so a retry still aborts the same upload.
   - Clears `self.upload_id`, `self.parts`, and `self.next_part_number` only 
after `abort_part` succeeds, making later aborts idempotent no-ops.
   
   Two deterministic unit tests cover both paths. Both tests fail on the 
unfixed implementation: one checks that buffered data is cleared and `close()` 
does not commit it; the other injects a transient abort failure, retries 
successfully, and verifies a third abort does not call `abort_part` again.
   
   # Are there any user-facing changes?
   
   Writers that abort before any part is initiated no longer retain or later 
commit buffered data. Calling `abort()` again after a successful abort is now a 
no-op instead of issuing another backend request. No public API changes.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: pi coding agent (T3 Code)
   - Model: group/deepseek via magpie
   - Effort: max
   - Role: Implemented the fix and deterministic unit tests, confirmed the 
tests failed before the fix, and ran formatting, clippy, and unit tests. The 
accountable human author remains responsible for the change.
   


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