Skip to content

Make FSStore.Delete* return ErrNotFound for missing files - #63

Open
damilolaedwards wants to merge 1 commit into
ethpandaops:masterfrom
damilolaedwards:fix/fsstore-delete-returns-not-found
Open

Make FSStore.Delete* return ErrNotFound for missing files#63
damilolaedwards wants to merge 1 commit into
ethpandaops:masterfrom
damilolaedwards:fix/fsstore-delete-returns-not-found

Conversation

@damilolaedwards

Copy link
Copy Markdown

Summary

  • Every Delete* method on the filesystem store passed os.Remove's raw error straight through instead of translating a missing file into the package's ErrNotFound sentinel. The S3 backend already made this distinction correctly.
  • The retention watcher relies on errors.Is(err, store.ErrNotFound) to decide whether a missing file is fine to treat as already gone (and still remove the database row) versus a real failure worth retrying. On the filesystem backend that branch could never trigger, so a state whose file was already missing (manual cleanup, a crash mid-delete) could never be purged: retention logged an error and retried forever, leaving the row behind permanently.
  • Fix is a single change in FSStore.removeFile, since every Delete* method routes through it.

Test plan

  • go build ./... and go vet ./...
  • New unit tests: each Delete* method returns a missing-file error that satisfies errors.Is(err, store.ErrNotFound); deleting an existing file still succeeds
  • New integration test: a beacon state row whose file is already missing from disk is now correctly purged by the retention loop instead of being retried forever
  • Confirmed all new tests fail against the pre-fix code
  • Full existing pkg/store and pkg/server/persistence suites pass with no regressions

Every Delete* method on the filesystem store passed os.Remove's raw
error straight through, so a missing file surfaced as an opaque
*PathError instead of the package's ErrNotFound sentinel. The S3
backend already made this distinction correctly.

The retention watcher relies on errors.Is(err, store.ErrNotFound) to
decide whether a missing file is fine to treat as already gone (and
still remove the database row) versus a real failure worth retrying.
On the filesystem backend that branch could never trigger, so a state
whose file was already missing (manual cleanup, a crash mid-delete)
could never be purged: retention logged an error and retried forever,
leaving the row behind permanently.
@damilolaedwards
damilolaedwards requested a review from Savid as a code owner July 27, 2026 13:44
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.

1 participant