mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-09-21 13:31:42 +00:00
fix: prevent pool exhaustion that caused 4-hour duplicate check stall
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
The pg pool had max=5 connections shared between Prisma operations and advisory locks. With 2 account locks held permanently and hash locks from timed-out (but still running) background work, pool.connect() would block forever — causing the Turnbase.7z stall. - Increase pool max from 5 to 15 for headroom - Add 30s connectionTimeoutMillis so pool.connect() throws instead of hanging forever when the pool is exhausted - On startup, terminate zombie PostgreSQL sessions from previous worker instances that hold stale advisory locks Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,14 @@ import { config } from "../util/config.js";
|
||||
|
||||
const pool = new pg.Pool({
|
||||
connectionString: config.databaseUrl,
|
||||
max: 5,
|
||||
// Pool needs headroom for: 2 account advisory locks (held for entire cycle),
|
||||
// up to 2 concurrent hash locks, plus Prisma operations from both accounts.
|
||||
// Previously max=5 caused pool exhaustion and indefinite hangs.
|
||||
max: 15,
|
||||
// Prevent pool.connect() from blocking forever when pool is exhausted.
|
||||
// Throws an error after 30s so the operation can fail and retry instead of
|
||||
// silently hanging for hours (as happened with the Turnbase.7z stall).
|
||||
connectionTimeoutMillis: 30_000,
|
||||
});
|
||||
|
||||
const adapter = new PrismaPg(pool);
|
||||
|
||||
Reference in New Issue
Block a user