benbjohnson/litestream · info
close temp meta file: %w
Error message
close temp meta file: %w
What it means
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.
Source
Thrown at vfs.go:1015
if removeErr := os.Remove(tmpPath); removeErr != nil {
h.logger.Warn("failed to remove temp meta file during cleanup", "error", removeErr)
}
return fmt.Errorf("write hydration meta: %w", err)
}
if err := tmp.Sync(); err != nil {
if closeErr := tmp.Close(); closeErr != nil {
h.logger.Warn("failed to close temp meta file during cleanup", "error", closeErr)
}
if removeErr := os.Remove(tmpPath); removeErr != nil {
h.logger.Warn("failed to remove temp meta file during cleanup", "error", removeErr)
}
return fmt.Errorf("sync temp meta file: %w", err)
}
if err := tmp.Close(); err != nil {
if removeErr := os.Remove(tmpPath); removeErr != nil {
h.logger.Warn("failed to remove temp meta file during cleanup", "error", removeErr)
}
return fmt.Errorf("close temp meta file: %w", err)
}
if err := os.Rename(tmpPath, h.metaPath()); err != nil {
if removeErr := os.Remove(tmpPath); removeErr != nil {
h.logger.Warn("failed to remove temp meta file during cleanup", "error", removeErr)
}
return fmt.Errorf("rename hydration meta: %w", err)
}
if err := syncDir(filepath.Dir(h.metaPath())); err != nil {
return fmt.Errorf("sync hydration meta directory: %w", err)
}
return nil
}
func syncDir(path string) error {
dir, err := os.Open(path)
if err != nil {
return err
}View on GitHub (pinned to 4ed7a308f6)
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
Defensive patterns
Strategy: try-catch
Try / catch
if err := saveMeta(); err != nil {
// temp file is auto-cleaned; just log and rely on re-hydration
h.logger.Warn("hydration meta not saved", "error", err)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: NFS/FUSE mounts reporting stale file handles at close; cascading failures after an earlier ENOSPC or EIO on the same fd.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- failed to scan directory %s: %w
- cannot remove tmp files: %w
- create temp L0 file: %w
- close L0 file: %w
- write page %d: %w
AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06).
Data as JSON: /api/errors/dfe69c67f6d99b15.
Report an issue: GitHub.