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

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements. You can link an issue to this PR using the GitHub syntax. For 
example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #.
   
   # Rationale for this change
   
   `RetryWrapper<R, I>` stored `inner: Option<R>` and moved it out with 
`Option::take()` across `.await` via `RetryPolicy::retry_with_context`. If an 
in-flight future on a wrapped `oio::Write`, `oio::List`, `oio::Delete`, or 
`oio::Copy` handle was dropped before resolving (for example under 
`tokio::select!`, an outer `TimeoutLayer`, or cancellation in language 
bindings), `self.inner` remained `None`. Subsequent calls on the same 
handle—including cleanup such as `Writer::abort`, `Copier::abort`, or retrying 
`Deleter::close`—then failed permanently with `ErrorKind::Unexpected("retry 
layer is in bad state, please make sure future not dropped before ready")`, 
losing queued state such as buffered batch deletions.
   
   `RetryPolicy` already drives retries with an explicit loop rather than 
`backon::RetryableWithContext`, so `RetryWrapper` no longer needs to move 
`inner` by value.
   
   # What changes are included in this PR?
   
   - Introduce a private `RetryLoop<'a, I>` helper in 
`core/layers/retry/src/lib.rs` that manages backoff, retry scheduling, and 
`RetryBudget` permit commit/release on cancellation.
   - Store `inner: R` directly in `RetryWrapper<R, I>` and borrow `&mut 
self.inner` inside each `oio::Write`, `oio::List`, `oio::Delete`, and 
`oio::Copy` retry loop so dropping an in-flight future preserves handle state 
instead of poisoning the wrapper.
   - Migrate `RetryPolicy::retry` and `RetryReadStream::read` onto `RetryLoop` 
and remove `RetryPolicy::retry_with_context`, preserving `RetryReadStream`'s 
`self.stream.take()` and `"read stream must be reopened"` `RetryBudget` guard.
   - Update `RetryLayer` and `TimeoutLayer` rustdoc notes on layer ordering and 
cancellation behavior.
   - Add deterministic cancellation regression tests in 
`core/layers/retry/src/tests/cancellation.rs` covering `Deleter`, 
`Copier::abort`, `Writer::{close,abort,copy_from}`, `Lister`, outer 
`TimeoutLayer` + `Writer::abort`, `RetryBudget` permit release during cancelled 
backoff sleep, and `RetryReadStream` reopen protection under `RetryBudget`.
   
   # Are there any user-facing changes?
   
   Dropping an in-flight future on a `RetryLayer`-wrapped writer, lister, 
deleter, or copier handle no longer poisons the handle with `"retry layer is in 
bad state"`. Composing `TimeoutLayer` outside `RetryLayer` now bounds total 
call duration without losing `RetryLayer` handle state, while callers still 
follow each handle's recovery contract (such as aborting an interrupted writer 
or reopening a read stream when using `RetryBudget`).
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: pi
   - Model: Gemini 4 Neon
   - Effort: high
   - Role: Implemented the `RetryLoop` refactor and `RetryWrapper` `&mut 
self.inner` borrowing change, updated `RetryLayer` and `TimeoutLayer` 
documentation, and authored deterministic unit tests for mid-flight 
cancellation recovery. Scope is limited to `core/layers/retry` and 
`core/layers/timeout` docs; public `core::Writer` / `core::Copier` cancellation 
contracts in `opendal-core` are unchanged.
   


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