From 4dc07be7417bfd6edc98a0f2766308d71d6b1084 Mon Sep 17 00:00:00 2001 From: Andrey Borodin Date: Fri, 13 Nov 2026 11:37:53 +0500 Subject: [PATCH v1 4/4] Do not suppress idle timeout for an inactive transaction timer The idle-in-transaction timeout was skipped when transaction_timeout had a smaller positive value, even if its timer had already been disabled by AbortTransaction. An aborted block could then remain connected without either timeout taking effect. Only skip the idle timeout when the transaction timer is actually active. This preserves the existing behaviour of ending transaction_timeout at AbortTransaction rather than extending it to an aborted SQL block. Back-patch to v17, where transaction_timeout was introduced. Discussion: https://postgr.es/m/19896-555a806fe6352359@postgresql.org --- src/backend/tcop/postgres.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 20327194532..ad61e5bef83 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -4760,7 +4760,8 @@ PostgresMain(const char *dbname, const char *username) /* Start the idle-in-transaction timer */ if (IdleInTransactionSessionTimeout > 0 - && (IdleInTransactionSessionTimeout < TransactionTimeout || TransactionTimeout == 0)) + && (IdleInTransactionSessionTimeout < TransactionTimeout || + !get_timeout_active(TRANSACTION_TIMEOUT))) { idle_in_transaction_timeout_enabled = true; enable_timeout_after(IDLE_IN_TRANSACTION_SESSION_TIMEOUT, @@ -4774,7 +4775,8 @@ PostgresMain(const char *dbname, const char *username) /* Start the idle-in-transaction timer */ if (IdleInTransactionSessionTimeout > 0 - && (IdleInTransactionSessionTimeout < TransactionTimeout || TransactionTimeout == 0)) + && (IdleInTransactionSessionTimeout < TransactionTimeout || + !get_timeout_active(TRANSACTION_TIMEOUT))) { idle_in_transaction_timeout_enabled = true; enable_timeout_after(IDLE_IN_TRANSACTION_SESSION_TIMEOUT, -- 2.50.1 (Apple Git-155)