Scope
Bind best-effort background work to agent lifecycle.
Problem
firePrefetch and reAdvertiseDigest start goroutines with context.Background(), so shutdown cannot cancel them and manifest bursts can create unbounded concurrent best-effort work.
Evidence:
internal/gantry/mirror/mirror.go:1756
internal/gantry/mirror/mirror.go:1774
Changes
- Pass an agent-scoped context or a cancellable child into
firePrefetch and reAdvertiseDigest instead of context.Background().
- Add a small semaphore if manifest bursts create too many concurrent goroutines.
- Ensure shutdown cancellation stops these best-effort goroutines before discovery/libp2p teardown completes.
Tests
- Lifecycle cancellation stops prefetch and readvertise goroutines.
- Shutdown does not start new background prefetch/readvertise work after drain begins.
Scope
Bind best-effort background work to agent lifecycle.
Problem
firePrefetchandreAdvertiseDigeststart goroutines withcontext.Background(), so shutdown cannot cancel them and manifest bursts can create unbounded concurrent best-effort work.Evidence:
internal/gantry/mirror/mirror.go:1756internal/gantry/mirror/mirror.go:1774Changes
firePrefetchandreAdvertiseDigestinstead ofcontext.Background().Tests