A Postgres restart or pg_terminate_backend (error 57P01) kills the autopilot worker's pooled client mid-$queryRaw in AutopilotWorker → decideBursts. Prisma surfaces it as P2010 wrapping the server message, and the tick catch logged it at warn as autopilot: 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 / terminating connection due to administrator command and log at info (autopilot: poll skipped, db connection was reset), keeping the warn path for real poll failures.
Sibling of #267 (BIT-32447), which already guards the realtime pg.Pool idle-client error event.
Evidence
Issue: BIT-32448 (ERRCLUSTER 5019795ae39d)
Location: apps/api/src/autopilot/service.ts:210 (decideBursts raw query), caught in AutopilotWorker.start tick.
Tests
New apps/api/src/autopilot/service.test.ts: isPostgresAdminShutdown matches the Prisma-wrapped 57P01 message and rejects unrelated errors; AutopilotWorker logs 57P01 at info (not warn) and keeps looping, and still warns on a real poll failure.
pnpm --filter @photoreport/api typecheck✅
vitest run src/autopilot → 5 files, 14 tests ✅
## Fix
A Postgres restart or `pg_terminate_backend` (error **57P01**) kills the autopilot worker's pooled client mid-`$queryRaw` in `AutopilotWorker` → `decideBursts`. Prisma surfaces it as `P2010` wrapping the server message, and the tick catch logged it at `warn` as `autopilot: 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` / `terminating connection due to administrator command` and log at `info` (`autopilot: poll skipped, db connection was reset`), keeping the `warn` path for real poll failures.
Sibling of #267 (BIT-32447), which already guards the realtime `pg.Pool` idle-client `error` event.
## Evidence
- Issue: BIT-32448 (ERRCLUSTER `5019795ae39d`)
- Location: `apps/api/src/autopilot/service.ts:210` (`decideBursts` raw query), caught in `AutopilotWorker.start` tick.
## Tests
- New `apps/api/src/autopilot/service.test.ts`: `isPostgresAdminShutdown` matches the Prisma-wrapped 57P01 message and rejects unrelated errors; `AutopilotWorker` logs 57P01 at `info` (not `warn`) and keeps looping, and still `warn`s on a real poll failure.
- `pnpm --filter @photoreport/api typecheck` ✅
- `vitest run src/autopilot` → 5 files, 14 tests ✅
A Postgres restart or `pg_terminate_backend` (error 57P01) takes the autopilot's pooled client mid-`$queryRaw`. Prisma surfaces it as P2010 wrapping the server message, and the catch in `AutopilotWorker.start` logged it at warn as "autopilot: 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.
Paperclip-Issue: BIT-32448
Paperclip-Cluster: 5019795ae39d
spark
merged commit e242c8e45f into main2026-11-18 17:52:28 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fix
A Postgres restart or
pg_terminate_backend(error 57P01) kills the autopilot worker's pooled client mid-$queryRawinAutopilotWorker→decideBursts. Prisma surfaces it asP2010wrapping the server message, and the tick catch logged it atwarnasautopilot: 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/terminating connection due to administrator commandand log atinfo(autopilot: poll skipped, db connection was reset), keeping thewarnpath for real poll failures.Sibling of #267 (BIT-32447), which already guards the realtime
pg.Poolidle-clienterrorevent.Evidence
5019795ae39d)apps/api/src/autopilot/service.ts:210(decideBurstsraw query), caught inAutopilotWorker.starttick.Tests
apps/api/src/autopilot/service.test.ts:isPostgresAdminShutdownmatches the Prisma-wrapped 57P01 message and rejects unrelated errors;AutopilotWorkerlogs 57P01 atinfo(notwarn) and keeps looping, and stillwarns on a real poll failure.pnpm --filter @photoreport/api typecheck✅vitest run src/autopilot→ 5 files, 14 tests ✅