benbjohnson/litestream · error

apply ltx file (level=%d, min=%s, max=%s): %w

Error message

apply ltx file (level=%d, min=%s, max=%s): %w

What it means

applyLTXFile failed to apply a single LTX file's pages to the followed database — opening, decoding, locking, or writing the file failed. The wrapped error identifies the step; the follow loop counts it as a consecutive error and retries.

Source

Thrown at replica.go:912

			}
			currentTXID = bridgedTXID

			// Re-check if this file is still needed after bridging.
			if info.MaxTXID <= currentTXID {
				continue
			}
			if info.MinTXID > currentTXID+1 {
				return closeLevel0(nil)
			}
		}

		// Skip if already covered by a higher-level file.
		if info.MaxTXID <= currentTXID {
			continue
		}

		if err := r.applyLTXFile(ctx, f, info, pageSize); err != nil {
			return closeLevel0(fmt.Errorf(
				"apply ltx file (level=%d, min=%s, max=%s): %w",
				info.Level, info.MinTXID, info.MaxTXID, err,
			))
		}
		currentTXID = info.MaxTXID
	}

	if iterErr := itr.Err(); iterErr != nil {
		return closeLevel0(fmt.Errorf("iterate level 0 ltx files: %w", iterErr))
	}
	if _, err := closeLevel0(nil); err != nil {
		return currentTXID, err
	}

	if !sawLevel0 {
		bridgedTXID, err := r.fillFollowGap(ctx, f, currentTXID, currentTXID+1, pageSize)
		if err != nil {
			return currentTXID, err

View on GitHub (pinned to 4ed7a308f6)

Solutions

  1. Inspect the wrapped error (open/decode/lock/write)
  2. Check file permissions and concurrent access to the followed database
  3. The follow loop retries; persistent failure may require a full re-restore
Defensive patterns

Strategy: retry

When it happens

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