{"record":{"id":"daba031e36f493a7","repo":"dagger/dagger","slug":"failed-to-get-usage-for-s-daba03","errorCode":null,"errorMessage":"failed to get usage for %s","messagePattern":"failed to get usage for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/snapshots/refs.go","lineNumber":168,"sourceCode":"func sizeFromMetadata(\n\tctx context.Context,\n\tsizeG *flightcontrol.Group[int64],\n\tcm *snapshotManager,\n\tmd *cacheMetadata,\n\tsnapshotID string,\n) (int64, error) {\n\treturn sizeG.Do(ctx, snapshotID, func(ctx context.Context) (int64, error) {\n\t\ts := md.getSize()\n\t\tif s != sizeUnknown {\n\t\t\treturn s, nil\n\t\t}\n\n\t\tvar usage snapshots.Usage\n\t\tif !md.getBlobOnly() {\n\t\t\tvar err error\n\t\t\tusage, err = cm.Snapshotter.Usage(ctx, snapshotID)\n\t\t\tif err != nil && !errors.Is(err, cerrdefs.ErrNotFound) {\n\t\t\t\treturn s, errors.Wrapf(err, \"failed to get usage for %s\", snapshotID)\n\t\t\t}\n\t\t}\n\n\t\tif dgst := md.getBlob(); dgst != \"\" {\n\t\t\tadded := make(map[digest.Digest]struct{})\n\t\t\tinfo, err := cm.ContentStore.Info(ctx, dgst)\n\t\t\tif err == nil {\n\t\t\t\tusage.Size += info.Size\n\t\t\t\tadded[dgst] = struct{}{}\n\t\t\t}\n\t\t\twalkBlobVariantsOnly(ctx, cm.ContentStore, dgst, func(desc ocispecs.Descriptor) bool {\n\t\t\t\tif _, ok := added[desc.Digest]; !ok {\n\t\t\t\t\tif info, err := cm.ContentStore.Info(ctx, desc.Digest); err == nil {\n\t\t\t\t\t\tusage.Size += info.Size\n\t\t\t\t\t\tadded[desc.Digest] = struct{}{}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn true","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/engine/snapshots/refs.go#L150-L186","documentation":"In sizeFromMetadata (cacheRecord size computation), a non-NotFound failure from Snapshotter.Usage(ctx, snapshotID) is wrapped as \"failed to get usage for %s\". The code computes a cache record's disk size by querying the snapshotter; NotFound is deliberately swallowed (treated as zero usage, e.g. blob-only or pruned records), but any other failure — I/O error, snapshotter corruption — aborts the size calculation.","triggerScenarios":"Calling Size()/usage accounting on a cache record whose snapshotID exists in metadata but whose snapshotter Usage lookup fails with something other than ErrNotFound.","commonSituations":"Overlayfs/native snapshot directories corrupted or partially deleted on disk; permission problems on the containerd state dir; snapshotter driver misbehaving after unclean shutdown.","solutions":["Check the snapshotter's on-disk state under /var/lib/containerd/io.containerd.snapshotter... for the snapshotID","Verify file permissions on the snapshot storage directory","Restart containerd to recover a wedged snapshotter","If the snapshot is genuinely gone, clear the record's metadata or let GC prune the record"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if _, err := cm.Snapshotter.Stat(ctx, snapshotID); err != nil {\n    // snapshot gone or unreadable — size will fall back to blob metadata\n}","typeGuard":null,"tryCatchPattern":"usage, err := cm.Snapshotter.Usage(ctx, snapshotID)\nif err != nil && !errors.Is(err, cerrdefs.ErrNotFound) {\n    // mirror the library: only non-NotFound is fatal\n    return errors.Wrapf(err, \"failed to get usage for %s\", snapshotID)\n}","preventionTips":["Treat ErrNotFound as zero-usage (blob-only/pruned records), like the library does","Check snapshotter on-disk permissions after unclean shutdowns","Restart containerd if Usage persistently fails on existing snapshots","Run GC repairs (containerd ctl) to clean corrupted snapshot dirs"],"tags":["snapshots","usage","disk-size","containerd"],"backgroundTag":"snapshotter-usage-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"}