Prepared statement errors in pgBouncer

On-call incidentMedium30 min

Your task

Postgres behind pgBouncer in transaction pooling mode. After moving an app to a serverless platform (lots of short-lived function instances) the app started intermittently failing with 'prepared statement "S_3" does not exist' and occasionally 'no more connections allowed'. The DB itself is lightly loaded. pgBouncer's SHOW POOLS shows cl_active high and sv_active low, with cl_waiting climbing during bursts. Triage and fix.

It covers

  • Leaked connections
  • Transaction pooling
  • Prepared statements