{"schemaVersion":"1.0","canonicalUrl":"https://automationtester.in/failures/database-pool-exhausted","slug":"database-pool-exhausted","title":"Database connection pool exhausted","signature":"Timed out fetching a new connection from the connection pool","frameworks":["CI","Jest","pytest"],"classification":"environment","summary":"Concurrent test work requested more database connections than the configured pool could provide before its timeout.","causes":[{"title":"Each test creates a new client","explanation":"Clients are opened repeatedly and not reused or closed.","diagnostic":"Count client construction and active connections per worker.","fix":"Create one lifecycle-managed client per worker and close it after the suite."},{"title":"Worker concurrency exceeds the database budget","explanation":"Parallel processes multiply each client's pool size.","diagnostic":"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."},{"title":"Transactions or streams leak connections","explanation":"An error path may skip release or rollback.","diagnostic":"Inspect long-running sessions and unclosed transaction paths.","fix":"Use scoped helpers that release in finally blocks."}],"prevention":["Budget connections across workers.","Manage clients at worker scope.","Assert cleanup on failure paths."],"related":["econnrefused-in-ci","test-data-unique-constraint"],"references":[{"label":"Prisma connection pool","url":"https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool"}]}