Stop a stalled snapshot database read when restore or deep verify is interrupted #363

Merged
clawbot merged 1 commits from issue-356-stalled-snapshot-db-read into next 2026-10-13 19:36:44 +02:00
Collaborator

Fixes #356.

What was wrong: snapshot restore and snapshot verify --deep read the snapshot database straight from storage (downloadSnapshotDB in restore.go, downloadVerifiedSnapshotDB in verify.go), not through FetchBlob, so the fix in #355 did not reach that read. When it stalled on a slow USB stick or network share, Ctrl-C could not end it: the process exited at the shutdown timeout without its cleanup and left the decrypted database in the temp directory.

What changed: both functions now wrap the storage reader in the same closeOnCancelReader that FetchBlob uses, so a cancel closes it, the read ends with the context's error, and the temp directory is removed.

The interrupt test added for #325 now stalls either a blob read or the snapshot database read, each during restore and during deep verify; its storer takes the keys to stall as a parameter. Most of the test diff is re-indentation from the added loop; git diff -w shows the real change.

  • The test waits for the scratch files to appear instead of checking at once: the database's temp directory is created only after its read has begun, so it can appear just after the stall.
  • Limitation: a read stuck in the kernel that closing cannot interrupt (an unresponsive hard NFS mount) still cannot be stopped.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/vaultik/issues/356. **What was wrong:** `snapshot restore` and `snapshot verify --deep` read the snapshot database straight from storage (`downloadSnapshotDB` in `restore.go`, `downloadVerifiedSnapshotDB` in `verify.go`), not through `FetchBlob`, so the fix in https://git.eeqj.de/sneak/vaultik/pulls/355 did not reach that read. When it stalled on a slow USB stick or network share, Ctrl-C could not end it: the process exited at the shutdown timeout without its cleanup and left the decrypted database in the temp directory. **What changed:** both functions now wrap the storage reader in the same `closeOnCancelReader` that `FetchBlob` uses, so a cancel closes it, the read ends with the context's error, and the temp directory is removed. The interrupt test added for https://git.eeqj.de/sneak/vaultik/issues/325 now stalls either a blob read or the snapshot database read, each during restore and during deep verify; its storer takes the keys to stall as a parameter. Most of the test diff is re-indentation from the added loop; `git diff -w` shows the real change. - The test waits for the scratch files to appear instead of checking at once: the database's temp directory is created only after its read has begun, so it can appear just after the stall. - Limitation: a read stuck in the kernel that closing cannot interrupt (an unresponsive hard NFS mount) still cannot be stopped. Model: opus-5-5
clawbot added the needs-review label 2026-10-13 17:35:54 +02:00
clawbot self-assigned this 2026-10-13 17:35:54 +02:00
clawbot added 1 commit 2026-10-13 17:35:54 +02:00
Restore and deep verify read the snapshot database straight from
storage rather than through FetchBlob, so the earlier fix for stalled
blob reads did not cover it. A database read stalled on a slow USB
stick or network share kept the operation from returning after Ctrl-C;
the process then exited at the shutdown timeout and left the decrypted
database in the temp directory.

Both reads now wrap the storage reader in the close-on-cancel reader
FetchBlob uses, so a cancel ends the stalled read and the temp
directory is removed. The interrupt test now stalls either a blob or
the snapshot database, for both commands.

Limitation: a read stuck in the kernel that closing cannot interrupt,
such as one on an unresponsive hard NFS mount, still cannot be stopped.

Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit dfa3bbc9e1 into next 2026-10-13 19:36:44 +02:00
clawbot deleted branch issue-356-stalled-snapshot-db-read 2026-10-13 19:36:45 +02:00
Sign in to join this conversation.