Give the app role a statement_timeout
One query with a missing index can hold a connection for minutes, and the pool drains behind it. A timeout on the role turns that into an error the app can handle.
ALTER ROLE app SET statement_timeout = '5s';
ALTER ROLE reporting SET statement_timeout = '5min';Separate roles for the app and for reports, each with the limit its work needs. A query that legitimately needs longer sets its own timeout for that one statement.
postgresqloperations