Skip to main content
All failure patterns
Environment or infrastructureCI · Jest · pytest

Database connection pool exhausted

Concurrent test work requested more database connections than the configured pool could provide before its timeout.

RECOGNIZABLE ERROR

Timed out fetching a new connection from the connection pool

RANKED DIAGNOSIS

What usually causes it

  1. 01

    Each test creates a new client

    Clients are opened repeatedly and not reused or closed.

    DIAGNOSE

    Count client construction and active connections per worker.

    FIX

    Create one lifecycle-managed client per worker and close it after the suite.

  2. 02

    Worker concurrency exceeds the database budget

    Parallel processes multiply each client's pool size.

    DIAGNOSE

    Calculate workers multiplied by pool maximum and compare it with the server limit.

    FIX

    Reduce per-worker pool size or test concurrency while preserving isolation.

  3. 03

    Transactions or streams leak connections

    An error path may skip release or rollback.

    DIAGNOSE

    Inspect long-running sessions and unclosed transaction paths.

    FIX

    Use scoped helpers that release in finally blocks.

Prevent the repeat

  • Budget connections across workers.
  • Manage clients at worker scope.
  • Assert cleanup on failure paths.

Primary references

Run this against your evidence

The browser triage workflow uses the same stable pattern slug and does not upload your paste.

Open local triage

Related failure patterns