On a Postgres server I want to limit the amount of time transactions may take before they are aborted.
There are two timeout settings in Postgres that relate to transaction, but I don’t think that they do accomplish what I need:
statement_timeout: Abort any statement that takes more than the specified amount of time.
idle_in_transaction_session_timeout: Terminate any session that has been idle (that is, waiting for a client query) within an open transaction for longer than the specified amount of time.
Do you know if there is a way to to restrict the maximum duration of Postgres transactions?
There is no way to restrict the duration of a transaction. I the practical cases I have dealt with, a combination of the two parameters you quoted did the trick. But there is no way to limit the duration of a transaction that consists of millions of small statements with little idle time in between.