Using pgBouncer in transaction mode seems to be the optimal way of reducing the number of active connection at any given time, but it's also given rise to a problem that I'm not sure how to solve effectively.
Say you want to have a blanket statement_timeout of 5 mins at the DB level just for the safety of preventing any unexpected super long running queries, but have a bunch of workers that run statements that normally take much longer than that. Without pgBouncer, you could just temporarily set the statement_timeout on the session and set it back to default afterwords and that all works fine. However, with pgBouncer in transaction mode this doesn't work reliably without wrapping the offending operations in a transaction and setting a local statement_timeout. However, that is not desirable either because then you have arbitrarily long running transactions just to achieve the desired timeout settings.
Is there any way to apply local timeouts to statements when using pgBouncer in transaction mode, but without having to use a transaction?