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

   # Which issue does this PR close?
   
   Closes #8853.
   
   # Rationale for this change
   
   `MultipartCopier` and `BlockCopier` overloaded `completed: bool` and 
`metadata: Option<Metadata>` to represent both completed and aborted states. 
This caused three lifecycle bugs:
   
   1. Calling `close()` after `abort()` skipped `next()`, fell back to an 
unknown `Metadata`, filled `source_size` when known, and returned 
`Ok(Metadata)` for an aborted copy.
   2. Calling `MultipartCopier::abort()` before `initiate_copy()` returned 
`Ok(())` without marking the copier aborted, allowing later `next()` or 
`close()` calls to execute the copy.
   3. Calling `BlockCopier::abort()` never cleared `scheduled_block_ids`, so 
repeated `abort()` calls resent `abort_block()` with the same block IDs.
   
   In addition, calling `abort()` after server-side completion could still 
invoke `abort_copy()` / `abort_block()` because `upload_id` / 
`scheduled_block_ids` were retained after completion, and a failed `abort()` 
left the copier able to resume `next()` / `close()` after clearing in-flight 
tasks.
   
   # What changes are included in this PR?
   
   - Replace `completed: bool` + `metadata: Option<Metadata>` with an explicit 
`State` lifecycle enum (`Running`, `Aborting`, `Completed(Metadata)`, 
`Aborted`) in both `MultipartCopier` and `BlockCopier`.
   - Transition to `State::Aborting` on `abort()`, preserve `upload_id` / 
`scheduled_block_ids` until `abort_copy()` / `abort_block()` succeeds so failed 
aborts remain retryable, clear them on success, and transition to 
`State::Aborted`.
   - Make `abort()` idempotent for `State::Aborted` and a no-op for 
`State::Completed(_)`, while rejecting `next()` and `close()` with a permanent 
`ErrorKind::Unexpected` once aborted or aborting.
   - Clear `upload_id` / `parts` and `scheduled_block_ids` / `block_ids` when 
server-side completion succeeds.
   - Add deterministic unit tests for both `MultipartCopier` and `BlockCopier` 
covering abort before initiation/scheduling, abort after initiation/scheduling 
followed by repeated abort and `close()` / `next()`, retryable abort failure 
blocking `next()` / `close()`, and abort after completion.
   
   # Are there any user-facing changes?
   
   None.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: pi / T3 Code
   - Model: Gemini 4 Neon
   - Effort: High
   - Role: Investigated issue #8853, implemented the explicit lifecycle state 
machines in `MultipartCopier` and `BlockCopier`, added deterministic unit 
tests, and verified formatting, clippy, and unit/doc tests locally. No external 
storage service was involved because this fix covers pure-Rust state 
transitions in `opendal-core`.
   


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