{"record":{"id":"6304244fd830af63","repo":"dagger/dagger","slug":"failed-to-release-applier","errorCode":null,"errorMessage":"failed to release applier","messagePattern":"failed to release applier","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"engine/snapshots/diffapply_linux.go","lineNumber":36,"sourceCode":"\t\"github.com/dagger/dagger/internal/buildkit/identity\"\n\t\"github.com/dagger/dagger/internal/buildkit/util/bklog\"\n\t\"github.com/hashicorp/go-multierror\"\n\t\"github.com/pkg/errors\"\n\t\"golang.org/x/sys/unix\"\n)\n\n// diffApply applies the provided diffs to the dest MountableRef and returns the correctly calculated disk usage\n// that accounts for any hardlinks made from existing snapshots. ctx is expected to have a temporary lease\n// associated with it.\nfunc (sn *mergeSnapshotter) diffApply(ctx context.Context, dest MountableRef, diffs ...Diff) (_ snapshots.Usage, rerr error) {\n\ta, err := applierFor(dest, sn.tryCrossSnapshotLink, sn.userxattr)\n\tif err != nil {\n\t\treturn snapshots.Usage{}, errors.Wrapf(err, \"failed to create applier\")\n\t}\n\tdefer func() {\n\t\treleaseErr := a.Release()\n\t\tif releaseErr != nil {\n\t\t\trerr = multierror.Append(rerr, errors.Wrapf(releaseErr, \"failed to release applier\")).ErrorOrNil()\n\t\t}\n\t}()\n\n\tfor _, diff := range diffs {\n\t\tvar lowerMntable MountableRef\n\t\tif diff.Lower != \"\" {\n\t\t\tif info, err := sn.Stat(ctx, diff.Lower); err != nil {\n\t\t\t\treturn snapshots.Usage{}, errors.Wrapf(err, \"failed to stat lower snapshot %s\", diff.Lower)\n\t\t\t} else if info.Kind == snapshots.KindCommitted {\n\t\t\t\tlowerMntable, err = sn.View(ctx, identity.NewID(), diff.Lower)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn snapshots.Usage{}, errors.Wrapf(err, \"failed to mount lower snapshot view %s\", diff.Lower)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlowerMntable, err = sn.Mounts(ctx, diff.Lower)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn snapshots.Usage{}, errors.Wrapf(err, \"failed to mount lower snapshot %s\", diff.Lower)\n\t\t\t\t}","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/engine/snapshots/diffapply_linux.go#L18-L54","documentation":"After diffApply finishes, the applier's Release() is deferred to free resources; if Release fails while the main body also failed, the release error is wrapped as 'failed to release applier' and appended via multierror so the original error is preserved. On its own it signals leaked or not-properly-closed applier resources (snapshot refs/mounts).","triggerScenarios":"a.Release() returns an error at function exit — e.g. releasing snapshot references or unmounting the destination fails; it can also mask/join with the primary error via multierror.","commonSituations":"Busy mounts preventing unmount (EBUSY); leaked references held elsewhere; destination snapshot already removed; cascading after an earlier failure in the same call.","solutions":["Look at the full multierror output — the release error often accompanies a primary error that is the real cause.","Check for busy mounts (mount | grep <path>) and unmount leftovers.","Verify no leaked references keep the snapshot alive; run prune to clean stale state.","Restart the engine if mounts are stuck after crash."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await mergeOp();\n} catch (e) {\n  const parts = String(e).split('\\n');\n  const primary = parts[0];\n  if (parts.some(p => p.includes('failed to release applier'))) {\n    // release failure is secondary; focus on primary, then unmount leftovers\n    cleanupMounts();\n  }\n  throw new Error(primary);\n}","preventionTips":["Read the full multierror, not just the last line","Clean up leftover mounts after engine crashes","Prune stale state periodically to avoid leaked references"],"tags":["applier","release","cleanup","mount"],"backgroundTag":"applier-release-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"}