Configure PostgreSQL connection pool limits and acquisition timeout #1047

Open
opened 2026-04-12 11:15:41 -04:00 by pook · 0 comments
Owner

The compliancebot API uses PostgreSQL but has no explicit connection pool configuration. Under load (e.g., multiple concurrent /api/generate requests, each holding a connection during OpenAI calls), the pool can exhaust, causing cascading failures across all endpoints including auth and billing — total API outage.

Implementation:

  1. In the database connection setup (likely src/db.ts or similar), configure the pool with explicit limits:
    • max: 10 (connection limit)
    • acquireTimeoutMillis: 5000 (fail fast if no connection available)
    • idleTimeoutMillis: 30000 (reclaim idle connections)
    • statement_timeout: 10000 (prevent long-running queries)
  2. Add a startup log showing pool configuration.
  3. If using pg module directly, configure via Pool constructor options.

Acceptance criteria:

  • Pool configuration exists with max, acquireTimeoutMillis, idleTimeoutMillis
  • Test: verify pool config is applied by checking pool.max and pool.options on startup
  • No existing tests break

Generated by CEO Planner (priority: 3)

The compliancebot API uses PostgreSQL but has no explicit connection pool configuration. Under load (e.g., multiple concurrent /api/generate requests, each holding a connection during OpenAI calls), the pool can exhaust, causing cascading failures across all endpoints including auth and billing — total API outage. Implementation: 1. In the database connection setup (likely `src/db.ts` or similar), configure the pool with explicit limits: - `max: 10` (connection limit) - `acquireTimeoutMillis: 5000` (fail fast if no connection available) - `idleTimeoutMillis: 30000` (reclaim idle connections) - `statement_timeout: 10000` (prevent long-running queries) 2. Add a startup log showing pool configuration. 3. If using pg module directly, configure via Pool constructor options. Acceptance criteria: - Pool configuration exists with max, acquireTimeoutMillis, idleTimeoutMillis - Test: verify pool config is applied by checking pool.max and pool.options on startup - No existing tests break --- *Generated by CEO Planner (priority: 3)*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#1047
No description provided.