fix(develop): downgrade 57P01 admin-shutdown poll errors to info (BIT-32449) #269

Merged
spark merged 1 commits from fix/BIT-32449-develop-pg-admin-shutdown into main 2026-11-18 18:26:39 +00:00
Owner

What

A Postgres restart or pg_terminate_backend (error 57P01) takes the render worker's pooled client mid-$queryRaw in DevelopService.claimRenders (apps/api/src/develop/service.ts:144). 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. Mirror the BIT-32448 autopilot fix: detect 57P01 and log at info (develop: poll skipped, db connection was reset), keeping the warn path for real poll failures.

Extract isPostgresAdminShutdown into apps/api/src/lib/pg.ts so develop and autopilot share one definition; autopilot/service.ts re-exports it to keep its existing test imports working.

Tests

New apps/api/src/develop/service.test.ts mirrors the autopilot tests:

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

pnpm -r build and pnpm -r typecheck green. Unit tests run locally with a no-DB vitest config (the API global-setup needs a *_test database, which CI provides via the pgvector service).

Paperclip-Issue: BIT-32449
Paperclip-Cluster: 8d12f6208533

## What A Postgres restart or `pg_terminate_backend` (error 57P01) takes the render worker's pooled client mid-`$queryRaw` in `DevelopService.claimRenders` (`apps/api/src/develop/service.ts:144`). 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. Mirror the BIT-32448 autopilot fix: detect 57P01 and log at `info` (`develop: poll skipped, db connection was reset`), keeping the `warn` path for real poll failures. Extract `isPostgresAdminShutdown` into `apps/api/src/lib/pg.ts` so `develop` and `autopilot` share one definition; `autopilot/service.ts` re-exports it to keep its existing test imports working. ## Tests New `apps/api/src/develop/service.test.ts` mirrors the autopilot tests: - `isPostgresAdminShutdown` matches the 57P01 raw-query message and rejects unrelated errors - `RenderWorker` logs a 57P01 shutdown at `info` (not `warn`) and keeps looping - `RenderWorker` still warns on a real poll failure `pnpm -r build` and `pnpm -r typecheck` green. Unit tests run locally with a no-DB vitest config (the API global-setup needs a `*_test` database, which CI provides via the pgvector service). Paperclip-Issue: BIT-32449 Paperclip-Cluster: 8d12f6208533
spark added 1 commit 2026-11-18 18:00:30 +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
spark added 1 commit 2026-11-18 18:15:23 +00:00
Merge branch 'main' into fix/BIT-32449-develop-pg-admin-shutdown
ci / rust (pull_request) Successful in 4m11s
ci / typescript (pull_request) Successful in 8m53s
99eb18aadb
spark merged commit 902ebda6fb into main 2026-11-18 18:26:39 +00:00
Sign in to join this conversation.