aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2025-02-19 14:52:32 +0530
committerAmit Kapila <akapila@postgresql.org>2025-02-19 15:02:22 +0530
commit8a695d7998be67445b9cd8e67faa684d4e87a40d (patch)
treef948bf20aa283fd53bd8676b1b44b27a88ca9493 /src/backend
parent302cf15759233e654512979286ce1a5c3b36625f (diff)
downloadpostgresql-8a695d7998be67445b9cd8e67faa684d4e87a40d.tar.gz
postgresql-8a695d7998be67445b9cd8e67faa684d4e87a40d.zip
Add a test for commit ac0e33136a using the injection point.
This test uses an injection point to bypass the time overhead caused by the idle_replication_slot_timeout GUC, which has a minimum value of one minute. Author: Hayato Kuroda <kuroda.hayato@fujitsu.com> Author: Nisha Moond <nisha.moond412@gmail.com> Reviewed-by: Peter Smith <smithpb2250@gmail.com> Reviewed-by: Vignesh C <vignesh21@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Discussion: https://postgr.es/m/CALj2ACW4aUe-_uFQOjdWCEN-xXoLGhmvRFnL8SNw_TZ5nJe+aw@mail.gmail.com
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/replication/slot.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index d73c9c2fc32..292407f5149 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -56,6 +56,7 @@
#include "storage/procarray.h"
#include "utils/builtins.h"
#include "utils/guc_hooks.h"
+#include "utils/injection_point.h"
#include "utils/varlena.h"
/*
@@ -1669,16 +1670,31 @@ DetermineSlotInvalidationCause(uint32 possible_causes, ReplicationSlot *s,
{
Assert(now > 0);
- /*
- * Check if the slot needs to be invalidated due to
- * idle_replication_slot_timeout GUC.
- */
- if (CanInvalidateIdleSlot(s) &&
- TimestampDifferenceExceedsSeconds(s->inactive_since, now,
- idle_replication_slot_timeout_mins * SECS_PER_MINUTE))
+ if (CanInvalidateIdleSlot(s))
{
- *inactive_since = s->inactive_since;
- return RS_INVAL_IDLE_TIMEOUT;
+ /*
+ * We simulate the invalidation due to idle_timeout as the minimum
+ * time idle time is one minute which makes tests take a long
+ * time.
+ */
+#ifdef USE_INJECTION_POINTS
+ if (IS_INJECTION_POINT_ATTACHED("slot-timeout-inval"))
+ {
+ *inactive_since = 0; /* since the beginning of time */
+ return RS_INVAL_IDLE_TIMEOUT;
+ }
+#endif
+
+ /*
+ * Check if the slot needs to be invalidated due to
+ * idle_replication_slot_timeout GUC.
+ */
+ if (TimestampDifferenceExceedsSeconds(s->inactive_since, now,
+ idle_replication_slot_timeout_mins * SECS_PER_MINUTE))
+ {
+ *inactive_since = s->inactive_since;
+ return RS_INVAL_IDLE_TIMEOUT;
+ }
}
}