Part of #321. Governing: ADR-0013, ADR-0018, SPEC graceful-shutdown REQ-TMO-003/REQ-WG-004/REQ-SIG-004, SPEC metadata-enrichment-pipeline REQ-ENRICH-041. Depends on: #341 (same shutdown path), #324 (shutdown_timeout config). Hotspot: cmd/server/main.go — serialize with #326/#341/#324.
Requirements
Acceptance Criteria
- SIGTERM under load: background work drains inside the budget, exit code 0, correct log attributes
- A long tick provably prevents the next tick from starting (test with fake clock or instrumentation)
go test -race clean over the shutdown path
Branch
feature/342-graceful-shutdown-ordering
PR Convention
PR title references the story; body ends with Closes #342, references the parent epic and governing artifacts above.
🤖 Posted on behalf of @joestump by Claude.
Part of #321. Governing: ADR-0013, ADR-0018, SPEC graceful-shutdown REQ-TMO-003/REQ-WG-004/REQ-SIG-004, SPEC metadata-enrichment-pipeline REQ-ENRICH-041. Depends on: #341 (same shutdown path), #324 (shutdown_timeout config). Hotspot: cmd/server/main.go — serialize with #326/#341/#324.
Requirements
srv.Shutdownfirst with the full 30s ctx then raceswg.Wait()on the same ctx (cmd/server/main.go:637-659) — audit CRITICAL. Fix order or amend the spec (state which in the PR)FindSimilarArtistsForAllnever checksctx.Done()and sleeps 500ms per artist uncancellably (internal/services/similar_artists.go:451-476); also note it has no callers — wire it to a scheduler or remove it. AndArtistFindSimilarspawns an untracked goroutine withcontext.Background()(internal/handlers/artists.go:653-656) — tie to lifecyclesyncMetadataForUsersspawns per-user goroutines and returns immediately, and its governing comment falsely claims it blocks (cmd/server/main.go:283-338) — audit CRITICAL. Add a per-loop in-flight guard (this also removes the tag-upsert concurrency trigger tracked under EPIC: Unified Tag Taxonomy Completion #303)Acceptance Criteria
go test -raceclean over the shutdown pathBranch
feature/342-graceful-shutdown-orderingPR Convention
PR title references the story; body ends with
Closes #342, references the parent epic and governing artifacts above.🤖 Posted on behalf of
@joestumpby Claude.