Repository navigation
fix: keep disk cache file state consistent - #24495
mergify[bot] merged 18 commits into
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
8bb4096 to
23d5cb5
Compare
There was a problem hiding this comment.
Pull request overview
Hardens the fileservice disk cache against stale in-memory index entries by verifying the on-disk cache file exists before treating an index hit as authoritative, and adds a regression test to ensure the cache self-repairs when the physical file is missing.
Changes:
- In
DiskCache.writeFile, validate cache index hits withos.Stat; if the file is missing, drop the stale index entry and proceed to rewrite the cache file. - Add
TestDiskCacheSetFileRepairsStaleIndexto reproduce the stale-index/missing-file scenario and assertSetFilerepairs the cache.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/fileservice/disk_cache.go | Adds existence check on cache index hits and deletes stale index entries to force a rewrite when the physical file is missing. |
| pkg/fileservice/disk_cache_test.go | Adds a regression test covering “index hit but physical file removed” and verifies subsequent reads observe repaired content. |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Retain memory cache values before publishing them in FIFO cache so delete/evict paths cannot release cache ownership before it is acquired. Keep slow post-set callbacks outside FIFO locks while preserving the existing public constructor. Co-authored-by: Copilot <[email protected]>
Use the same shard-locked validation for immediate enqueue as pending enqueue so a slow post-set callback cannot enqueue an item deleted before enqueue. Add coverage for enqueue-after-delete accounting. Co-authored-by: Copilot <[email protected]>
Merge Queue Status
This pull request spent 35 seconds in the queue, including 6 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #24493
What this PR does / why we need it:
This PR ports the safe disk-cache consistency fix to 4.0-dev.
4.0-dev did not yet contain the FIFO async
postEvictchange from #24117, but this PR brings the same performance intent in with the disk-cache safety guards included. This keeps the 3.0-dev and 4.0-dev fixes consistent while avoiding the stale-index race that caused repeated S3 full-object reads in 3.0-dev.Changes:
postEvictcallbacks outsidequeueLockto avoid slow callback lock convoy.Replace,Evict, andEvictWithWait.Deletecannot race with enqueue draining.os.Statbefore trusting a disk cache index hit; stale entries are repaired and rewritten.writeFilestill holds the per-path update guard.fifocache.Newcallback signature migration for object metadata cache.Validation: