fix(faces): downgrade 57P01 admin-shutdown poll errors to info (BIT-32450) #270

Merged
spark merged 2 commits from fix/BIT-32450-faces-pg-admin-shutdown into main 2026-11-18 18:14:32 +00:00
Owner

What

A Postgres restart or pg_terminate_backend (error 57P01) kills the pooled client mid-prisma.$queryRaw in FaceWorker.claimWhere (apps/api/src/faces/service.ts:116). Prisma surfaces it as P2010 wrapping the server message terminating connection due to administrator command.

The next tick re-claims a fresh client, so this is a transient blip. It was logged at warn (faces: poll failed), which paged the error loop (BIT-32450). Now it is downgraded to info (faces: poll skipped, db connection was reset) and the loop continues.

How

Reuses the shared isPostgresAdminShutdown helper from apps/api/src/lib/pg.ts (introduced for the autopilot and develop workers in BIT-32448 / BIT-32449) and applies the same info/warn split in the FaceWorker tick catch block.

Stacked on top of fix/BIT-32449-develop-pg-admin-shutdown (which adds lib/pg.ts); once that PR merges, this one auto-collapses to just the faces changes.

Tests

  • isPostgresAdminShutdown matches the real 57P01 raw-query message and rejects unrelated errors.
  • FaceWorker logs a 57P01 shutdown at info (not warn) and keeps looping.
  • A real poll failure still warns.

pnpm --filter @photoreport/api vitest run --config vitest.unit.config.ts src/faces/ → 6 passed.

Paperclip-Issue: BIT-32450
Paperclip-Cluster: b23ce9fba31c

## What A Postgres restart or `pg_terminate_backend` (error 57P01) kills the pooled client mid-`prisma.$queryRaw` in `FaceWorker.claimWhere` (`apps/api/src/faces/service.ts:116`). Prisma surfaces it as `P2010` wrapping the server message `terminating connection due to administrator command`. The next tick re-claims a fresh client, so this is a transient blip. It was logged at `warn` (`faces: poll failed`), which paged the error loop (BIT-32450). Now it is downgraded to `info` (`faces: poll skipped, db connection was reset`) and the loop continues. ## How Reuses the shared `isPostgresAdminShutdown` helper from `apps/api/src/lib/pg.ts` (introduced for the autopilot and develop workers in BIT-32448 / BIT-32449) and applies the same info/warn split in the `FaceWorker` tick catch block. Stacked on top of `fix/BIT-32449-develop-pg-admin-shutdown` (which adds `lib/pg.ts`); once that PR merges, this one auto-collapses to just the faces changes. ## Tests - `isPostgresAdminShutdown` matches the real 57P01 raw-query message and rejects unrelated errors. - `FaceWorker` logs a 57P01 shutdown at `info` (not `warn`) and keeps looping. - A real poll failure still warns. `pnpm --filter @photoreport/api vitest run --config vitest.unit.config.ts src/faces/` → 6 passed. Paperclip-Issue: BIT-32450 Paperclip-Cluster: b23ce9fba31c
spark added 2 commits 2026-11-18 18:04:37 +00:00
fix(develop): downgrade 57P01 admin-shutdown poll errors to info so they stop paging the error loop (BIT-32449)
ci / rust (pull_request) Successful in 3m29s
ci / typescript (pull_request) Successful in 8m31s
4e093af85d
A Postgres restart or `pg_terminate_backend` (error 57P01) takes the render worker's pooled client mid-`$queryRaw` in `DevelopService.claimRenders`. Prisma surfaces it as P2010 wrapping the server message, and the catch in `RenderWorker.start` logged it at warn as "develop: poll failed" — which fed the error loop on every tick during a DB restart. The next tick re-claims a fresh client, so this is a transient blip: detect 57P01 and log at info instead, keeping the warn path for real poll failures. Extract `isPostgresAdminShutdown` into `lib/pg.ts` so develop and autopilot share one definition.

Paperclip-Issue: BIT-32449
Paperclip-Cluster: 8d12f6208533
fix(faces): downgrade 57P01 admin-shutdown poll errors to info so they stop paging the error loop (BIT-32450)
ci / rust (pull_request) Successful in 4m24s
ci / typescript (pull_request) Successful in 9m47s
3f7455ebfa
A Postgres restart or pg_terminate_backend (error 57P01) kills the pooled
client mid-`prisma.` in FaceWorker.claimWhere. Prisma surfaces it
as P2010 wrapping the server message. The next tick re-claims a fresh
client, so this is a transient blip: log it at info and keep looping instead
of warning, which was paging the error loop.

Reuses the shared isPostgresAdminShutdown helper from lib/pg.js (introduced
for the autopilot and develop workers in BIT-32448/BIT-32449).
spark merged commit 444c1e492a into main 2026-11-18 18:14:32 +00:00
Sign in to join this conversation.