mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-02 17:41:25 +02:00
Fix race condition in transaction timeout TAP tests
The interruption handler within the injection point can get stuck in an infinite loop while handling transaction timeout. To avoid this situation we reset the timeout flag before invoking the injection point. Author: Alexander Korotkov Reviewed-by: Andrey Borodin Discussion: https://postgr.es/m/ZfPchPC6oNN71X2J%40paquier.xyz
This commit is contained in:
parent
a3f349c612
commit
4c2eda67f5
@ -3409,8 +3409,10 @@ ProcessInterrupts(void)
|
|||||||
/*
|
/*
|
||||||
* If the GUC has been reset to zero, ignore the signal. This is
|
* If the GUC has been reset to zero, ignore the signal. This is
|
||||||
* important because the GUC update itself won't disable any pending
|
* important because the GUC update itself won't disable any pending
|
||||||
* interrupt.
|
* interrupt. We need to unset the flag before the injection point,
|
||||||
|
* otherwise we could loop in interrupts checking.
|
||||||
*/
|
*/
|
||||||
|
IdleInTransactionSessionTimeoutPending = false;
|
||||||
if (IdleInTransactionSessionTimeout > 0)
|
if (IdleInTransactionSessionTimeout > 0)
|
||||||
{
|
{
|
||||||
INJECTION_POINT("idle-in-transaction-session-timeout");
|
INJECTION_POINT("idle-in-transaction-session-timeout");
|
||||||
@ -3418,13 +3420,12 @@ ProcessInterrupts(void)
|
|||||||
(errcode(ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT),
|
(errcode(ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT),
|
||||||
errmsg("terminating connection due to idle-in-transaction timeout")));
|
errmsg("terminating connection due to idle-in-transaction timeout")));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
IdleInTransactionSessionTimeoutPending = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TransactionTimeoutPending)
|
if (TransactionTimeoutPending)
|
||||||
{
|
{
|
||||||
/* As above, ignore the signal if the GUC has been reset to zero. */
|
/* As above, ignore the signal if the GUC has been reset to zero. */
|
||||||
|
TransactionTimeoutPending = false;
|
||||||
if (TransactionTimeout > 0)
|
if (TransactionTimeout > 0)
|
||||||
{
|
{
|
||||||
INJECTION_POINT("transaction-timeout");
|
INJECTION_POINT("transaction-timeout");
|
||||||
@ -3432,13 +3433,12 @@ ProcessInterrupts(void)
|
|||||||
(errcode(ERRCODE_TRANSACTION_TIMEOUT),
|
(errcode(ERRCODE_TRANSACTION_TIMEOUT),
|
||||||
errmsg("terminating connection due to transaction timeout")));
|
errmsg("terminating connection due to transaction timeout")));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
TransactionTimeoutPending = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IdleSessionTimeoutPending)
|
if (IdleSessionTimeoutPending)
|
||||||
{
|
{
|
||||||
/* As above, ignore the signal if the GUC has been reset to zero. */
|
/* As above, ignore the signal if the GUC has been reset to zero. */
|
||||||
|
IdleSessionTimeoutPending = false;
|
||||||
if (IdleSessionTimeout > 0)
|
if (IdleSessionTimeout > 0)
|
||||||
{
|
{
|
||||||
INJECTION_POINT("idle-session-timeout");
|
INJECTION_POINT("idle-session-timeout");
|
||||||
@ -3446,8 +3446,6 @@ ProcessInterrupts(void)
|
|||||||
(errcode(ERRCODE_IDLE_SESSION_TIMEOUT),
|
(errcode(ERRCODE_IDLE_SESSION_TIMEOUT),
|
||||||
errmsg("terminating connection due to idle-session timeout")));
|
errmsg("terminating connection due to idle-session timeout")));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
IdleSessionTimeoutPending = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user