From 92dee4a96dc6e70d7346ecd3f3836a4ff36a7a05 Mon Sep 17 00:00:00 2001
From: Hou Zhijie <houzj.fnst@cn.fujitsu.com>
Date: Thu, 15 Feb 2024 10:48:50 +0800
Subject: [PATCH 1/2] fix BF error take 2

---
 .../t/040_standby_failover_slots_sync.pl        | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

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 9634a50b3e..2b7b4528b5 100644
--- a/src/test/recovery/t/040_standby_failover_slots_sync.pl
+++ b/src/test/recovery/t/040_standby_failover_slots_sync.pl
@@ -223,17 +223,14 @@ is( $standby1->safe_psql(
 $standby1->append_conf('postgresql.conf', 'max_slot_wal_keep_size = -1');
 $standby1->reload;
 
-# Enable the subscription to let it catch up to the latest wal position
-$subscriber1->safe_psql('postgres',
-	"ALTER SUBSCRIPTION regress_mysub1 ENABLE");
+# To ensure that restart_lsn has moved to a recent WAL position, we re-create
+# the subscription and the logical slot.
+$subscriber1->safe_psql(
+	'postgres', qq[
+	DROP SUBSCRIPTION regress_mysub1;
+	CREATE SUBSCRIPTION regress_mysub1 CONNECTION '$publisher_connstr' PUBLICATION regress_mypub WITH (slot_name = lsub1_slot, copy_data = false, failover = true);
+]);
 
-# This wait ensures that confirmed_flush_lsn has been moved to latest
-# position.
-$primary->wait_for_catchup('regress_mysub1');
-
-# To ensure that restart_lsn has moved to a recent WAL position, we need
-# to log XLOG_RUNNING_XACTS and make sure the same is processed as well
-$primary->psql('postgres', "CHECKPOINT");
 $primary->wait_for_catchup('regress_mysub1');
 
 # Do not allow any further advancement of the restart_lsn for the lsub1_slot.
-- 
2.30.0.windows.2

