{"record":{"id":"9cf42ce3127c9c9d","repo":"benbjohnson/litestream","slug":"vacuum-failed-w","errorCode":null,"errorMessage":"vacuum failed: %w","messagePattern":"vacuum failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream-test/shrink.go","lineNumber":278,"sourceCode":"\tduration := time.Since(startTime)\n\tslog.Info(\"Checkpoint complete\",\n\t\t\"mode\", c.CheckpointMode,\n\t\t\"busy\", busy,\n\t\t\"pages_written\", written,\n\t\t\"total_pages\", total,\n\t\t\"duration\", duration,\n\t)\n\n\treturn nil\n}\n\nfunc (c *ShrinkCommand) runVacuum(db *sql.DB) error {\n\tslog.Info(\"Running VACUUM (this may take a while)\")\n\n\tstartTime := time.Now()\n\t_, err := db.Exec(\"VACUUM\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"vacuum failed: %w\", err)\n\t}\n\n\tduration := time.Since(startTime)\n\tslog.Info(\"VACUUM complete\", \"duration\", duration)\n\n\treturn nil\n}\n\nfunc (c *ShrinkCommand) Usage() {\n\tfmt.Fprintln(c.Main.Stdout, `\nShrink a database by deleting data and optionally running VACUUM.\n\nUsage:\n\n\tlitestream-test shrink [options]\n\nOptions:\n","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream-test/shrink.go#L260-L296","documentation":"This error wraps failure of the `VACUUM` statement in `runVacuum`, the final step of the shrink command that rebuilds the database file to reclaim space. VACUUM fails when the disk lacks free space for the temporary copy, other transactions are open, or the database is not writable. It is thrown by `ShrinkCommand.runVacuum` and aborts the shrink.","triggerScenarios":"Insufficient disk space for VACUUM's temp copy (needs roughly 2x the DB size); another connection holds an open transaction; database opened read-only; database corrupted.","commonSituations":"Shrinking multi-GB test databases on small tmpfs/disk; concurrent litestream replication writing during vacuum; running shrink against a read-only mounted volume.","solutions":["Free disk space (VACUUM needs ~2x database size as temp space)","Close all other connections/transactions to the database during vacuum","Ensure the DB file and temp directory are writable","Check the wrapped error message for 'database is locked' or 'disk I/O error' and fix that root cause"],"exampleFix":"// before\nlitestream-test shrink --source-db /mnt/ro/large.db\n// after\n# mount writable & ensure ~2x DB size free\nlitestream-test shrink --source-db /mnt/rw/large.db","handlingStrategy":"validation","validationCode":"var fs syscall.Statfs_t\nsyscall.Statfs(filepath.Dir(dbPath), &fs)\nif fs.Bavail*uint64(fs.Bsize) < 2*dbSizeBytes {\n\treturn errors.New(\"insufficient disk space for VACUUM\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure ~2x DB size free on disk before VACUUM","Close all other DB connections during vacuum","Verify the DB file is writable, not read-only"],"tags":["sqlite","vacuum","disk-space","test-tooling"],"backgroundTag":"database-write-failed","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}