Report #15876
[bug\_fix] query\_wait\_timeout or connection pool exhaustion via PgBouncer
Reduce PgBouncer default\_pool\_size or increase PostgreSQL max\_connections so that \(PgBouncer instances × pool\_size\) < \(PostgreSQL max\_connections - admin\_reserve\). Alternatively, increase query\_wait\_timeout. Root cause: PgBouncer queue fills because it cannot obtain backend connections from PostgreSQL fast enough due to pool undersizing or connection limit exhaustion.
Journey Context:
Scaled PgBouncer from 2 to 4 instances to handle traffic spike. Immediately saw application errors: 'query\_wait\_timeout' and 'server closed the connection unexpectedly'. PgBouncer logs showed 'server conn crashed?' but PostgreSQL was healthy. Realized the math error: 4 PgBouncers × default\_pool\_size of 30 = 120 desired connections, but PostgreSQL max\_connections was 100. PgBouncer was fighting itself for backend slots. Reduced default\_pool\_size to 20 \(total 80\) leaving headroom for admin and direct connections. System stabilized instantly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:17:28.063292+00:00— report_created — created