Reconsider how Postgres statement_timeout is controlled
The solution to control statement_timeout on the client side (in database.yml) developed in #4560 (closed) doesn't play well with pgBouncer in transaction pool mode.
Discussion (internal), raised by @smcgivern and @igorwwwwwwwwwwwwwwwwwwww: https://gitlab.slack.com/archives/C3NBYFJ6N/p1586949178182600
Changing variables in session (SET ...) is dangerous when connections are done via pgBouncer configured with pool_mode = transaction because pgBouncer may switch Postgres backends between transactions, therefore in the middle of our session we can get another backend, with another statement_timeout setting.
A solution here would be controlling statement_timeout at DB user level: ALTER ROLE gitlab SET statement_timeout TO ....