Kill sessions that sit idle inside a transaction
A connection that ran BEGIN and then went to lunch holds its locks, and stops 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 usual culprit is an ORM that opens a transaction per request and forgets to commit on an error path, and this setting is how you catch it.
postgresqloperations