1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

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
This commit is contained in:
Michael Paquier
2024-03-06 14:38:25 +09:00
parent d93627bcbe
commit 08a52ab151
2 changed files with 123 additions and 2 deletions

View File

@ -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. */