Repository navigation
Server: removal runs inside the server, ordered against uploads - #107
Merged
Merged
Conversation
No request removed anything. The one removal path, reclaim-nars --delete, ran on the host against the store directory and shared no lock with the server, so a narinfo that arrived after its listing lost an old NAR, and a NAR uploaded again after its listing was removed anyway. The README asked for no push in progress during a run. DELETE /<hash>.narinfo removes an entry, POST /reclaim removes the NARs no narinfo names and the abandoned uploads, and GET /reclaim lists what it would remove; all three need the write key. Each FileStore carries a gate, a reader-writer lock over STM. A narinfo upload holds it shared from the check of its NAR through its write (storeNarInfo), each rename into nar/ holds it shared for the rename, and a reclaim or a narinfo removal holds it alone. A waiting removal lets nothing new take the gate, an interrupted one withdraws, and no request body is read under it. DELETE leaves the NAR to the reclaim, which removes it once nothing names it, as attic's garbage collection reaps orphan NARs. A narinfo uploaded over an entry replaces it, so a push can store a smaller encoding of the same NAR; the NAR it displaces is reclaimed the same way, and a client still holding the old narinfo gets upstream's SubstituteGone, a miss rather than a failure. reclaim-nars now exits nonzero and names the requests, since the server ignores arguments it does not know and would start a second server over the store. FileStore becomes abstract, fileStoreAt goes, scanStore takes a clock and lists the staged uploads, and stm joins the dependencies. The tests stop a reclaim between its listing and its removals through its clock and send a narinfo, a NAR or a multipart completion meanwhile, and stop a narinfo upload between its check and its write through its signer and start a reclaim meanwhile; each must wait at the gate and leave the store consistent. Removing the gate from any of those paths, narrowing the upload's hold to its check, or dropping the gate's writer preference or its withdrawal on interrupt fails the suite.
aoinoikaz
force-pushed
the
server-removal
branch
from
November 16, 2026 05:43
eb6b569 to
b3c8496
Compare
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.
Nothing in the server removed anything. The one removal path,
reclaim-nars --delete, ran on the host against the store directory with no lock shared with the server, so a narinfo stored after its listing could lose its NAR, and a NAR uploaded after the listing was removed; the README asked that no push run during a reclaim.Removal now runs inside the server, ordered against uploads by a reader-writer gate on the store: a narinfo upload holds it shared from the check of its NAR through its write, every rename into
nar/holds it shared for the rename, and a reclaim or a narinfo removal holds it exclusive. Request bodies are never read under the gate, and a waiting removal lets nothing new in. All three requests take the write key:DELETE /<hash>.narinfoGET /reclaimPOST /reclaim?min-age-hours=N(default 336)nova-cache-server reclaim-narsnow exits 1 naming these requests, and the README drops its no-push-in-progress rule. The shape follows attic's split between removing an entry and reaping orphan archives; attic orders reaping against uploads with a per-NAR hold in its database, and the gate is the in-process equivalent for a store with none. A removed archive needs no grace period: upstream's substituter treats a 404 for a NAR as a garbage-collected path and tries the next substituter (SubstituteGone). Deterministic tests stop a reclaim between its listing and its removals and an upload between its check and its write, and each fails with its part of the gate removed.FileStorebecomes abstract andfileStoreAtgoes, so the next release is 0.13.0.0, as the walk-error change already requires.Closes #96.