Skip to content

lib/store: force cleanup now removes in-memory cache entries - #652

Open
sileshidev-lab wants to merge 1 commit into
uber:masterfrom
sileshidev-lab:force-cleanup-memory-cache
Open

lib/store: force cleanup now removes in-memory cache entries#652
sileshidev-lab wants to merge 1 commit into
uber:masterfrom
sileshidev-lab:force-cleanup-memory-cache

Conversation

@sileshidev-lab

Copy link
Copy Markdown

Summary

Fixes #490 — the force-cleanup endpoint gets entries that only exist in the memory cache, but never actually removes them, since the current deletion logic only touches disk files.

Root cause: CAStore.GetCacheFileStat and CAStore.ListCacheFiles both already have overrides that check the memory cache (ListCacheFiles explicitly merges memory + disk entries). DeleteCacheFile has no such override — calls fall straight through to the embedded, disk-only cacheStore.DeleteCacheFile via struct embedding. So the force-cleanup handler lists an in-memory entry as a valid deletion candidate, then silently no-ops on actually deleting it.

Fix: add a CAStore.DeleteCacheFile override, matching the pattern of the existing memory-aware overrides — remove the entry from the memory cache first (BlobMemoryCache.Remove, a documented no-op if absent), then fall through to the disk delete. A not-exist error from the disk delete is only swallowed when we know the entry was memory-only (tracked before removal), so the not-exist signal is preserved for entries that genuinely don't exist anywhere — existing disk-only and disabled-memory-cache behavior is unchanged.

Test plan

  • New TestCAStore_DeleteCacheFile with 4 subtests: memory-only entry is removed with no error, disk-only entry still deletes as before (regression), memory cache disabled falls back to disk-only behavior (regression), and a truly nonexistent entry still returns the not-exist error
  • Verified the new test actually catches the bug: reverted the fix locally and confirmed exactly the memory-only-entry subtest fails while the regression subtests still pass — not a false-positive test
  • go build ./... — whole repo compiles
  • go test -race --tags "unit" ./lib/store/... — all pass (matches the project's exact CI test command/flags)
  • golangci-lint run ./lib/store/... — 0 issues
  • Line lengths checked against STYLEGUIDE.md's <100 char limit

DeleteCacheFile had no CAStore-level override, unlike
GetCacheFileStat and ListCacheFiles which both already check the
memory cache. Calls fell straight through to the disk-only
cacheStore.DeleteCacheFile, so entries that only lived in the
memory cache were never actually removed.

This meant the force-cleanup endpoint would list an in-memory
entry as a deletion candidate (ListCacheFiles already includes
memory entries) but silently fail to remove it, since the delete
step only touched disk.

Add a DeleteCacheFile override that removes the entry from the
memory cache first, then falls through to the disk delete. A
not-exist error from the disk delete is only swallowed when we
know the entry was memory-only (never had a disk file to begin
with), so the not-exist signal is preserved for entries that
genuinely don't exist anywhere.

Fixes uber#490
@CLAassistant

CLAassistant commented Aug 6, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

fix(lib/store): include in-mem cache for force cleanup

2 participants