diff options
author | Alexander Korotkov <akorotkov@postgresql.org> | 2024-02-16 03:36:38 +0200 |
---|---|---|
committer | Alexander Korotkov <akorotkov@postgresql.org> | 2024-02-16 03:36:38 +0200 |
commit | bf82f43790a675dd1b9522a7799357e61e7aa635 (patch) | |
tree | 07c459ce59aadc3b8157112635c736976685ae20 /src/backend/access/transam/xact.c | |
parent | 51efe38cb92f4b15b68811bcce9ab878fbc71ea5 (diff) | |
download | postgresql-bf82f43790a675dd1b9522a7799357e61e7aa635.tar.gz postgresql-bf82f43790a675dd1b9522a7799357e61e7aa635.zip |
Followup fixes for transaction_timeout
Don't deal with transaction timeout in PostgresMain(). Instead, release
transaction timeout activated by StartTransaction() in
CommitTransaction()/AbortTransaction()/PrepareTransaction(). Deal with both
enabling and disabling transaction timeout in assign_transaction_timeout().
Also, remove potentially flaky timeouts-long isolation test, which has no
guarantees to pass on slow/busy machines.
Reported-by: Andres Freund
Discussion: https://postgr.es/m/20240215230856.pc6k57tqxt7fhldm%40awork3.anarazel.de
Diffstat (limited to 'src/backend/access/transam/xact.c')
-rw-r--r-- | src/backend/access/transam/xact.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index a124ba59330..70ab6e27a13 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -2262,6 +2262,10 @@ CommitTransaction(void) s->state = TRANS_COMMIT; s->parallelModeLevel = 0; + /* Disable transaction timeout */ + if (TransactionTimeout > 0) + disable_timeout(TRANSACTION_TIMEOUT, false); + if (!is_parallel_worker) { /* @@ -2535,6 +2539,10 @@ PrepareTransaction(void) */ s->state = TRANS_PREPARE; + /* Disable transaction timeout */ + if (TransactionTimeout > 0) + disable_timeout(TRANSACTION_TIMEOUT, false); + prepared_at = GetCurrentTimestamp(); /* @@ -2707,6 +2715,10 @@ AbortTransaction(void) /* Prevent cancel/die interrupt while cleaning up */ HOLD_INTERRUPTS(); + /* Disable transaction timeout */ + if (TransactionTimeout > 0) + disable_timeout(TRANSACTION_TIMEOUT, false); + /* Make sure we have a valid memory context and resource owner */ AtAbort_Memory(); AtAbort_ResourceOwner(); |