summaryrefslogtreecommitdiff
path: root/src/backend/replication
diff options
context:
space:
mode:
authorMichael Paquier2024-03-06 05:38:25 +0000
committerMichael Paquier2024-03-06 05:39:40 +0000
commit08a52ab151ca599406883768cdc08b7929e516de (patch)
tree095d96a2772afb6c0a509233ca9b3a416c90dedd /src/backend/replication
parentd93627bcbe5001750e7611f0e637200e2d81dcff (diff)
Add recovery TAP test for race condition with slot invalidations
This commit adds a recovery test to provide coverage for the bug fixed in 818fefd8fd, using an injection point to wait just after the process of an active slot is killed. The trick is to give enough time for effective_xmin and effective_catalog_xmin to advance so as the slot invalidation robustness can be checked since the active process is killed without holding its slot's mutex for a short time. Author: Bertrand Drouvot Discussion: https://postgr.es/m/ZdyZya4YrNapWKqz@ip-10-97-1-34.eu-west-3.compute.internal
Diffstat (limited to 'src/backend/replication')
-rw-r--r--src/backend/replication/slot.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index 2614f98ddd2..02ae27499b5 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -53,6 +53,7 @@
#include "storage/proc.h"
#include "storage/procarray.h"
#include "utils/builtins.h"
+#include "utils/injection_point.h"
/*
* Replication slot on-disk data structure.
@@ -1658,6 +1659,14 @@ InvalidatePossiblyObsoleteSlot(ReplicationSlotInvalidationCause cause,
last_signaled_pid = active_pid;
terminated = true;
conflict_prev = conflict;
+
+ /*
+ * This injection point needs to be after kill() to ensure
+ * that the slot is not "active" anymore. It also has to be
+ * after ReportSlotInvalidation() to ensure that the
+ * invalidation message is logged.
+ */
+ INJECTION_POINT("terminate-process-holding-slot");
}
/* Wait until the slot is released. */