{"record":{"id":"5cc3fc9a27366281","repo":"containerd/containerd","slug":"can-t-find-sandbox-for-taskexit-event-w","errorCode":null,"errorMessage":"can't find sandbox for TaskExit event: %w","messagePattern":"can't find sandbox for TaskExit event: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cri/server/events.go","lineNumber":347,"sourceCode":"\t\tlog.L.Infof(\"TaskExit event %+v\", e)\n\t\t// Use ID instead of ContainerID to rule out TaskExit event for exec.\n\t\tcntr, err := ce.c.containerStore.Get(e.ID)\n\t\tif err == nil {\n\t\t\tif err := ce.c.handleContainerExit(ctx, e, cntr, cntr.SandboxID); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to handle container TaskExit event: %w\", err)\n\t\t\t}\n\t\t\treturn nil\n\t\t} else if !errdefs.IsNotFound(err) {\n\t\t\treturn fmt.Errorf(\"can't find container for TaskExit event: %w\", err)\n\t\t}\n\t\tsb, err := ce.c.sandboxStore.Get(e.ID)\n\t\tif err == nil {\n\t\t\tif err := ce.c.handleSandboxExit(ctx, sb, e.ExitStatus, e.ExitedAt.AsTime()); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to handle sandbox TaskExit event: %w\", err)\n\t\t\t}\n\t\t\treturn nil\n\t\t} else if !errdefs.IsNotFound(err) {\n\t\t\treturn fmt.Errorf(\"can't find sandbox for TaskExit event: %w\", err)\n\t\t}\n\t\treturn nil\n\tcase *eventtypes.SandboxExit:\n\t\tlog.L.Infof(\"SandboxExit event %+v\", e)\n\t\tsb, err := ce.c.sandboxStore.Get(e.GetSandboxID())\n\t\tif err == nil {\n\t\t\tif err := ce.c.handleSandboxExit(ctx, sb, e.ExitStatus, e.ExitedAt.AsTime()); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to handle sandbox TaskExit event: %w\", err)\n\t\t\t}\n\t\t\treturn nil\n\t\t} else if !errdefs.IsNotFound(err) {\n\t\t\treturn fmt.Errorf(\"can't find sandbox for TaskExit event: %w\", err)\n\t\t}\n\t\treturn nil\n\tcase *eventtypes.TaskOOM:\n\t\tlog.L.Infof(\"TaskOOM event %+v\", e)\n\t\t// For TaskOOM, we only care which container it belongs to.\n\t\tcntr, err := ce.c.containerStore.Get(e.ContainerID)","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/containerd/containerd/blob/4246446a2bf7d03837b0244118d858799393bd80/internal/cri/server/events.go#L329-L365","documentation":"HandleEvent returns this when neither the container store nor the sandbox store can resolve a TaskExit event's ID — and the sandbox lookup failed with an error other than NotFound. Since NotFound from both stores means the ID is unknown and is silently ignored, a non-NotFound error here indicates the sandbox store lookup machinery itself failed.","triggerScenarios":"containerStore.Get(e.ID) returns NotFound, then sandboxStore.Get(e.ID) returns a non-NotFound error (metadata DB failure, transport error, store corruption) while handling *eventtypes.TaskExit.","commonSituations":"containerd metadata bolt DB failure under load; daemon shutdown mid-event; store corruption after crash; upgrade leaving inconsistent store state.","solutions":["Check containerd daemon logs for sandbox store / bolt errors","Restart containerd; the backoff monitor will redeliver the event","Inspect wrapped error chain for the underlying store cause","If persistent, inspect the containerd root metadata DB integrity"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Go: exit early on NotFound from container store, then guard sandbox lookup:\ncntr, err := containerStore.Get(e.ID)\nif errdefs.IsNotFound(err) {\n    sb, serr := sandboxStore.Get(e.ID)\n    if serr != nil && !errdefs.IsNotFound(serr) {\n        return fmt.Errorf(\"can't find sandbox for TaskExit event: %w\", serr)\n    }\n}","typeGuard":"func isSandboxLookupFailure(err error) bool {\n    return err != nil && !errdefs.IsNotFound(err)\n}","tryCatchPattern":"if err := HandleEvent(ev); err != nil {\n    if isSandboxLookupFailure(err) {\n        log.L.WithError(err).Errorf(\"sandbox store failure; restart may be required\")\n    }\n    // NotFound from both stores is intentionally ignored\n}","preventionTips":["Check bolt metadata DB integrity if lookups fail for known IDs","Restart containerd after unclean shutdown that may corrupt store state","Only NotFound from both stores is safe to ignore silently","Verify event IDs correspond to real containers/sandboxes (ID vs ContainerID confusion for exec)"],"tags":["containerd","cri","sandbox","store-lookup"],"backgroundTag":"sandbox-store-lookup-failed","analyzedSha":"4246446a2bf7d03837b0244118d858799393bd80","analyzedAt":"2026-09-02T00:14:43.053Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}