A Postgres restart or a downed route makes the database unreachable (Prisma P1001: Can't reach database server at <host>:<port>) mid-rematch, inside eventForName's findUnique (apps/api/src/archive/service.ts:857). The per-folder catch logged it at warn, which paged the error loop for a transient blip — and every remaining folder in the batch would fail the same way, producing redundant failing queries.
Fix
Add isPrismaServerUnreachable(err) to lib/pg.ts (detects P1001 / Can't reach database server), next to isPrismaConnectionClosed / isPostgresAdminShutdown from BIT-32448/32460.
In ArchiveService.rematch, when a folder fails with P1001, log at info and break out of the folder loop — the next verifyAll (on start, every six hours) retries once the server is back.
Reuses the same downgrade-to-info pattern as the faces/develop/autopilot workers (BIT-32448/32449/32450).
src/archive/service.test.ts: rematch logs at info and stops the batch on P1001 (second folder never queried); still warns on a real per-folder error.
Full unit suite: 43 files, 149 passed, 3 skipped. pnpm typecheck clean.
Paperclip-Issue: BIT-32462
## What
A Postgres restart or a downed route makes the database unreachable (Prisma `P1001`: `Can't reach database server at <host>:<port>`) mid-`rematch`, inside `eventForName`'s `findUnique` (`apps/api/src/archive/service.ts:857`). The per-folder catch logged it at `warn`, which paged the error loop for a transient blip — and every remaining folder in the batch would fail the same way, producing redundant failing queries.
## Fix
- Add `isPrismaServerUnreachable(err)` to `lib/pg.ts` (detects `P1001` / `Can't reach database server`), next to `isPrismaConnectionClosed` / `isPostgresAdminShutdown` from BIT-32448/32460.
- In `ArchiveService.rematch`, when a folder fails with P1001, log at `info` and `break` out of the folder loop — the next `verifyAll` (on start, every six hours) retries once the server is back.
- Reuses the same downgrade-to-info pattern as the faces/develop/autopilot workers (BIT-32448/32449/32450).
## Tests
- `src/lib/pg.test.ts`: `isPrismaServerUnreachable` matches P1001, rejects P1017/57P01/other.
- `src/archive/service.test.ts`: `rematch` logs at info and stops the batch on P1001 (second folder never queried); still warns on a real per-folder error.
- Full unit suite: 43 files, 149 passed, 3 skipped. `pnpm typecheck` clean.
Paperclip-Issue: BIT-32462
A Postgres restart or a downed route makes the database unreachable
(Prisma P1001: "Can't reach database server at <host>:<port>") mid-rematch,
inside eventForName's findUnique. The per-folder catch logged it at warn,
which paged the error loop for a transient blip — and every remaining folder
in the batch would fail the same way, producing redundant failing queries.
Detect P1001 with a shared isPrismaServerUnreachable helper (lib/pg.js, next
to isPrismaConnectionClosed/isPostgresAdminShutdown from BIT-32448/32460),
log it at info and break out of the folder loop. The next verifyAll (on
start, every six hours) retries once the server is back. Reuses the same
downgrade-to-info pattern as the faces/develop/autopilot workers (BIT-32448/
32449/32450).
Paperclip-Issue: BIT-32462
spark
merged commit f43be9f978 into main2026-11-18 20:31:57 +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.
What
A Postgres restart or a downed route makes the database unreachable (Prisma
P1001:Can't reach database server at <host>:<port>) mid-rematch, insideeventForName'sfindUnique(apps/api/src/archive/service.ts:857). The per-folder catch logged it atwarn, which paged the error loop for a transient blip — and every remaining folder in the batch would fail the same way, producing redundant failing queries.Fix
isPrismaServerUnreachable(err)tolib/pg.ts(detectsP1001/Can't reach database server), next toisPrismaConnectionClosed/isPostgresAdminShutdownfrom BIT-32448/32460.ArchiveService.rematch, when a folder fails with P1001, log atinfoandbreakout of the folder loop — the nextverifyAll(on start, every six hours) retries once the server is back.Tests
src/lib/pg.test.ts:isPrismaServerUnreachablematches P1001, rejects P1017/57P01/other.src/archive/service.test.ts:rematchlogs at info and stops the batch on P1001 (second folder never queried); still warns on a real per-folder error.pnpm typecheckclean.Paperclip-Issue: BIT-32462