mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #161] [MERGED] fix(overlaybd): clear cache bitmap before destructive eviction steps #218
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#218
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/AgentENV/pull/161
Author: @huajq
Created: 8/12/2026
Status: ✅ Merged
Merged: 8/13/2026
Merged by: @yingdi-shan
Base:
main← Head:fix/overlaybd-cache-eviction-recovery📝 Commits (1)
c132bdafix(overlaybd): clear cache bitmap before destructive eviction steps📊 Changes
2 files changed (+63 additions, -5 deletions)
View changed files
📝
storage/overlaybd/src/backend/cache/full_file_cache/cache_entry.rs(+12 -5)📝
storage/overlaybd/src/backend/cache/tests.rs(+51 -0)📄 Description
What
Reorder
CacheEntry::evict_all_blocks: clear the in-memory block bitmap before removingmeta.binand hole-punching the data file. Pure ordering change; no new logic.Why
evict_all_blockscurrently removesmeta.bin, hole-punches the data file (its contents become zeros), and only then clears the in-memory bitmap. If the operation exits unexpectedly between the punch and the bitmap clear — e.g. a filesystem error under disk pressure, or a panic/cancellation in the blocking task — the entry is left with a bitmap that still claims blocks are cached while its data file reads back as all zeros. Every later read then hits the bitmap and serves zeros without ever falling back to the source (header magic/type don't matchat the overlaybd layer), with no self-heal until process restart.Clearing the bitmap first makes every partial-failure mode leave a benign "empty bitmap + intact data" state, where reads simply miss and refetch from the source.
Related issue
No tracking issue. Found during the review of the 2026-08-11 production cache-poison incident; related to #131 (cache-directory isolation). This PR is defense-in-depth, not the incident's root-cause fix.
Scope and non-goals
evict_all_blocksordering change and one discriminating regression test.Design and behavior changes
Failure/crash semantics only: a mid-eviction failure now leaves "empty bitmap + intact data" (miss-and-refetch) instead of "marked bitmap + zeroed data" (poison). The successful eviction path is behaviorally unchanged.
Compatibility and operations
Validation
make fmt(equivalent:cargo fmt --checkpassed)make clippy(cargo clippy -p overlaybd --all-targets -- -D warningspassed)cargo test -p overlaybd --lib -- backend::cache— 56 passed / 0 failed, including the new regression testtest_eviction_clears_bitmap_before_destroying_data, which fails on the pre-fix codemake test-unit(not run in full; change is confined to the overlaybd cache eviction path and covered by the crate-level suite)make -C services test(noservices/changes)Skipped checks and reasons: KVM integration tests not run — the change does not touch device/VM paths; validation was performed on a Linux test host.
Risks and reviewer notes
evict_all_blocksinstorage/overlaybd/src/backend/cache/full_file_cache/cache_entry.rs; regression test at the end oftests.rs.Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.