heroku-buildpack-pgbouncer icon indicating copy to clipboard operation
heroku-buildpack-pgbouncer copied to clipboard

introduce PGBOUNCER_CONNECT_QUERY parameter to configure connect_query setting

Open igorwwwwwwwwwwwwwwwwwwww opened this issue 7 years ago • 0 comments

TLDR: this is super useful for setting things like statement_timeout on backend connection initiation.

Backstory:

We are running pgbouncer in statement pooling mode. We were setting statement_timeout on connection start in activerecord, to make sure we don't have lingering long-running queries. But for some reason we had a really bad query almost take down the database, so we started to investigate.

Long story short: As soon as pgbouncer re-creates its connections (by default at least once every hour), they do not have statement_timeout (and other session-level props) set.

This patch allows defining a query to execute after pgbouncer creates a new backend connection.