Tomasz Ostrowski wrote:
The database would get an error on the connection socket only after it tries to read or write to it next time. But it does not try to do this - it's busy counting those quarks until statement_timeout is reached.
It is unfortunate that PostgreSQL does not take into account that the client has disconnected and does not need to process query.
I know only one non-stable utility that can solve your problem:
https://github.com/yandex/odyssey (unfortunately pgbouncer can't do that).