Fix corrupted local cache eviction with logging and tests#14
Closed
cchristous wants to merge 2 commits intorichardartoul:mainfrom
Closed
Fix corrupted local cache eviction with logging and tests#14cchristous wants to merge 2 commits intorichardartoul:mainfrom
cchristous wants to merge 2 commits intorichardartoul:mainfrom
Conversation
When S3 backend returns objects with empty outputid metadata, gobuildcache wrote corrupted local cache entries (outputID: with no value). Subsequent check() calls logged 2 WARN lines per corrupted entry, producing 45,000+ warnings per build. Two fixes: - s3.go: Treat empty outputid metadata as a cache miss instead of returning empty outputID that gets written to local cache - localcache.go: Silently evict corrupted entries on read instead of logging WARN. Corrupted entries are treated as cache misses.
- Add debug-level logging when evicting corrupted local cache entries for observability while avoiding log spam from stale entries - Add warn-level logging in evict() for non-ErrNotExist os.Remove errors (permission denied, I/O errors) instead of silently ignoring - Add tests: GET after PUT in read-only mode, corrupted metadata eviction, valid entry not evicted, empty outputID defense-in-depth, and evict permission error handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why these changes are safe
check()only fires for non-ErrNotExisterrors fromreadMetadata— genuine cache misses (file not found) are unaffected.evict()function tolerates already-removed files (ErrNotExistis silently ignored) and logs real filesystem errors at Warn level.S3.Get()— returnsmiss=true, err=niland properly closes the response body.-debugfor troubleshooting.Test plan
TestCorruptedMetadata_EvictsEntry— corrupted metadata triggers eviction of both data and meta filesTestCorruptedMetadata_ValidEntryNotEvicted— valid entries are not affected by eviction logicTestEmptyOutputID_BackendHit_LocalCacheSelfHeals— empty outputID from backend creates corrupted entry that self-heals on next checkTestEvict_PermissionError_LogsWarningAndContinues— eviction failure due to permissions does not panic, files remainTestReadOnlyMode_GetAfterPut— GET after PUT in read-only mode hits local cache