Skip to content

fix: invalidate CacheStore entries after bulk deletion - #4696

Open
Harshit-2118 wants to merge 2 commits into
zarr-developers:mainfrom
Harshit-2118:fix/cache-bulk-deletion
Open

Harshit-2118 wants to merge 2 commits into
zarr-developers:mainfrom
Harshit-2118:fix/cache-bulk-deletion

Conversation

@Harshit-2118

Copy link
Copy Markdown

Summary

Fixes #4695.

CacheStore.clear() and CacheStore.delete_dir() previously deleted entries in the source store without invalidating cached data, leaving stale full-key or byte-range entries and out-of-sync size/LRU tracking. This fix performs the source deletion first, invalidates the persistent cache and matching tracked entries, and updates current_size and LRU tracking under the state lock. Directory boundaries are preserved: deleting data/ leaves the key data and the prefix database/ alone.

For reviewers

Range invalidation removes its tuple-key tracking and subtracts its sizes. The following loop handles only full-key entries, subtracting each size once before removing its tracking. Persistent cache deletion also removes stale entries that are not tracked by this instance.

The 12 new cases cover full/range reads, clear and directory deletion, trailing-slash and empty prefixes, untracked persistent entries, public group reopening in formats 2 and 3, shared read-only views, a disk-backed cache, size-budget reuse/LRU eviction, and source-error controls. Against unchanged main 13f4bf5, they give 10 failures and 2 passing controls; with the fix all 12 pass. The selected cache/wrapper/memory/local-store suite reports 562 passed and 159 GPU-only skips. Ruff check/format, focused mypy and changelog validation pass. A fresh run of the 12 new cases also passes against the unchanged upstream head.

Source errors raised before deletion propagate before cache invalidation. This does not add rollback for partially failing backends or atomicity for concurrent reads and deletion. The full project suite and hosted CI have not been run locally.

Author attestation

  • I am a human, these are my changes, and I have reviewed and understood every change and can explain why each is correct.

TODO

  • Add regression tests.
  • Add docstrings for the overrides.
  • Add a bugfix changelog fragment.
  • GitHub Actions have all passed.
  • Codecov passes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CacheStore serves deleted arrays after group deletion or store clearing

1 participant