Skip to content

Gantry: 10 - Lifecycle-bound background work #286

@vpatelsj

Description

@vpatelsj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions