fix(store): a killed git leaves no lock for anyone to remove, and a verification can be told to stop
A git killed (cancelled by a close, or silent for GIT_TIMEOUT) leaves the lock files it held, and nothing removed them for 300 s (the archive) or ever (a folder target): an immediate reopen's backup failed on index.lock and waited 15 minutes, and a receive-pack killed holding a ref lock could stop every later push. This process knows when it killed its own git, so once the command is reaped AND everything it started is gone (the process group is waited for: a killed process can still take a lock in its last instructions) the locks it could have left are dealt with at once, each noted for the caller's record. - the book's own archive: every lock is removed (this process holds the book's store lock, so no other wanderbooks process runs git on it); the same at open (clear_archive_locks), where a lock is a dead git's. - a target on this computer: D-30 makes the folder the owner's (an external disk, a synced folder), and nothing enforces that no other computer, data root with a book of the same id, or hand pushes to it (the only guard is the fast-forward rule). So a lock there is removed only if it was NOT there when the push began (one that was is left and noted) and it has stood unchanged for LOCK_SETTLE after the kill (a live writer holds a ref lock for the milliseconds of a ref update). Said in INVARIANT 5, with the one case this cannot see (a second writer stalled holding the lock past LOCK_SETTLE). A far repository is never touched. - a git killed inside `init` (found by the test with real git: the first backup of a book made HEAD.lock in a repository that isn't one yet, which stopped every later init) is covered the same way. - no git of ours starts another to go on after it (gc.auto=0, maintenance.auto=false), so 'everything it started is gone' is true. Also: a drill or proof can be told to stop (the cancel flag), looked at between phases, once per journal line replayed or applied, once per stored file hashed or listed and once per 64 KiB chunk compared (cancel.rs, a thread-scoped flag so nothing else can be stopped by it), and leaves nothing (its scratch clone is removed). Tests use REAL git, made slow by a reference-transaction hook that waits: killed mid-commit, mid-add (a huge sparse file), mid-push; the next backup succeeds and git fsck passes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ca6f5aa982
commit
10790d8794
8 files changed
+927
-31
No files matched your search
@@ -5,6 +5,10 @@ use thiserror::Error;
|
||||
/// Every way a store operation can fail.
|
||||
#[derive(Debug, Error)]
|
||||
pub enum StoreError {
|
||||
/// A verification was told to stop ([`crate::cancel`]): the books it
|
||||
/// was reading are being let go.
|
||||
#[error("stopped: the books are closing")]
|
||||
Cancelled,
|
||||
/// An attachment link names a subject that doesn't exist.
|
||||
#[error("no {0} to link to")]
|
||||
UnknownSubject(String),
|
||||
|
||||
Reference in new issue
Block a user