{"record":{"id":"09bc0603853ebe00","repo":"benbjohnson/litestream","slug":"get-final-size-w","errorCode":null,"errorMessage":"get final size: %w","messagePattern":"get final size: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/litestream-test/shrink.go","lineNumber":134,"sourceCode":"\t\t\t\"change_from_delete_mb\", (sizeAfterDelete-sizeAfterCheckpoint)/1024/1024,\n\t\t)\n\t}\n\n\tif c.Vacuum {\n\t\tif err := c.runVacuum(db); err != nil {\n\t\t\treturn fmt.Errorf(\"vacuum: %w\", err)\n\t\t}\n\n\t\tsizeAfterVacuum, _ := getDatabaseSize(c.DB)\n\t\tslog.Info(\"Size after VACUUM\",\n\t\t\t\"size_mb\", sizeAfterVacuum/1024/1024,\n\t\t\t\"total_reduction_mb\", (initialSize-sizeAfterVacuum)/1024/1024,\n\t\t)\n\t}\n\n\tfinalSize, err := getDatabaseSize(c.DB)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get final size: %w\", err)\n\t}\n\n\treductionPercent := float64(initialSize-finalSize) / float64(initialSize) * 100\n\tslog.Info(\"Shrink operation complete\",\n\t\t\"initial_size_mb\", initialSize/1024/1024,\n\t\t\"final_size_mb\", finalSize/1024/1024,\n\t\t\"reduction_percent\", fmt.Sprintf(\"%.1f\", reductionPercent),\n\t)\n\n\treturn nil\n}\n\nfunc (c *ShrinkCommand) getTableList(db *sql.DB) ([]string, error) {\n\trows, err := db.Query(`\n\t\tSELECT name FROM sqlite_master\n\t\tWHERE type='table'\n\t\tAND name NOT LIKE 'sqlite_%'\n\t\tAND name NOT LIKE 'load_test'","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream-test/shrink.go#L116-L152","documentation":"At the end of shrinkDatabase, the final database size is measured with getDatabaseSize(c.DB) to compute the reduction percentage; failure is wrapped as `get final size: %w`. This is a pure filesystem/stat operation — all SQL work (deletes, checkpoint, vacuum) has already completed, so this error never means the shrink itself failed.","triggerScenarios":"The database file vanished or became unreadable between the last operation and this final stat (external deletion, unmounted volume, permissions change); an OS error inside getDatabaseSize.","commonSituations":"Cleanup automation firing at job completion and deleting temp databases before the tool logs its summary; tests running on ephemeral storage that gets recycled; a hung NFS mount timing out on the final stat.","solutions":["Re-run to get a clean summary; the shrink work itself already succeeded","Verify with `ls -l <db>` / `du -h <db>` to get the final size manually","Prevent cleanup jobs from racing the tool (delay deletion until the process exits)","Inspect the wrapped inner error for the exact filesystem cause"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// size can always be obtained manually if the tool's final stat fails:\n// ls -l <db>  or  sqlite3 <db> 'PRAGMA page_count * page_size;'","typeGuard":null,"tryCatchPattern":"if err := runShrink(args); err != nil {\n    if strings.Contains(err.Error(), \"get final size\") {\n        log.Printf(\"shrink completed but final measurement failed (non-fatal): %v\", err)\n        return nil // work is done; only reporting failed\n    }\n    return err\n}","preventionTips":["Hold cleanup jobs until the shrink process has fully exited","Treat this error as cosmetic — all data operations already committed","Check the file size directly with ls/du if the summary is missing"],"tags":["filesystem","sqlite","stat","reporting"],"backgroundTag":"file-read-failed","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}