From ed93abb97f7ce745bbe89b2cc7cce2139e504757 Mon Sep 17 00:00:00 2001
From: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Date: Fri, 7 Aug 2026 15:35:31 +0900
Subject: [PATCH v2] Stablize 019_replslot_limit

---
 src/test/recovery/t/019_replslot_limit.pl | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/test/recovery/t/019_replslot_limit.pl b/src/test/recovery/t/019_replslot_limit.pl
index a412faf51c6..1fe698fcc04 100644
--- a/src/test/recovery/t/019_replslot_limit.pl
+++ b/src/test/recovery/t/019_replslot_limit.pl
@@ -306,8 +306,6 @@ my $node_primary3 = PostgreSQL::Test::Cluster->new('primary3');
 $node_primary3->init(allows_streaming => 1, extra => ['--wal-segsize=1']);
 $node_primary3->append_conf(
 	'postgresql.conf', qq(
-	min_wal_size = 2MB
-	max_wal_size = 2MB
 	log_checkpoints = yes
 	max_slot_wal_keep_size = 1MB
 	));
@@ -374,6 +372,15 @@ $logstart = -s $node_primary3->logfile;
 kill 'STOP', $senderpid, $receiverpid;
 $node_primary3->advance_wal(2);
 
+# Start a psql session to run the checkpoint in the background. It cannot
+# complete while the walsender is stopped.
+my $checkpoint = $node_primary3->background_psql('postgres');
+$checkpoint->query_until(
+    qr/starting_checkpoint/, q(
+	\echo starting_checkpoint
+	CHECKPOINT;
+));
+
 my $msg_logged = 0;
 my $max_attempts = $PostgreSQL::Test::Utils::timeout_default;
 while ($max_attempts-- >= 0)
@@ -397,6 +404,7 @@ $node_primary3->poll_query_until('postgres',
 	"SELECT wal_status FROM pg_replication_slots WHERE slot_name = 'rep3'",
 	"lost")
   or die "timed out waiting for slot to be lost";
+$checkpoint->quit;
 
 $msg_logged = 0;
 $max_attempts = $PostgreSQL::Test::Utils::timeout_default;
-- 
2.52.0

