Repository navigation
fix(core): prune permits/ in retained directories and identity staging files - #455
Merged
Merged
Conversation
…g files A first permit caller that stalls only through teardown builds an empty permits/ in the retained session directory. The retained prune path now removes an old permits/ that is empty or holds only stale permit files with gone owners, using the same checks as the coordination directory path, then prunes the directory as before. A writer killed inside publishCoordinationIdentity leaves its .takeover-identity-<uuid> staging file or the writeFileAtomic temp for it in the sessions root. Prune now removes them once they are older than the marker horizon, and the temp only when its writer pid is gone. Closes #431 Closes #434
Prune removed a retained directory's files through its open handle without checking that the name still pointed at it, and a bare rmdir aborted the whole run when an entry appeared first. Check the device and inode as the coordination path does, and keep a directory that gains an entry before rmdir.
removeRetainedDirectory took seven parameters, over the PickCheck limit of six.
Closed
2 tasks done
Closed
3 tasks done
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.
Closes #431
Closes #434
session prunenow removes two leftovers that it used to keep forever.A first permit caller that stalls only through teardown builds
permits/in the retained directory and then fails closed (#434). Prune now accepts a retained directory that holdspermits/, whenpermits/is a real directory that is empty or holds only stale permit files whose owners are gone. It uses the same permit checks as the #414 coordination path. Before it removes anything, it checks again that the session is not in the registry and that the directory under the id is still the one it opened, by device and inode. It then removes the permit files, carries the teardown time, removes the files and the marker through the directory handle, and removes the directory only if it is empty.publishCoordinationIdentityleaves.takeover-identity-<uuid>and itswriteFileAtomictemp in the sessions root when its process dies between the write and the unlink (#431). Prune now removes a staging file older than the one-day horizon, and a temp older than the horizon whose writer pid is gone. A staging file names no writer, so age alone decides. A writer that stalls past the horizon and then finds its staging file gone fails on the link and publishes nothing.Traceability
removes takeover identity staging files that a killed writer left,keeps takeover identity staging files inside the horizon,keeps %s in the sessions rootmain~/.pickforge/investigations/431-434/before-main-source.log,r2/core-tests.logfails closed for a writer that stalls past the horizon before it links the identitymain~/.pickforge/investigations/431-434/before-main-source.logpermits/that is empty or holds only stale permit files with gone ownersremoves permits/ that a caller stalled only through teardown left in a retained directory,removes stale permit files with gone owners from permits/ in a retained directory,keeps a retained directory whose permits is a symlink,keeps a retained directory whose permits/ holds %spermits/; stale permit records and temps;permits/as a symlink; a young permit, a live owner, a live temp writer and an unknown file are keptmain~/.pickforge/investigations/431-434/434-before-main-source.log,r2/core-tests.logstopped.json, a log,permits/, the identity and input-closed markers~/.pickforge/investigations/431-434/r2/core-tests.logkeeps a retained directory that is replaced after its permits are listed,keeps a retained directory that gains an entry before rmdirrmdir~/.pickforge/investigations/431-434/r2/before-r1-source.log~/.pickforge/investigations/431-434/mutation-*.logcli-qa.shplants both leftovers in a temporaryPICKFORGE_HOMEand runssession prune --all-stopped --jsonmainnothing is pruned~/.pickforge/investigations/431-434/cli-qa-after.log,cli-qa-before-main-source.logfull-suite.shmain: build, typecheck, lint andsession-retention.test.ts(82 tests) pass~/.pickforge/investigations/431-434/full/,r3/pickcheck check --base origin/main --fail-on new,worsened,unmatched; gitleaks on the branch commits~/.pickforge/investigations/431-434/pickcheck.jsonKnown limit: the directory identity check runs before the removal steps, which await. A process that swaps the directory between that check and the final
rmdircannot make prune remove its files, because each unlink goes through the handle prune opened and removes only files prune validated. The only step by name is thermdirof an empty directory, and neither POSIX nor Node can remove a directory by inode. The coordination path merged with #414 has the same window.Found during review and filed as #453: a slower concurrent prune can abort in
carryStoppedAtafter a faster prune removed the markers. It is unchanged frommain, and no data is at risk.Review
Council, three seats per round.
Round 1 found that prune did not check the directory identity before removal, and that a bare
rmdirthrew when the directory gained an entry. Both are fixed in 0f97b00. dff4ede after the council only passes the checked files and the teardown time as one object, for PickCheck's parameter limit. In round 2, Sol held that the identity check still leaves a rename window. That window is the known limit above, and Fable agreed that no change is needed. Sol rechecked dff4ede: 10/10, no findings.