kopia/kopia · error

error rewriting contents in short packs

Error message

error rewriting contents in short packs

What it means

This error wraps any failure from runTaskRewriteContentsFull during a full maintenance run in kopia. Full maintenance consolidates packs that are less than 80% full by rewriting their contents into new consolidated packs, orphaning the old ones. If the rewrite task fails (e.g. blob storage errors, context cancellation, content conflicts), the wrapper adds this message.

Solutions

  1. Re-run `kopia maintenance run --full` after transient storage/network issues; the task is resumable and idempotent
  2. Check blob-storage health and rate-limit settings; enable parallelism/anti-throttling options for the provider
  3. Ensure no competing `kopia maintenance run` is running concurrently (check maintenance schedule ownership)
  4. Inspect the wrapped inner error and repo logs for the specific pack/blob that failed
Defensive patterns

Strategy: try-catch

Validate before calling

if shouldFullRewriteContents(s, safety) {
    // ensure storage is reachable before starting
    if err := s.ListContentsBlobIDs(ctx); err != nil {
        return errors.Wrap(err, "storage not reachable, skipping full rewrite")
    }
}

Try / catch

if err := runTaskRewriteContentsFull(ctx, runParams, s, safety); err != nil {
    if errors.Is(err, context.Canceled) || isTransientStorageError(err) {
        // schedule retry instead of failing hard
        scheduleRetry(err)
        return nil
    }
    return errors.Wrap(err, "error rewriting contents in short packs")
}

Prevention

When it happens

Trigger: shouldFullRewriteContents returned true and runTaskRewriteContentsFull failed: blob upload/download errors, storage throttling or outages, corrupted pack data, concurrent maintenance by another client, or context cancellation mid-rewrite.

Common situations: Large repositories with many short packs hitting rate limits on object storage; network interruptions during long rewrites; two clients both attempting full maintenance concurrently; running out of local temp space for staging.

Related errors


AI-assisted analysis of kopia/kopia@82495e54b5 (2026-09-07). Data as JSON: /api/errors/f44d5935af2302be. Report an issue: GitHub.

Appendix: source

Thrown at repo/maintenance/maintenance_run.go:513

func runTaskExtendBlobRetentionTimeFull(ctx context.Context, runParams RunParameters, s *Schedule) error {
	return ReportRun(ctx, runParams.rep, TaskExtendBlobRetentionTimeFull, s, func() (maintenancestats.Kind, error) {
		return extendBlobRetentionTime(ctx, runParams.rep, ExtendBlobRetentionTimeOptions{})
	})
}

func runFullMaintenance(ctx context.Context, runParams RunParameters, safety SafetyParameters) error {
	log := runParams.rep.LogManager().NewLogger("maintenance-full")

	s, err := GetSchedule(ctx, runParams.rep)
	if err != nil {
		return errors.Wrap(err, "unable to get schedule")
	}

	if shouldFullRewriteContents(s, safety) {
		// find packs that are less than 80% full and rewrite contents in them into
		// new consolidated packs, orphaning old packs in the process.
		if err := runTaskRewriteContentsFull(ctx, runParams, s, safety); err != nil {
			return errors.Wrap(err, "error rewriting contents in short packs")
		}
	} else {
		notRewritingContents(ctx, log)
	}

	// rewrite indexes by dropping content entries that have been marked
	// as deleted for a long time
	if err := runTaskDropDeletedContentsFull(ctx, runParams, s, safety); err != nil {
		return errors.Wrap(err, "error dropping deleted contents")
	}

	if shouldDeleteOrphanedPacks(runParams.rep.Time(), s, safety) {
		// delete orphaned packs after some time.
		if err := runTaskDeleteOrphanedPacksFull(ctx, runParams, s, safety); err != nil {
			return errors.Wrap(err, "error deleting unreferenced blobs")
		}
	} else {
		notDeletingOrphanedPacks(ctx, log, s, safety)

View on GitHub (pinned to 82495e54b5)