Skip to content

Snapshot GC holding write lock across deadline-less proxy Remove permanently wedges all snapshot operations #13798

Closed

Description

@NahumLitvin

Description

The snapshot garbage collector in core/metadata can permanently wedge every snapshot operation on a node when a proxy snapshotter stops answering.

garbageCollect holds the snapshotter write lock for the whole pass, and pruneBranch calls the underlying Snapshotter.Remove under that lock with no deadline. cleanupSnapshotter also strips cancellation with context.WithoutCancel, so nothing can interrupt the call from above. If the snapshotter is a proxy plugin whose connection has stopped responding, the Remove RPC blocks forever, the lock is never released, and every snapshot operation after that (including CRI RunPodSandbox) queues behind it until containerd is restarted. The node keeps reporting Ready the whole time, so nothing evicts or replaces it.

There is an old TODO in the code about this: core/metadata/snapshot.go has "TODO: Unlock before removal".

Steps to reproduce the issue

  1. Configure a proxy snapshotter as the CRI snapshotter (we hit this with soci-snapshotter, but any proxy plugin works).
  2. Wedge the proxy's gRPC connection so an in-flight Remove never gets response headers. In our case the snapshotter stopped serving containerd's long-lived connection after running out of file descriptors ([Bug] content_store=containerd: cross-process bbolt/lease deadlock between soci-snapshotter and containerd on first boot awslabs/soci-snapshotter#2037 is a similar report).
  3. Have at least one orphaned snapshot so GC calls Remove.
  4. Wait for the GC scheduler to run.

After that, every pod sandbox creation on the node fails with RunPodSandbox ... DeadlineExceeded.

Describe the results you received and expected

What we saw in production (containerd 2.2.3), from goroutine dumps of both daemons:

The GC goroutine sat blocked for 410 minutes:

goroutine 61 [sync.WaitGroup.Wait, 410 minutes]:
github.com/containerd/containerd/v2/core/metadata.(*DB).GarbageCollect (db.go:476)
github.com/containerd/containerd/v2/plugins/gc.(*gcScheduler).run

Its cleanup worker was parked in the proxied Remove with no deadline:

goroutine 25822900 [select, 410 minutes]:
google.golang.org/grpc/internal/transport.(*ClientStream).waitOnHeader
...
core/snapshots/proxy.(*proxySnapshotter).Remove
core/metadata.(*snapshotter).pruneBranch

17 CRI operations (RemoveContainer and the sandbox creation path) were blocked on the metadata snapshotter RWMutex for the same duration, and 40 gc-scheduler mutationCallback goroutines piled up on an unread channel.

Expected: a snapshotter that stops answering should turn into an error and a retry on the next GC pass, not disable pod creation on the node until someone restarts containerd.

What version of containerd are you using?

2.2.3 (the code is the same on main)

Any other relevant information

Fix proposed in #13799. Can share the full goroutine dumps if useful.

Activity

  1. NahumLitvin commented on Jul 15, 2026

    @NahumLitvin
    ContributorAuthor

    Turned out the trigger on our side was an fd leak in soci's lazy loading path (one leaked spancache fd per verified file), fixed in awslabs/soci-snapshotter#2043. That explains how the snapshotter got wedged. This issue and #13799 are about containerd surviving a snapshotter that stops answering, whatever the cause.

  2. NahumLitvin commented on Aug 10, 2026

    @NahumLitvin
    ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions