Kill sessions that sit idle inside a transaction
A connection that ran BEGIN and then went to lunch holds its locks and blocks vacuum from cleaning anything newer than its snapshot. You find out when the table bloats or a migration hangs.
ALTER SYSTEM SET idle_in_transaction_session_timeout = '60s';Sixty seconds is generous for an app. The ORM that opens a transaction per request and forgets to commit on an error path is the usual culprit, and this setting is how you find it.
postgresqloperations