{"record":{"id":"f44d5935af2302be","repo":"kopia/kopia","slug":"error-rewriting-contents-in-short-packs","errorCode":null,"errorMessage":"error rewriting contents in short packs","messagePattern":"error rewriting contents in short packs","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"repo/maintenance/maintenance_run.go","lineNumber":513,"sourceCode":"func runTaskExtendBlobRetentionTimeFull(ctx context.Context, runParams RunParameters, s *Schedule) error {\n\treturn ReportRun(ctx, runParams.rep, TaskExtendBlobRetentionTimeFull, s, func() (maintenancestats.Kind, error) {\n\t\treturn extendBlobRetentionTime(ctx, runParams.rep, ExtendBlobRetentionTimeOptions{})\n\t})\n}\n\nfunc runFullMaintenance(ctx context.Context, runParams RunParameters, safety SafetyParameters) error {\n\tlog := runParams.rep.LogManager().NewLogger(\"maintenance-full\")\n\n\ts, err := GetSchedule(ctx, runParams.rep)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"unable to get schedule\")\n\t}\n\n\tif shouldFullRewriteContents(s, safety) {\n\t\t// find packs that are less than 80% full and rewrite contents in them into\n\t\t// new consolidated packs, orphaning old packs in the process.\n\t\tif err := runTaskRewriteContentsFull(ctx, runParams, s, safety); err != nil {\n\t\t\treturn errors.Wrap(err, \"error rewriting contents in short packs\")\n\t\t}\n\t} else {\n\t\tnotRewritingContents(ctx, log)\n\t}\n\n\t// rewrite indexes by dropping content entries that have been marked\n\t// as deleted for a long time\n\tif err := runTaskDropDeletedContentsFull(ctx, runParams, s, safety); err != nil {\n\t\treturn errors.Wrap(err, \"error dropping deleted contents\")\n\t}\n\n\tif shouldDeleteOrphanedPacks(runParams.rep.Time(), s, safety) {\n\t\t// delete orphaned packs after some time.\n\t\tif err := runTaskDeleteOrphanedPacksFull(ctx, runParams, s, safety); err != nil {\n\t\t\treturn errors.Wrap(err, \"error deleting unreferenced blobs\")\n\t\t}\n\t} else {\n\t\tnotDeletingOrphanedPacks(ctx, log, s, safety)","sourceCodeStart":495,"sourceCodeEnd":531,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/repo/maintenance/maintenance_run.go#L495-L531","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-run `kopia maintenance run --full` after transient storage/network issues; the task is resumable and idempotent","Check blob-storage health and rate-limit settings; enable parallelism/anti-throttling options for the provider","Ensure no competing `kopia maintenance run` is running concurrently (check maintenance schedule ownership)","Inspect the wrapped inner error and repo logs for the specific pack/blob that failed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if shouldFullRewriteContents(s, safety) {\n    // ensure storage is reachable before starting\n    if err := s.ListContentsBlobIDs(ctx); err != nil {\n        return errors.Wrap(err, \"storage not reachable, skipping full rewrite\")\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := runTaskRewriteContentsFull(ctx, runParams, s, safety); err != nil {\n    if errors.Is(err, context.Canceled) || isTransientStorageError(err) {\n        // schedule retry instead of failing hard\n        scheduleRetry(err)\n        return nil\n    }\n    return errors.Wrap(err, \"error rewriting contents in short packs\")\n}","preventionTips":["Run full maintenance during off-peak hours to avoid storage throttling","Ensure only one client owns maintenance (check `kopia maintenance info`)","Configure provider-appropriate rate-limit/retry settings","Monitor repo for growing numbers of short packs so rewrites stay small"],"tags":["maintenance","storage","golang"],"backgroundTag":"api-error-response","analyzedSha":"82495e54b584c1ef6073c9e1be048f57f8aef078","analyzedAt":"2026-09-07T20:35:21.689Z","contentChangedAt":"2026-09-07T20:35:21.689Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}