Skip to content

.tip

· one of the small things

Transaction pooling breaks session state, plan for it

In transaction mode PgBouncer hands the connection back after every transaction, so anything that lives on the session disappears: SET without LOCAL, advisory locks held across transactions, LISTEN, and named prepared statements on older versions.

SET LOCAL statement_timeout = '2s';  -- survives pooling
SET statement_timeout = '2s';        -- leaks to the next client

Every session-level feature in your code becomes a bug in transaction mode. Before you switch, grep for SET without LOCAL.

postgresqloperations