benbjohnson/litestream · error

new ltx compactor: %w

Error message

new ltx compactor: %w

What it means

ltx.NewCompactor failed to initialize over the plan's readers — typically an LTX header mismatch (incompatible versions, page sizes, or non-contiguous TXID ranges) in the selected backup files. The error surfaces through the compaction pipe.

Source

Thrown at replica.go:743

	}

	// Output to temp file & atomically rename.
	tmpOutputPath := opt.OutputPath + ".tmp"
	r.Logger().Debug("compacting into database", "path", tmpOutputPath, "n", len(rdrs))
	defer func() { _ = os.Remove(tmpOutputPath) }()

	f, err := os.Create(tmpOutputPath)
	if err != nil {
		return fmt.Errorf("create temp database path: %w", err)
	}
	defer func() { _ = f.Close() }()

	pr, pw := io.Pipe()

	go func() {
		c, err := ltx.NewCompactor(pw, rdrs)
		if err != nil {
			pw.CloseWithError(fmt.Errorf("new ltx compactor: %w", err))
			return
		}
		c.HeaderFlags = ltx.HeaderFlagNoChecksum
		_ = pw.CloseWithError(c.Compact(ctx))
	}()

	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.

View on GitHub (pinned to 4ed7a308f6)

Solutions

  1. Verify the LTX chain is contiguous (litestream ltx per level)
  2. Re-take a snapshot and rebuild history if the chain is inconsistent
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at replica.go:743 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/24e89598d79b80ab. Report an issue: GitHub.