benbjohnson/litestream · error

sync restore output dir: %w

Error message

sync restore output dir: %w

What it means

After renaming the restored database into place, FsyncDir on the output directory failed. The rename itself succeeded but durability of the directory entry could not be guaranteed — usually an I/O error or a filesystem that doesn't support fsync on directories.

Source

Thrown at replica.go:767

	dec := ltx.NewDecoder(pr)
	if err := dec.DecodeDatabaseTo(f); err != nil {
		return fmt.Errorf("decode database: %w", err)
	}

	if err := f.Sync(); err != nil {
		return err
	} else if err := f.Close(); err != nil {
		return err
	}

	// Copy file to final location.
	r.Logger().Debug("renaming database from temporary location")
	if err := os.Rename(tmpOutputPath, opt.OutputPath); err != nil {
		return err
	}
	if err := internal.FsyncDir(filepath.Dir(opt.OutputPath)); err != nil {
		return fmt.Errorf("sync restore output dir: %w", err)
	}

	if opt.IntegrityCheck != IntegrityCheckNone {
		if err := checkIntegrity(ctx, opt.OutputPath, opt.IntegrityCheck); err != nil {
			if ctx.Err() == nil {
				_ = os.Remove(opt.OutputPath)
				_ = os.Remove(opt.OutputPath + "-shm")
				_ = os.Remove(opt.OutputPath + "-wal")
			}
			return fmt.Errorf("post-restore integrity check: %w", err)
		}
		r.Logger().Info("post-restore integrity check passed")
	}

	// Enter follow mode if enabled, continuously applying new LTX files.
	if opt.Follow {
		for _, rd := range rdrs {
			if closer, ok := rd.(io.Closer); ok {

View on GitHub (pinned to 4ed7a308f6)

Solutions

  1. Check filesystem health and dmesg for I/O errors
  2. Verify the output directory is on a local POSIX filesystem
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at replica.go:767 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06). Data as JSON: /api/errors/0192e9f3bb0d0d84. Report an issue: GitHub.