aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
diff options
context:
space:
mode:
authorAlexander Korotkov <akorotkov@postgresql.org>2024-03-14 13:10:21 +0200
committerAlexander Korotkov <akorotkov@postgresql.org>2024-03-14 13:12:15 +0200
commiteeefd4280f6e5167d70efabb89586b7d38922d95 (patch)
tree25f6bdce86953c94e52b90cc367d15896c966483 /src/backend/tcop/postgres.c
parente85662df44ff47acdf5d2d413339445d60a9c30c (diff)
downloadpostgresql-eeefd4280f6e5167d70efabb89586b7d38922d95.tar.gz
postgresql-eeefd4280f6e5167d70efabb89586b7d38922d95.zip
Add TAP tests for timeouts
This commit adds new tests to verify that transaction_timeout, idle_session_timeout, and idle_in_transaction_session_timeout work as expected. We introduce new injection points in before throwing a timeout FATAL error and check these injection points are reached. Discussion: https://postgr.es/m/CAAhFRxiQsRs2Eq5kCo9nXE3HTugsAAJdSQSmxncivebAxdmBjQ%40mail.gmail.com Author: Andrey Borodin Reviewed-by: Alexander Korotkov
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 6b7903314ab..7ac623019bc 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -72,6 +72,7 @@
#include "tcop/tcopprot.h"
#include "tcop/utility.h"
#include "utils/guc_hooks.h"
+#include "utils/injection_point.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/ps_status.h"
@@ -3411,9 +3412,12 @@ ProcessInterrupts(void)
* interrupt.
*/
if (IdleInTransactionSessionTimeout > 0)
+ {
+ INJECTION_POINT("idle-in-transaction-session-timeout");
ereport(FATAL,
(errcode(ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT),
errmsg("terminating connection due to idle-in-transaction timeout")));
+ }
else
IdleInTransactionSessionTimeoutPending = false;
}
@@ -3422,9 +3426,12 @@ ProcessInterrupts(void)
{
/* As above, ignore the signal if the GUC has been reset to zero. */
if (TransactionTimeout > 0)
+ {
+ INJECTION_POINT("transaction-timeout");
ereport(FATAL,
(errcode(ERRCODE_TRANSACTION_TIMEOUT),
errmsg("terminating connection due to transaction timeout")));
+ }
else
TransactionTimeoutPending = false;
}
@@ -3433,9 +3440,12 @@ ProcessInterrupts(void)
{
/* As above, ignore the signal if the GUC has been reset to zero. */
if (IdleSessionTimeout > 0)
+ {
+ INJECTION_POINT("idle-session-timeout");
ereport(FATAL,
(errcode(ERRCODE_IDLE_SESSION_TIMEOUT),
errmsg("terminating connection due to idle-session timeout")));
+ }
else
IdleSessionTimeoutPending = false;
}