internal/database and the blob upload step still end the process on a rollback after Ctrl-C, a failed close of query results, or a failed temp file cleanup #345

Closed
opened 2026-10-13 07:59:35 +02:00 by clawbot · 1 comment
Collaborator

Found while fixing #301.

What is wrong: #301 stops WithTx from exiting the process when a cancelled transaction was already rolled back. The same pattern remains elsewhere in internal/database: the rollback in WithReadTx (so Ctrl-C during a read can still end in a fatal exit instead of the interrupted exit), and database.Fatalf when closing query results fails, in blobs.go, chunks.go and snapshots.go. A process exit skips deferred cleanup.

Definition of done

  • No call in internal/database ends the process; each of these paths returns an error, and a rollback that finds the transaction already rolled back (sql.ErrTxDone) after a cancel is not an error.
  • The same for cleanupBlobTempFile in internal/snapshot/scanner.go, which calls log.Fatal when closing or removing a blob's temp file fails, ending the process from inside the upload step (noticed while fixing #302).
  • A test covers a read transaction cancelled during its body, and each changed close path where it can be caused.

Model: opus-5-5

Found while fixing https://git.eeqj.de/sneak/vaultik/issues/301. **What is wrong:** https://git.eeqj.de/sneak/vaultik/issues/301 stops `WithTx` from exiting the process when a cancelled transaction was already rolled back. The same pattern remains elsewhere in `internal/database`: the rollback in `WithReadTx` (so Ctrl-C during a read can still end in a fatal exit instead of the interrupted exit), and `database.Fatalf` when closing query results fails, in `blobs.go`, `chunks.go` and `snapshots.go`. A process exit skips deferred cleanup. **Definition of done** - No call in `internal/database` ends the process; each of these paths returns an error, and a rollback that finds the transaction already rolled back (`sql.ErrTxDone`) after a cancel is not an error. - The same for `cleanupBlobTempFile` in `internal/snapshot/scanner.go`, which calls `log.Fatal` when closing or removing a blob's temp file fails, ending the process from inside the upload step (noticed while fixing https://git.eeqj.de/sneak/vaultik/issues/302). - A test covers a read transaction cancelled during its body, and each changed close path where it can be caused. Model: opus-5-5
clawbot self-assigned this 2026-10-13 07:59:35 +02:00
clawbot changed title from internal/database still ends the process on a read-transaction rollback after Ctrl-C and on a failed close of query results to internal/database and the blob upload step still end the process on a rollback after Ctrl-C, a failed close of query results, or a failed temp file cleanup 2026-10-13 10:07:01 +02:00
Author
Collaborator

Implemented in #364: WithReadTx now handles its rollback as WithTx does, the query functions no longer end the process when closing their rows, and cleanupBlobTempFile returns its close or remove failure to the upload step. Details and disclosures are in the PR body.

Model: opus-5-5

Implemented in https://git.eeqj.de/sneak/vaultik/pulls/364: `WithReadTx` now handles its rollback as `WithTx` does, the query functions no longer end the process when closing their rows, and `cleanupBlobTempFile` returns its close or remove failure to the upload step. Details and disclosures are in the PR body. Model: opus-5-5
Sign in to join this conversation.