{"record":{"id":"38b01c1191738f1a","repo":"containerd/containerd","slug":"failed-to-get-info-on-already-active-mount-w","errorCode":null,"errorMessage":"failed to get info on already active mount: %w","messagePattern":"failed to get info on already active mount: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/runtime/v2/task_mounts.go","lineNumber":88,"sourceCode":"\n\tactivateOpts := []mount.ActivateOpt{\n\t\tmount.WithLabels(map[string]string{\n\t\t\t\"containerd.io/gc.bref.container\": taskID,\n\t\t}),\n\t}\n\tactivateOpts = append(activateOpts, c.mountClaimOpts(ctx, runtimeName, bootstrap)...)\n\n\tai, err := c.manager.Activate(ctx, taskID, rootfs, activateOpts...)\n\tswitch {\n\tcase err == nil:\n\t\treturn mountActivation{rootfs: ai.System, owned: true}, nil\n\tcase errdefs.IsAlreadyExists(err):\n\t\t// If creation of task with same identifier, use existing mount rather than forcing\n\t\t// deactivation of the old one. The back reference will prevent racing between\n\t\t// deactivation and re-use, as the container with the same ID would still exist.\n\t\tai, err := c.manager.Info(ctx, taskID)\n\t\tif err != nil {\n\t\t\treturn mountActivation{}, fmt.Errorf(\"failed to get info on already active mount: %w\", err)\n\t\t}\n\t\treturn mountActivation{rootfs: ai.System}, nil\n\tcase errdefs.IsNotImplemented(err):\n\t\t// Nothing needed the mount manager, the shim performs all the mounts.\n\t\treturn mountActivation{rootfs: rootfs}, nil\n\tdefault:\n\t\treturn mountActivation{}, err\n\t}\n}\n\n// Deactivate deactivates the mounts activated for taskID.\nfunc (c *taskMountController) Deactivate(ctx context.Context, taskID string) error {\n\tif c.manager == nil {\n\t\treturn nil\n\t}\n\treturn c.manager.Deactivate(ctx, taskID)\n}\n","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/containerd/containerd/blob/4246446a2bf7d03837b0244118d858799393bd80/core/runtime/v2/task_mounts.go#L70-L106","documentation":"In the task mount manager's Activate, when registering a mount fails with ErrAlreadyExists (a task with the same ID already holds a mount), containerd tries to fetch the existing activation info via c.manager.Info. If that Info lookup fails, this error wraps it and the mount activation aborts.","triggerScenarios":"Activate is called for a task ID that already has an active mount, and the subsequent manager.Info(ctx, taskID) fails (task vanished concurrently, ID mismatch, manager internal error).","commonSituations":"Race where the previous container/task is being torn down while a new one with the same ID activates; leftover stale mount state from a crashed task; ID reuse without cleanup.","solutions":["Remove the stale task/mount state (deactivate or delete the container with the conflicting ID) and retry.","Avoid reusing container IDs until the old one is fully removed.","Inspect the wrapped Info error for the true cause (NotFound => stale reference; cleanup the mount manager state)."],"exampleFix":"// before\nctr, err := client.NewContainer(ctx, sameID) // reuse ID while old mount still active\n// after\nif err := client.ContainerService().Delete(ctx, sameID); err != nil && !errdefs.IsNotFound(err) { return err }\nctr, err := client.NewContainer(ctx, sameID)","handlingStrategy":"retry","validationCode":"// Before activating, check for an existing container with the same ID\nif _, err := c.manager.Info(ctx, taskID); err == nil {\n    return errors.New(\"task ID already active; choose another ID or delete first\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"failed to get info on already active mount\") {\n        // stale/racing mount; cleanup and retry with backoff\n        time.Sleep(50 * time.Millisecond)\n        return activateMount(ctx, taskID, rootfs)\n    }\n    return err\n}","preventionTips":["Never reuse container/task IDs until the old one is fully deleted.","Serialize Create/Delete for the same ID (single-flight or lock per ID).","Clean up stale mount-manager state after crashes."],"tags":["mounts","race-condition","containerd","task-lifecycle"],"backgroundTag":"mount-already-exists","analyzedSha":"4246446a2bf7d03837b0244118d858799393bd80","analyzedAt":"2026-09-02T00:14:43.053Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}