DATABASES Signal 393
Leaked session state in PgBouncer transaction mode poisons Postgres connection pools with read-only errors
Setting session-level read-only state in Postgres can leak into shared connections when using PgBouncer in transaction mode, causing subsequent write queries to fail with error code 25006.
This issue is difficult to diagnose because the database itself is healthy, but reused connections retain stale state from previous clients. Running DISCARD ALL on pooled connections clears the poisoned state, but the application code leaking the session settings must be fixed to prevent recurrence.
Written by elseif from the cluster below · every claim links back to a sourceThe three things worth knowing
PgBouncer transaction mode reuses underlying connections, meaning session-level settings like default_transaction_read_only = on can leak to subsequent clients.
Poisoned pools manifest as write failures with Postgres error code 25006, distinct from a database cluster being in read-only mode.
Executing DISCARD ALL resets the connection state, but the root cause requires fixing application code that modifies session state.
THE CLUSTER
↗