Repository navigation
fix(cache): delete the stored variant on NAR eviction - #1341
Conversation
DeleteNar removed only the exact URL variant via narStore.DeleteNar, but a Compression:none NAR's physical object is stored under the .nar.zst variant. Deleting nar/<H>.nar therefore left the real .nar.zst blob orphaned on disk while still clearing bytes_stored_at — leaking storage and making the /upload presence check lie (report absent while bytes remain). It also spuriously errored, since the bare none object never exists. Delete the actually-stored variant (the .nar.zst variant for none, mirroring statNarInStore) and track whether any variant was present, returning ErrNotFound only when none was — preserving the established 'deleting an absent NAR errors' contract while no longer orphaning the blob. Surfaced by CodeRabbit review on PR #1331. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
This change is part of the following stack: Change managed by git-spice. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR fixes a bug in ChangesFix Cache.DeleteNar orphaned-bytes handling
🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where deleting a Compression:none NAR left its physical .nar.zst variant orphaned on disk while clearing the bytes_stored_at marker. The DeleteNar function in pkg/cache/cache.go has been updated to delete the .nar.zst variant for none NARs before clearing the marker, and to return storage.ErrNotFound only if no variant was present. Corresponding unit tests have been added to verify this behavior. There are no review comments to address, and I have no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1341 +/- ##
============================
============================
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
## Summary The `[Unreleased]` section was populated in #1309 but skewed toward the recent CDC-drain, in-flight-staging, and Ent-migration work, omitting several user-facing features and fixes that also landed since v0.9.4. This backfills the missing notable changes, each cross-referenced by PR. **Added** - `ncps fsck` command + Helm fsck CronJob (#975, #996, #998, #999, #1000, #1004, #1006, #1176) - Closure pinning HTTP endpoints `POST`/`DELETE /pin/{hash}.narinfo`, `GET /pins` (#1108) - pprof server via `--pprof-addr` (#1063) - CDC lazy chunking as a feature + `--cache-cdc-lazy-cleanup-schedule` + recovery cron (#1082, #1083, #1089, #1096) - Helm: auto `GOMEMLIMIT` (#1061), configurable temp volume / `volumeClaimTemplate` (#1074, #1077), SQLite `Recreate` strategy (#1012) - Startup storage reporting + deprecated-narinfo warning (#959, #961) - `docker-dev` image (#1097) **Fixed** - `store/tmp` no longer wiped on startup (#1313) - `nix-hash` NAR verification (#1101) - Prometheus counters primed at startup (#1337, #1343) - 404 on un-reassemblable chunked NARs (#1319), purged narinfo no longer 500 (#1318), fail-fast tmp validation (#1086) - Further CDC/cache reliability fixes (#1317, #1346, #1341, #1342, #1331, #1347) **Changed** - CDC config now persisted in the DB config table (#971) Dependency bumps, CI/test-only changes, and the internal Ent-conversion PRs are intentionally excluded; the existing Ent-migration entry already covers that work. ## Test plan - [x] `nix fmt` reports no changes (docs-only edit) - [x] CHANGELOG section structure intact (Added/Fixed/Changed/Removed/Migration/CI)
Summary
Cache.DeleteNarremoved only the exact URL variant vianarStore.DeleteNar, but aCompression:noneNAR's physical object is stored under the.nar.zstvariant. Deletingnar/<H>.nartherefore left the real.nar.zstblob orphaned on disk while still clearingbytes_stored_at— leaking storage and making the/uploadpresence check lie (report absent while bytes remain). It also spuriously errored, since the bare none object never exists.This deletes the actually-stored variant (the
.nar.zstvariant fornone, mirroringstatNarInStore) and tracks whether any variant was present, returningErrNotFoundonly when none was — preserving the established "deleting an absent NAR errors" contract while no longer orphaning the blob.Surfaced by a CodeRabbit "outside diff range" finding on #1331; scoped out of that PR as pre-existing, now fixed on its own.
Specs: adds a requirement to
upload-reference-presence(deletion removes the stored variant before clearing the marker; not-found only when no variant was present).Test plan
task fmt,task lint,task testpassTestDeleteNar_RemovesNoneNarZstdVariant(none NAR removes the.nar.zstobject)TestDeleteNar_AbsentNoneNarReturnsNotFound(contract: absent →ErrNotFound, marker kept)DeleteNar"absent → ErrNotFound" backend test still passes