0001-reproduce-BF-failure-in-040_standby_failover_slots_s.patch
application/octet-stream
Filename: 0001-reproduce-BF-failure-in-040_standby_failover_slots_s.patch
Type: application/octet-stream
Part: 1
Patch
Format: format-patch
Series: patch 0001
Subject: reproduce BF failure in 040_standby_failover_slots_sync
| File | + | − |
|---|---|---|
| src/backend/replication/logical/logical.c | 3 | 0 |
| src/backend/replication/walsender.c | 4 | 0 |
| src/test/recovery/t/040_standby_failover_slots_sync.pl | 26 | 1 |
From fd1c96dcb3d2aeba279c605a8db960c7d0e7a0ad Mon Sep 17 00:00:00 2001
From: Zhijie Hou <houzj.fnst@cn.fujitsu.com>
Date: Tue, 6 May 2025 12:02:17 +0800
Subject: [PATCH] reproduce BF failure in 040_standby_failover_slots_sync
---
src/backend/replication/logical/logical.c | 3 +++
src/backend/replication/walsender.c | 4 +++
.../t/040_standby_failover_slots_sync.pl | 27 ++++++++++++++++++-
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index a8d2e024d34..f7cc4cabd49 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1819,6 +1819,9 @@ LogicalConfirmReceivedLocation(XLogRecPtr lsn)
{
Assert(lsn != InvalidXLogRecPtr);
+ if (lsn < MyReplicationSlot->data.confirmed_flush)
+ elog(LOG, "confirmed_flush move backwards");
+
/* Do an unlocked check for candidate_lsn first. */
if (MyReplicationSlot->candidate_xmin_lsn != InvalidXLogRecPtr ||
MyReplicationSlot->candidate_restart_valid != InvalidXLogRecPtr)
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 9fa8beb6103..c74dea40815 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -95,6 +95,7 @@
#include "utils/ps_status.h"
#include "utils/timeout.h"
#include "utils/timestamp.h"
+#include "utils/injection_point.h"
/* Minimum interval used by walsender for stats flushes, in ms */
#define WALSENDER_STATS_FLUSH_INTERVAL 1000
@@ -2810,6 +2811,9 @@ WalSndLoop(WalSndSendDataCallback send_data)
SyncRepInitConfig();
}
+ if (send_data == XLogSendLogical)
+ INJECTION_POINT("process-replies");
+
/* Check for input from the client */
ProcessRepliesIfAny();
diff --git a/src/test/recovery/t/040_standby_failover_slots_sync.pl b/src/test/recovery/t/040_standby_failover_slots_sync.pl
index 9c8b49e942d..441fd77a157 100644
--- a/src/test/recovery/t/040_standby_failover_slots_sync.pl
+++ b/src/test/recovery/t/040_standby_failover_slots_sync.pl
@@ -841,9 +841,11 @@ $primary->reload;
# option; subsequent tests will verify if it can be correctly replicated to the
# subscriber after committing it on the promoted standby.
##################################################
-
+$standby1->append_conf('postgresql.conf', qq(sync_replication_slots = off));
$standby1->start;
+$standby1->safe_psql('postgres', "SELECT pg_sync_replication_slots();");
+
# Prepare a transaction
$primary->safe_psql(
'postgres', qq[
@@ -865,6 +867,12 @@ $primary->poll_query_until(
"SELECT COUNT(*) FROM pg_catalog.pg_replication_slots WHERE slot_name = 'lsub1_slot' AND active='f'",
1);
+$primary->safe_psql(
+ 'postgres', qq[
+ CREATE EXTENSION injection_points;
+ SELECT injection_points_attach('process-replies', 'wait');
+]);
+
# Set two_phase to true and enable the subscription
$subscriber1->safe_psql(
'postgres', qq[
@@ -872,6 +880,23 @@ $subscriber1->safe_psql(
ALTER SUBSCRIPTION regress_mysub1 ENABLE;
]);
+sleep 1;
+
+$primary->safe_psql('postgres',
+ "SELECT injection_points_wakeup('process-replies');");
+
+$standby1->append_conf('postgresql.conf', qq(sync_replication_slots = on));
+$standby1->reload;
+
+
+sleep 2;
+
+$primary->safe_psql(
+ 'postgres', qq[
+ SELECT injection_points_detach('process-replies');
+ SELECT injection_points_wakeup('process-replies');
+]);
+
$primary->wait_for_catchup('regress_mysub1');
my $two_phase_at = $primary->safe_psql('postgres',
--
2.31.1