SET transaction_timeout inside a transaction

From: "Quentin de Metz" <quentin(at)de(dot)me(dot)tz>
To: pgsql-novice(at)postgresql(dot)org
Cc: amborodin(at)acm(dot)org, aekorotkov(at)gmail(dot)com, japinli(at)hotmail(dot)com, zhjwpku(at)gmail(dot)com
Subject: SET transaction_timeout inside a transaction
Date: 2025-09-19 20:12:59
Message-ID: 554670a7-7560-4d18-8ecb-8518fddf2b9d@app.fastmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello,

It appears that changing the transaction_timeout when inside a transaction does not work as expected.

Running the following script on master:

SET transaction_timeout = '1s';
BEGIN;
SET transaction_timeout = '3s';
SELECT pg_sleep(2);

Fails with the following:

FATAL: terminating connection due to transaction timeout
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.

A workaround is to "SET transaction_timeout = 0" before each override. But this resets the timer, which may not be aligned with this parameter's intention.

Thank you,
Best regards,

Quentin de Metz

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2025-09-19 20:21:00 Re: SET transaction_timeout inside a transaction
Previous Message TIM CHILD 2025-09-19 16:34:13 Re: Can we lock or expire a ROLE / USER