dagger/dagger · error
ensure lease for snapshot diff
Error message
ensure lease for snapshot diff
What it means
ApplySnapshotDiff wraps EnsureLease failures with this message. EnsureLease attaches (or creates) the lease context needed so the snapshots referenced by the diff are not garbage-collected while Merge runs. If lease acquisition fails (lease manager error, backend unavailable), the whole diff application is aborted before any merge occurs.
Source
Thrown at engine/snapshots/manager.go:508
}
id := identity.NewID()
snapshotID := id
var diffs []Diff
if upper == nil || lower.SnapshotID() != upper.SnapshotID() {
diff := Diff{
Lower: lower.SnapshotID(),
Comparison: fsdiff.CompareContentOnMetadataMatch,
}
if upper != nil {
diff.Upper = upper.SnapshotID()
}
diffs = append(diffs, diff)
}
ctx, err := EnsureLease(ctx)
if err != nil {
return nil, errors.Wrap(err, "ensure lease for snapshot diff")
}
if err := cm.Snapshotter.Merge(ctx, snapshotID, diffs); err != nil {
return nil, errors.Wrap(err, "failed to apply snapshot diff")
}
cm.mu.Lock()
defer cm.mu.Unlock()
md := cm.ensureMetadata(id)
rec := &cacheRecord{
mutable: false,
cm: cm,
md: md,
}
opts = append(opts, withSnapshotID(snapshotID))
if err := initializeMetadata(rec.md, opts...); err != nil {
return nil, errView on GitHub (pinned to 82ba2681db)
Solutions
- Inspect the wrapped error: if it's a context error, retry with a fresh, live context.
- Verify the lease manager is properly initialized in the engine setup.
- Avoid cancelling the context while diff/merge operations are in flight.
- Check engine logs for lease-manager backend failures (often signals broader store problems).
Defensive patterns
Strategy: try-catch
Validate before calling
if err := ctx.Err(); err != nil { return err } // context must be live before ApplySnapshotDiff Try / catch
ir, err := cm.ApplySnapshotDiff(ctx, lower, upper)
if err != nil && strings.Contains(err.Error(), "ensure lease for snapshot diff") {
// lease acquisition failed: retry with fresh context, log lease-manager state
} Prevention
- Keep contexts alive for the duration of diff/merge operations.
- Ensure the lease manager is initialized before any ref operations.
- Avoid cancelling upstream work while merges are in flight.
- Watch engine logs for lease manager failures.
When it happens
Trigger: ApplySnapshotDiff(ctx, lower, upper) is called and EnsureLease(ctx) fails — typically when the lease manager cannot create/attach a lease for the context (backend error, cancelled context, lease manager not wired).
Common situations: Calling ApplySnapshotDiff with an already-cancelled context; lease manager misconfigured or its storage unavailable; concurrent engine shutdown racing lease creation.
Related errors
- missing lease requirement for adopt
- load %s: acquire operation lease: %w
- operation lease scope already released
- ensure lease for snapshot merge
- failed to ensure temporary lease for view mounts during merg
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/6352c87b6fb4c31e.
Report an issue: GitHub.