fix(sports): downgrade 57P01 admin-terminated connection in linkStoredSquads to info (BIT-32471) #275

Merged
spark merged 1 commits from fix/BIT-32471-sports-57p01-admin-shutdown into main 2026-11-18 21:40:03 +00:00
Owner

Postgres terminates a pooled client mid-query on restart or pg_terminate_backend (SQLSTATE 57P01); Prisma surfaces the raw-query failure as P2010 wrapping "terminating connection due to administrator command".

linkStoredSquads ran an unguarded $queryRaw, so the rejection escaped to SportsWorker.fillRegister's catch and logged warn ("sports: register not filled"), paging the error loop for a transient blip (BIT-32471, ERRCLUSTER 498b9b73d09c).

Fix

Wrap the $queryRaw (extracted into linkStoredSquadsRows) so an admin-shutdown is detected via isPostgresAdminShutdown, logged at info, and returns 0 — fillRegister's loop breaks and the next scheduled tick retries on a fresh client. Non-transient errors still rethrow. The same helper already covers the equivalent raw-query path (BIT-32448/32449).

Tests

  • linkStoredSquads logs at info and returns 0 when the raw query is terminated mid-flight (57P01).
  • linkStoredSquads still rethrows a non-transient raw-query error.
  • Existing pg.test.ts / service.test.ts suites pass (23 tests).

Paperclip-Issue: BIT-32471

Postgres terminates a pooled client mid-query on restart or `pg_terminate_backend` (SQLSTATE 57P01); Prisma surfaces the raw-query failure as P2010 wrapping "terminating connection due to administrator command". `linkStoredSquads` ran an unguarded `$queryRaw`, so the rejection escaped to `SportsWorker.fillRegister`'s catch and logged `warn` ("sports: register not filled"), paging the error loop for a transient blip (BIT-32471, ERRCLUSTER 498b9b73d09c). ## Fix Wrap the `$queryRaw` (extracted into `linkStoredSquadsRows`) so an admin-shutdown is detected via `isPostgresAdminShutdown`, logged at info, and returns 0 — `fillRegister`'s loop breaks and the next scheduled tick retries on a fresh client. Non-transient errors still rethrow. The same helper already covers the equivalent raw-query path (BIT-32448/32449). ## Tests - `linkStoredSquads` logs at info and returns 0 when the raw query is terminated mid-flight (57P01). - `linkStoredSquads` still rethrows a non-transient raw-query error. - Existing `pg.test.ts` / `service.test.ts` suites pass (23 tests). Paperclip-Issue: BIT-32471
spark added 1 commit 2026-11-18 21:28:05 +00:00
fix(sports): downgrade 57P01 admin-terminated connection in linkStoredSquads to info (BIT-32471)
ci / rust (pull_request) Successful in 4m28s
ci / typescript (pull_request) Successful in 10m0s
b7aa187154
Postgres terminates a pooled client mid-query on restart or
`pg_terminate_backend` (SQLSTATE 57P01); Prisma surfaces the raw-query
failure as P2010 wrapping "terminating connection due to administrator
command". linkStoredSquads runs an unguarded `$queryRaw`, so the rejection
escaped to SportsWorker.fillRegister's catch and logged `warn` ("sports:
register not filled"), paging the error loop for a transient blip.

Wrap the `$queryRaw` (extracted into linkStoredSquadsRows) so an
admin-shutdown is detected via isPostgresAdminShutdown, logged at info, and
returns 0 — fillRegister's loop breaks and the next scheduled tick retries
on a fresh client. Non-transient errors still rethrow. The same helper
already covers the equivalent raw-query path (BIT-32448/32449).

Paperclip-Issue: BIT-32471
spark merged commit 238f4cad1f into main 2026-11-18 21:40:03 +00:00
Sign in to join this conversation.