Root cause on CT 264: photoreport-worker hit PM2 max_memory_restart: 2G under archive burst → SIGINT → $disconnect() while in-flight Prisma queries still ran → Cannot use a pool after calling end on the pool (PrismaPgAdapter). Separate from BIT-31177 (realtime NOTIFY pool).
Workers/scanner now async stop() and wait for tick + in-flight work before the DB pool ends.
PM2 worker cap raised to 6G, kill_timeout to 45s (above the 25s drain window).
Test plan
waitUntil behaviour verified via tsx (true / flip / timeout)
pnpm exec tsc -p tsconfig.json --noEmit in apps/api (clean after workspace package build)
After merge/deploy on CT 264: pm2 describe photoreport-worker — restarts should stop climbing every few minutes; stderr should not flood pool-after-end on each SIGINT
Confirm max_memory_restart shows 6G after pm2 startOrReload infra/pm2/api.config.cjs --update-env
## Summary
- Root cause on CT 264: `photoreport-worker` hit PM2 `max_memory_restart: 2G` under archive burst → SIGINT → `$disconnect()` while in-flight Prisma queries still ran → `Cannot use a pool after calling end on the pool` (PrismaPgAdapter). Separate from BIT-31177 (realtime NOTIFY pool).
- Workers/scanner now `async stop()` and wait for tick + in-flight work before the DB pool ends.
- PM2 worker cap raised to `6G`, `kill_timeout` to 45s (above the 25s drain window).
## Test plan
- [x] `waitUntil` behaviour verified via `tsx` (true / flip / timeout)
- [x] `pnpm exec tsc -p tsconfig.json --noEmit` in `apps/api` (clean after workspace package build)
- [ ] After merge/deploy on CT 264: `pm2 describe photoreport-worker` — restarts should stop climbing every few minutes; stderr should not flood pool-after-end on each SIGINT
- [ ] Confirm `max_memory_restart` shows 6G after `pm2 startOrReload infra/pm2/api.config.cjs --update-env`
PM2 max_memory SIGINT was ending the Prisma/pg pool while archive and
delivery jobs still queried it, flooding "Cannot use a pool after calling
end". Await idle on all loop workers before $disconnect, and raise the
worker memory/kill_timeout so burst indexing does not restart every few
minutes.
Paperclip-Agent: David Santos (urlKey founding-engineer; id 0b1fcf92-5fe3-4ac0-9f29-df4ab72f5376)
Paperclip-Issue: BIT-31189
Paperclip-Run: 61448079-9293-4b3b-989d-b5857bf058c1
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.
Summary
photoreport-workerhit PM2max_memory_restart: 2Gunder archive burst → SIGINT →$disconnect()while in-flight Prisma queries still ran →Cannot use a pool after calling end on the pool(PrismaPgAdapter). Separate from BIT-31177 (realtime NOTIFY pool).async stop()and wait for tick + in-flight work before the DB pool ends.6G,kill_timeoutto 45s (above the 25s drain window).Test plan
waitUntilbehaviour verified viatsx(true / flip / timeout)pnpm exec tsc -p tsconfig.json --noEmitinapps/api(clean after workspace package build)pm2 describe photoreport-worker— restarts should stop climbing every few minutes; stderr should not flood pool-after-end on each SIGINTmax_memory_restartshows 6G afterpm2 startOrReload infra/pm2/api.config.cjs --update-envauto-approve: CI success (gitea_auto_approve_open_prs_once.py)
auto-approve: CI success (gitea_auto_approve_open_prs_once.py)
auto-approve: CI success (gitea_auto_approve_open_prs_once.py)