{"record":{"id":"5279d6b2c1f9ef83","repo":"dagger/dagger","slug":"failed-to-write-compressed-diff","errorCode":null,"errorMessage":"failed to write compressed diff","messagePattern":"failed to write compressed diff","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/snapshots/blobs_linux.go","lineNumber":79,"sourceCode":"\t\t}\n\t}()\n\n\tif err = cw.Truncate(0); err != nil {\n\t\treturn emptyDesc, false, errors.Wrap(err, \"failed to truncate writer\")\n\t}\n\n\tbufW := bufio.NewWriterSize(cw, 128*1024)\n\tvar labels map[string]string\n\tif compressorFunc != nil {\n\t\tdgstr := digest.SHA256.Digester()\n\t\tcompressed, err := compressorFunc(bufW, mediaType)\n\t\tif err != nil {\n\t\t\treturn emptyDesc, false, errors.Wrap(err, \"failed to get compressed stream\")\n\t\t}\n\t\t// Close ensure compressorFunc does some finalization works.\n\t\tdefer compressed.Close()\n\t\tif err := overlay.WriteUpperdir(ctx, io.MultiWriter(compressed, dgstr.Hash()), upperdir, lower); err != nil {\n\t\t\treturn emptyDesc, false, errors.Wrap(err, \"failed to write compressed diff\")\n\t\t}\n\t\tif err := compressed.Close(); err != nil {\n\t\t\treturn emptyDesc, false, errors.Wrap(err, \"failed to close compressed diff writer\")\n\t\t}\n\t\tlabels = map[string]string{\n\t\t\tlabelspkg.LabelUncompressed: dgstr.Digest().String(),\n\t\t}\n\t} else {\n\t\tif err = overlay.WriteUpperdir(ctx, bufW, upperdir, lower); err != nil {\n\t\t\treturn emptyDesc, false, errors.Wrap(err, \"failed to write diff\")\n\t\t}\n\t}\n\n\tif err := bufW.Flush(); err != nil {\n\t\treturn emptyDesc, false, errors.Wrap(err, \"failed to flush diff\")\n\t}\n\tvar commitopts []content.Opt\n\tif labels != nil {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/engine/snapshots/blobs_linux.go#L61-L97","documentation":"While computing the overlay-snapshot diff, the engine walks the upperdir and writes the changed files into the compressed stream (io.MultiWriter of the compressor and a SHA256 digester used for the uncompressed diffID label). If overlay.WriteUpperdir fails, the error is wrapped as 'failed to write compressed diff'. The cause is inside the filesystem diff walk or writing through the compressor.","triggerScenarios":"overlay.WriteUpperdir(ctx, MultiWriter(compressed, dgstr.Hash()), upperdir, lower) erroring — e.g. upperdir files unreadable/changed mid-walk, whiteout/opaque-xattr handling errors, compressor write failure (disk full) or context cancellation during the diff.","commonSituations":"Underlying snapshot files removed while the build was running (GC or concurrent prune); disk filling up mid-diff; filesystem corruption in /var/lib/... snapshot dirs; very large layers hitting IO limits.","solutions":["Read the wrapped inner error for the root cause.","Check disk space on the content-store/snapshot volume.","Rerun the build — concurrent modification of the snapshot during diff is often transient.","If snapshot dirs are corrupt, clear the affected cache and rebuild (e.g. buildctl prune for the ref)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"_, ok, err := ref.tryComputeOverlayBlob(ctx, lower, upper, mediaType, refID, compressor)\nif err != nil && strings.Contains(err.Error(), \"failed to write compressed diff\") {\n\tlog.Printf(\"diff write failed: %v; verifying snapshot and disk\", errors.Cause(err))\n\t// check disk, then retry or fall back to a plain walking differ\n}","preventionTips":["Prevent GC/prune of snapshots during export","Keep ample free disk space (compressed write amplifies IO)","Avoid mutating the filesystem being diffed concurrently","Ensure the process has read access to all upperdir files"],"tags":["overlayfs","io","compression","filesystem-diff","buildkit"],"backgroundTag":"overlay-diff-write-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}