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

   # Which issue does this PR close?
   
   Related to #8584, where this bug surfaced during the S3 no-replay review 
(the zero-success `flush_buffer` collapse noted in 
https://github.com/apache/opendal/issues/8584#issuecomment-... review 
discussion). This PR fixes the core `BatchDeleter` error masking; the S3 
service-side replay guard remains tracked in that issue.
   
   # Rationale for this change
   
   `BatchDeleter::flush_buffer` checked `result.succeeded.is_empty()` before 
inspecting `result.failed`, and returned a permanent `ErrorKind::Unexpected` 
("batch delete returned zero successes") whenever a batch reported zero 
successes. When the backend accounted for every input path in `failed`, this 
had two bad effects:
   
   - Permanent per-object errors (e.g. S3 `PreconditionFailed` → 
`ConditionNotMatch`, `AccessDenied` → `PermissionDenied`) were discarded, 
losing both their `ErrorKind` and path/version context. Single-object deletes 
via `delete_once` preserve the real error, so batch and single paths behaved 
inconsistently.
   - Temporary per-object errors (e.g. `SlowDown`/`RateLimited`) were converted 
into a permanent `Unexpected`, so `RetryLayer` could never retry a fully-failed 
batch even though every item was safely replayable.
   
   # What changes are included in this PR?
   
   - `flush_buffer` now first validates that `succeeded + failed` accounts for 
every buffered path, so a buggy backend that drops or invents paths still fails 
fast with `Unexpected` instead of looping.
   - Failed paths already stay queued in the buffer; the flush now returns the 
first permanent failure with its original `ErrorKind` plus `path`/`version` 
context, matching `delete_once` semantics.
   - When nothing was deleted and every failure is temporary, the flush returns 
the first temporary error (kind and `is_temporary()` preserved, with 
`path`/`version` context). The items remain queued, so `RetryLayer` or a later 
`close()` replays the whole batch. Partial progress with temporary failures 
keeps the existing behavior: `close()` re-flushes the remaining items.
   - The `delete_batch` trait doc now states the real contract: implementations 
must account for every input path in `succeeded` or `failed`.
   - Five new unit tests cover all-failed permanent, all-failed temporary + 
retry, empty result, and partial permanent/temporary failure handling.
   
   # Are there any user-facing changes?
   
   Yes, as the fix intends. For a batch delete where every item fails: callers 
now receive the backend's real error kind and status (e.g. `ConditionNotMatch`, 
`PermissionDenied`, or a retryable temporary error) instead of a permanent 
`Unexpected`. Under `RetryLayer`, fully-failed batches with temporary errors 
are now retried instead of failing immediately.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: T3 Code (pi-coding-agent subagent), version 1.5.2.
   - Model: devin/swe-2.
   - Effort: max.
   - Role: Implemented the fix and unit tests, ran local verification. The bug 
and desired semantics were identified by maintainer analysis in #8584; no 
service-side wire behavior is claimed here — this change only fixes error 
propagation in `core` based on the existing `BatchDelete` contract.
   


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