{"record":{"id":"dfe69c67f6d99b15","repo":"benbjohnson/litestream","slug":"close-temp-meta-file-w","errorCode":null,"errorMessage":"close temp meta file: %w","messagePattern":"close temp meta file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"vfs.go","lineNumber":1015,"sourceCode":"\t\tif removeErr := os.Remove(tmpPath); removeErr != nil {\n\t\t\th.logger.Warn(\"failed to remove temp meta file during cleanup\", \"error\", removeErr)\n\t\t}\n\t\treturn fmt.Errorf(\"write hydration meta: %w\", err)\n\t}\n\tif err := tmp.Sync(); err != nil {\n\t\tif closeErr := tmp.Close(); closeErr != nil {\n\t\t\th.logger.Warn(\"failed to close temp meta file during cleanup\", \"error\", closeErr)\n\t\t}\n\t\tif removeErr := os.Remove(tmpPath); removeErr != nil {\n\t\t\th.logger.Warn(\"failed to remove temp meta file during cleanup\", \"error\", removeErr)\n\t\t}\n\t\treturn fmt.Errorf(\"sync temp meta file: %w\", err)\n\t}\n\tif err := tmp.Close(); err != nil {\n\t\tif removeErr := os.Remove(tmpPath); removeErr != nil {\n\t\t\th.logger.Warn(\"failed to remove temp meta file during cleanup\", \"error\", removeErr)\n\t\t}\n\t\treturn fmt.Errorf(\"close temp meta file: %w\", err)\n\t}\n\tif err := os.Rename(tmpPath, h.metaPath()); err != nil {\n\t\tif removeErr := os.Remove(tmpPath); removeErr != nil {\n\t\t\th.logger.Warn(\"failed to remove temp meta file during cleanup\", \"error\", removeErr)\n\t\t}\n\t\treturn fmt.Errorf(\"rename hydration meta: %w\", err)\n\t}\n\tif err := syncDir(filepath.Dir(h.metaPath())); err != nil {\n\t\treturn fmt.Errorf(\"sync hydration meta directory: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc syncDir(path string) error {\n\tdir, err := os.Open(path)\n\tif err != nil {\n\t\treturn err\n\t}","sourceCodeStart":997,"sourceCodeEnd":1033,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/vfs.go#L997-L1033","documentation":"Hydrator.saveMeta wraps (*os.File).Close failures on the temp meta file as \"close temp meta file\". Close after Sync rarely fails, but when it does the meta is not renamed into place and the temp file is removed.","triggerScenarios":"Deferred buffered-write flush failing at close (on filesystems where close flushes); fd already invalidated by earlier I/O failure; rare filesystem-specific close-time errors.","commonSituations":"NFS/FUSE mounts reporting stale file handles at close; cascading failures after an earlier ENOSPC or EIO on the same fd.","solutions":["Check the wrapped errno — STALE/NFS issues mean remount the share; earlier I/O errors mean fix the disk first","Since the temp file is cleaned up, no manual .hydration-meta-* cleanup is needed","Retry by restarting litestream once the filesystem is healthy"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := saveMeta(); err != nil {\n\t// temp file is auto-cleaned; just log and rely on re-hydration\n\th.logger.Warn(\"hydration meta not saved\", \"error\", err)\n}","preventionTips":["Prefer local filesystems over network mounts for meta files","After any ENOSPC/EIO event, restart litestream once the volume is healthy","No manual cleanup needed — temp files are removed on failure"],"tags":["io","filesystem","temp-file"],"backgroundTag":"file-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"}