Files
Bobby Ho f32341ea4e fix(coderd/notifications): do not fetch after a graceful stop (#32627)
## TL;DR

Fix a race condition where the notification sender could fetch another batch after graceful shutdown was requested, delaying shutdown and causing intermittent `TestBackpressure` failures.

Refs https://linear.app/codercom/issue/CORE-718/flake-testbackpressure

## Changes

- Check the graceful context before fetching a new batch.
- Allow in-flight batches to complete and persist their results before shutdown.
- Leave `quartz` and other `TickerFunc` callers unchanged.
- Add `TestNotifier_NoFetchAfterGracefulStop` to verify that a late ticker callback does not trigger another fetch.

## Testing

- New regression test fails without the fix and passes with it.
- Notifier tests pass with `-race -count=5`.
- `golangci-lint` reports zero issues.
- Reproduced the original CI failure under high concurrency.
- With an artificially widened race window: 10/10 failures before the fix, 0/20 after the fix.
- Database-backed tests were validated on an earlier commit but have not been rerun on this branch.
2026-11-24 12:46:12 -07:00
..