(unnamed)

text/plain

Filename: (unnamed)
Type: text/plain
Part: 0
Message: Re: Race conditions in 019_replslot_limit.pl
diff --git a/src/test/recovery/t/019_replslot_limit.pl b/src/test/recovery/t/019_replslot_limit.pl
index 4257bd4d35..059003d63a 100644
--- a/src/test/recovery/t/019_replslot_limit.pl
+++ b/src/test/recovery/t/019_replslot_limit.pl
@@ -35,6 +35,11 @@ my $result = $node_primary->safe_psql('postgres',
 );
 is($result, "t|t|t", 'check the state of non-reserved slot is "unknown"');
 
+# re-create reserved replication slot before taking backup
+$node_primary->safe_psql('postgres', q[
+	SELECT pg_drop_replication_slot('rep1');
+	SELECT pg_create_physical_replication_slot('rep1', true);
+]);
 
 # Take backup
 my $backup_name = 'my_backup';
@@ -265,7 +270,7 @@ log_checkpoints = yes
 ));
 $node_primary2->start;
 $node_primary2->safe_psql('postgres',
-	"SELECT pg_create_physical_replication_slot('rep1')");
+	"SELECT pg_create_physical_replication_slot('rep1', true)");
 $backup_name = 'my_backup2';
 $node_primary2->backup($backup_name);
 
@@ -319,7 +324,7 @@ $node_primary3->append_conf(
 	));
 $node_primary3->start;
 $node_primary3->safe_psql('postgres',
-	"SELECT pg_create_physical_replication_slot('rep3')");
+	"SELECT pg_create_physical_replication_slot('rep3', true)");
 # Take backup
 $backup_name = 'my_backup';
 $node_primary3->backup($backup_name);
@@ -327,6 +332,14 @@ $node_primary3->backup($backup_name);
 my $node_standby3 = PostgreSQL::Test::Cluster->new('standby_3');
 $node_standby3->init_from_backup($node_primary3, $backup_name,
 	has_streaming => 1);
+
+# We will check for walsender process just after. Make sure no
+# walsenders will stay sitting.
+$node_primary3->poll_query_until('postgres',
+	"SELECT count(*) = 0 FROM pg_stat_activity WHERE backend_type = 'walsender'",
+	"t")
+  or die "timed out waiting for wealsender to get out";
+
 $node_standby3->append_conf('postgresql.conf', "primary_slot_name = 'rep3'");
 $node_standby3->start;
 $node_primary3->wait_for_catchup($node_standby3);