From 86b4d6f4df132da83fc4d754b54eaefe17c303ee Mon Sep 17 00:00:00 2001 From: japinli Date: Sat, 23 Dec 2023 11:04:25 +0800 Subject: [PATCH v21 3/4] Try to enable transaction_timeout before next command --- src/backend/tcop/postgres.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index a2611cf8e6..96161eb7ab 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -4513,6 +4513,11 @@ PostgresMain(const char *dbname, const char *username) enable_timeout_after(IDLE_IN_TRANSACTION_SESSION_TIMEOUT, IdleInTransactionSessionTimeout); } + + /* Schedule or reschedule transaction timeout */ + if (TransactionTimeout > 0 && !get_timeout_active(TRANSACTION_TIMEOUT)) + enable_timeout_after(TRANSACTION_TIMEOUT, + TransactionTimeout); } else if (IsTransactionOrTransactionBlock()) { @@ -4527,6 +4532,11 @@ PostgresMain(const char *dbname, const char *username) enable_timeout_after(IDLE_IN_TRANSACTION_SESSION_TIMEOUT, IdleInTransactionSessionTimeout); } + + /* Schedule or reschedule transaction timeout */ + if (TransactionTimeout > 0 && !get_timeout_active(TRANSACTION_TIMEOUT)) + enable_timeout_after(TRANSACTION_TIMEOUT, + TransactionTimeout); } else { -- 2.37.1 (Apple Git-137.1)