fix(sports): filter pg client not-queryable as transient (BIT-33527) #327

Merged
spark merged 1 commits from fix/BIT-33527-pg-client-not-queryable-transient into main 2026-12-04 11:32:57 +00:00
Member

Summary

A pooled pg Client that had a connection error (socket closed, server restart, network blip) is marked not-queryable by node-postgres before Prisma's adapter-pg runs the next query on it. The message Client has encountered a connection error and is not queryable has no Prisma error code, so the existing isPrismaConnectionClosed (P1017) check does not catch it. The rejection escapes to the SportsWorker fillRegister and tick catch blocks, logs as warn, and pages the error loop.

The pool discards the dead client and hands out a fresh one on the next attempt, so this is transient — same class as the existing P1017/P2028/57P01 blips.

Changes

  • lib/pg.ts: Add isPgClientNotQueryable helper that matches the raw pg/lib/client.js message.
  • sports/service.ts: Downgrade the error to info in fillRegister and tick catch blocks (same pattern as BIT-32810, BIT-32083).
  • lib/reporter.ts: Add the message to isTransientDatabaseError so any other code path that lets it propagate to a generic log.error is also suppressed (safety-net pattern from BIT-33537 for P2037).
  • Tests: Unit tests for the new helper and the reporter filter.

Paperclip-Issue: BIT-33527

## Summary A pooled `pg` Client that had a connection error (socket closed, server restart, network blip) is marked not-queryable by node-postgres before Prisma's adapter-pg runs the next query on it. The message `Client has encountered a connection error and is not queryable` has no Prisma error code, so the existing `isPrismaConnectionClosed` (P1017) check does not catch it. The rejection escapes to the SportsWorker `fillRegister` and `tick` catch blocks, logs as `warn`, and pages the error loop. The pool discards the dead client and hands out a fresh one on the next attempt, so this is transient — same class as the existing P1017/P2028/57P01 blips. ## Changes - **`lib/pg.ts`**: Add `isPgClientNotQueryable` helper that matches the raw `pg/lib/client.js` message. - **`sports/service.ts`**: Downgrade the error to `info` in `fillRegister` and `tick` catch blocks (same pattern as BIT-32810, BIT-32083). - **`lib/reporter.ts`**: Add the message to `isTransientDatabaseError` so any other code path that lets it propagate to a generic `log.error` is also suppressed (safety-net pattern from BIT-33537 for P2037). - **Tests**: Unit tests for the new helper and the reporter filter. Paperclip-Issue: BIT-33527
jos-alves added 1 commit 2026-12-04 11:20:28 +00:00
fix(sports): filter pg client not-queryable as transient (BIT-33527)
ci / typescript (push) Skipped
ci / rust (push) Skipped
ci / rust (pull_request) Successful in 5m47s
ci / typescript (pull_request) Successful in 11m37s
8d8573e53a
A pooled pg Client that had a connection error (socket closed, server
restart, network blip) is marked not-queryable by node-postgres before
Prisma's adapter-pg runs the next query on it. The message
"Client has encountered a connection error and is not queryable" has no
Prisma error code, so the existing isPrismaConnectionClosed (P1017) check
does not catch it. The rejection escapes to the SportsWorker fillRegister
and tick catch blocks, logs as warn, and pages the error loop.

- Add isPgClientNotQueryable to lib/pg.ts and downgrade the error to info
  in fillRegister and tick (same pattern as BIT-32810, BIT-32083).
- Add the message to isTransientDatabaseError in reporter.ts so any other
  code path that lets it propagate to a generic log.error is also
  suppressed (same safety-net pattern as BIT-33537 for P2037).
- Add unit tests for the new helper and the reporter filter.

Paperclip-Issue: BIT-33527
paperclip-review-bot left a comment
Member

auto-approve: CI success on 8d8573e53a (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success on 8d8573e53ab1 (gitea_auto_approve_open_prs_once.py)
founding-engineer left a comment
Member

auto-approve: CI success on 8d8573e53a (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success on 8d8573e53ab1 (gitea_auto_approve_open_prs_once.py)
devops-engineer left a comment
Member

auto-approve: CI success on 8d8573e53a (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success on 8d8573e53ab1 (gitea_auto_approve_open_prs_once.py)
spark merged commit 85e2f41113 into main 2026-12-04 11:32:57 +00:00
Sign in to join this conversation.