1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-17 17:02:08 +03:00

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
This commit is contained in:
Alexander Korotkov
2024-02-16 03:36:38 +02:00
parent 51efe38cb9
commit bf82f43790
4 changed files with 23 additions and 56 deletions

View File

@ -3647,9 +3647,17 @@ check_log_stats(bool *newval, void **extra, GucSource source)
void
assign_transaction_timeout(int newval, void *extra)
{
if (TransactionTimeout <= 0 &&
get_timeout_active(TRANSACTION_TIMEOUT))
disable_timeout(TRANSACTION_TIMEOUT, false);
if (IsTransactionState())
{
/*
* If transaction_timeout GUC has changes within the transaction block
* enable or disable the timer correspondingly.
*/
if (newval > 0 && !get_timeout_active(TRANSACTION_TIMEOUT))
enable_timeout_after(TRANSACTION_TIMEOUT, newval);
else if (newval <= 0 && get_timeout_active(TRANSACTION_TIMEOUT))
disable_timeout(TRANSACTION_TIMEOUT, false);
}
}
@ -4510,11 +4518,6 @@ 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())
{
@ -4529,11 +4532,6 @@ 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
{
@ -4586,13 +4584,6 @@ PostgresMain(const char *dbname, const char *username)
enable_timeout_after(IDLE_SESSION_TIMEOUT,
IdleSessionTimeout);
}
/*
* If GUC is changed then it's handled in
* assign_transaction_timeout().
*/
if (TransactionTimeout > 0 && get_timeout_active(TRANSACTION_TIMEOUT))
disable_timeout(TRANSACTION_TIMEOUT, false);
}
/* Report any recently-changed GUC options */