Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4c2eda6

Browse files
committed
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
1 parent a3f349c commit 4c2eda6

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/backend/tcop/postgres.c

+5-7
Original file line numberDiff line numberDiff line change
@@ -3409,45 +3409,43 @@ ProcessInterrupts(void)
34093409
/*
34103410
* If the GUC has been reset to zero, ignore the signal. This is
34113411
* important because the GUC update itself won't disable any pending
3412-
* interrupt.
3412+
* interrupt. We need to unset the flag before the injection point,
3413+
* otherwise we could loop in interrupts checking.
34133414
*/
3415+
IdleInTransactionSessionTimeoutPending = false;
34143416
if (IdleInTransactionSessionTimeout > 0)
34153417
{
34163418
INJECTION_POINT("idle-in-transaction-session-timeout");
34173419
ereport(FATAL,
34183420
(errcode(ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT),
34193421
errmsg("terminating connection due to idle-in-transaction timeout")));
34203422
}
3421-
else
3422-
IdleInTransactionSessionTimeoutPending = false;
34233423
}
34243424

34253425
if (TransactionTimeoutPending)
34263426
{
34273427
/* As above, ignore the signal if the GUC has been reset to zero. */
3428+
TransactionTimeoutPending = false;
34283429
if (TransactionTimeout > 0)
34293430
{
34303431
INJECTION_POINT("transaction-timeout");
34313432
ereport(FATAL,
34323433
(errcode(ERRCODE_TRANSACTION_TIMEOUT),
34333434
errmsg("terminating connection due to transaction timeout")));
34343435
}
3435-
else
3436-
TransactionTimeoutPending = false;
34373436
}
34383437

34393438
if (IdleSessionTimeoutPending)
34403439
{
34413440
/* As above, ignore the signal if the GUC has been reset to zero. */
3441+
IdleSessionTimeoutPending = false;
34423442
if (IdleSessionTimeout > 0)
34433443
{
34443444
INJECTION_POINT("idle-session-timeout");
34453445
ereport(FATAL,
34463446
(errcode(ERRCODE_IDLE_SESSION_TIMEOUT),
34473447
errmsg("terminating connection due to idle-session timeout")));
34483448
}
3449-
else
3450-
IdleSessionTimeoutPending = false;
34513449
}
34523450

34533451
/*

0 commit comments

Comments
 (0)