Transaction pooling breaks session state, plan for it
PgBouncer in transaction mode hands a connection back after every transaction, so anything that lives on the session is gone: SET without LOCAL, advisory locks held across transactions, LISTEN, named prepared statements on older versions.
SET LOCAL statement_timeout = '2s'; -- survives pooling
SET statement_timeout = '2s'; -- leaks to the next clientEvery session-level feature in your code is a bug in transaction mode. Grep for SET without LOCAL before you switch.
postgresqloperations