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

   # Which issue does this PR close?
   
   N/A
   
   # Rationale for this change
   
   `CacheDeleter::delete` previously called `state.begin_mutation(&subjects)` 
before `inner.delete(path, args)`, but when `inner.delete` returned `Ok(())`, 
it deferred actual cache invalidation (`state.invalidate` or 
`state.bump_generation`) until `CacheDeleter::close`.
   
   `begin_mutation` only advances the in-process shard epoch to block 
concurrent fills from publishing stale pointers; it does not remove an already 
cached metadata pointer. For deleters that commit deletions during `delete()` 
(such as `OneShotDeleter` implementations including `Memory` and `Fs`, or 
`BatchDeleter` when a batch flushes mid-stream), any read between 
`deleter.delete(...)` and `deleter.close()`—or after a deleter is dropped 
without calling `close()`—served the deleted object from cache.
   
   In addition, if a later `delete()` call failed after an earlier buffered 
batch had partially flushed, only the failing call's subjects were invalidated 
on the error path.
   
   # What changes are included in this PR?
   
   - In `core/layers/cache/src/mutation.rs`:
     - Invalidate immediately in `CacheDeleter::delete` when `inner.delete` 
succeeds (calling `bump_generation()` for recursive deletes and 
`invalidate(&subjects)` otherwise), while keeping `self.subjects` and 
`self.recursive` tracked so `CacheDeleter::close` invalidates again after 
buffered deleters flush.
     - On `CacheDeleter::delete` errors, also invalidate previously tracked 
subjects (or bump generation if `self.recursive || recursive`) in case an 
earlier buffered batch flushed before the error.
     - Skip `invalidate` on empty `close()` calls when no non-recursive 
subjects are tracked.
   - In `core/layers/cache/tests/read_through.rs`:
     - Add `deleter_delete_invalidates_cache_before_close` covering 
single-object and recursive delete invalidation before `Deleter::close`.
     - Add `buffered_deleter_invalidates_again_on_close` covering buffered 
deleters where reads between `delete()` and `close()` re-populate the cache 
before `close()` deletes from origin.
     - Update `fs_origin_handles_missing_read_metadata_and_mutations` to expect 
`v1/gen` = `"2"` after `op.delete_with("dir/").recursive(true)` (one bump on 
`delete`, one on `close`).
   
   # Are there any user-facing changes?
   
   Reads issued through `CacheLayer` between `Deleter::delete` and 
`Deleter::close` no longer return cached bytes for objects already removed from 
the origin service.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: pi
   - Model: Gemini 4 Neon
   - Effort: high
   - Role: Reproduced the bug with regression tests, implemented the 
`CacheDeleter` invalidation fix and buffered-deleter coverage, and ran 
formatting, clippy, and crate tests.
   


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