{"record":{"id":"ee96cdb5df2f241d","repo":"benbjohnson/litestream","slug":"sync-temp-meta-file-w","errorCode":null,"errorMessage":"sync temp meta file: %w","messagePattern":"sync temp meta file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"vfs.go","lineNumber":1009,"sourceCode":"\ttmpPath := tmp.Name()\n\n\tif _, err := fmt.Fprintf(tmp, \"%d\\n\", txid); 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(\"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}","sourceCodeStart":991,"sourceCodeEnd":1027,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/vfs.go#L991-L1027","documentation":"Hydrator.saveMeta wraps tmp.Sync() failures as \"sync temp meta file\". fsync ensures the TXID survives a crash before the atomic rename; if the sync fails, the temp file is cleaned up and the meta is not published, so the next open re-hydrates.","triggerScenarios":"fsync returns EIO because the underlying disk is failing or was detached; ENOSPC-like metadata pressure on some filesystems; network filesystems that don't support reliable fsync returning errors.","commonSituations":"Failing disks reporting E_IO in dmesg; VM disks detached on the hypervisor side; FUSE/NFS mounts with flaky fsync support.","solutions":["Check kernel logs (dmesg) for I/O errors on the backing device — treat EIO as a hardware/disk problem","Replace or remount the failing volume; move the hydration path to healthy local storage","Accept the degraded mode: without a saved meta, litestream simply re-hydrates fully on next start"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := saveMeta(); err != nil && errors.Is(err, syscall.EIO) {\n\t// disk failing — evacuate volume and re-hydrate from replica\n}","preventionTips":["SMART-monitor disks hosting hydration state","Avoid FUSE/NFS mounts lacking reliable fsync","Accept degraded mode: failed sync means full re-hydration next start, no data loss"],"tags":["fsync","filesystem","durability"],"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-14T05:17:10.506Z"}