fix(store): git is told to end before it is killed, and nothing in the owner's backup folder is ever deleted
A stopped git was killed outright and the program then removed lock files: in the archive every lock found, in a folder target any lock new since the push whose mtime held still for 1.5 s. Git does not touch a lock it is holding, so an unchanged mtime does not prove a lock stale: another git (the owner's, another machine's on a shared disk, a sync client's) stalled in a hook or an fsync loses its lock to that rule, and two ref updates race. The removal also re-resolved the repository and refs paths, so a folder swapped for a link redirected it. Now: SIGTERM goes to the git's process group first (git removes its own locks on SIGTERM, a push's receiving end its quarantine), TERM_GRACE (3 s) is waited for the group to end, and only then SIGKILL. A folder target is never written to or deleted from except by git: a lock our kill left there is left, noted with its whole path, and the push fails with LockLeft, which tells the owner which file to remove and that it is only safe once nothing else uses the folder. The archive keeps only two removals: the locks our own stopped git made (not there when the command began), and at open and at the start of a backup a lock older than ten minutes. Removals go through a directory handle opened once, never follow links, and take only regular files named as git names its locks (git_locks.rs). Tests use real git: SIGTERM mid-commit, mid-add and mid-push leaves no lock and no cleanup; a frozen group (SIGSTOP, so SIGTERM stays pending) is killed after the grace and the archive's locks go while the target's stay and are named; a git that traps SIGTERM is killed after the grace; fsck --strict on both repositories right after a stop during a 48 MiB pack's receipt; the archive's age rule; a swapped refs folder or archive path touches nothing outside. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7e5b698c1c
commit
6f174f3f87
3 files changed
+1427
-319
No files matched your search
+865
-319
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user