v24-0018-Address-comments-From-Vignesh-4.patch

application/octet-stream

Filename: v24-0018-Address-comments-From-Vignesh-4.patch
Type: application/octet-stream
Part: 17
Message: RE: speed up a logical replica setup

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v24-0018
Subject: Address comments From Vignesh #4
File+
src/bin/pg_basebackup/t/041_pg_createsubscriber_standby.pl 25 23
From a01ffc85ec9a023d2836463730bdd3bae17a036d Mon Sep 17 00:00:00 2001
From: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Date: Thu, 22 Feb 2024 11:24:49 +0000
Subject: [PATCH v24 18/18] Address comments From Vignesh #4

---
 .../t/041_pg_createsubscriber_standby.pl      | 48 ++++++++++---------
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/src/bin/pg_basebackup/t/041_pg_createsubscriber_standby.pl b/src/bin/pg_basebackup/t/041_pg_createsubscriber_standby.pl
index 06ef05d5e8..2b428a2d5b 100644
--- a/src/bin/pg_basebackup/t/041_pg_createsubscriber_standby.pl
+++ b/src/bin/pg_basebackup/t/041_pg_createsubscriber_standby.pl
@@ -9,7 +9,7 @@ use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
 use Test::More;
 
-# Set up node P as primary
+# Set up node_p as primary
 my $node_p = PostgreSQL::Test::Cluster->new('node_p');
 $node_p->init(allows_streaming => 'logical');
 $node_p->start;
@@ -18,18 +18,16 @@ $node_p->start;
 # Check pg_createsubscriber fails when the target server is not a
 # standby of the source.
 #
-# Set up node F as about-to-fail node. Force it to initialize a new cluster
+# Set up node_f as about-to-fail node. Force it to initialize a new cluster
 # instead of copying a previously initdb'd cluster.
-my $node_f;
-{
-	local $ENV{'INITDB_TEMPLATE'} = undef;
 
-	$node_f = PostgreSQL::Test::Cluster->new('node_f');
-	$node_f->init(allows_streaming => 'logical');
-	$node_f->start;
-}
 
-# Run pg_createsubscriber on about-to-fail node F
+
+my $node_f = PostgreSQL::Test::Cluster->new('node_f');
+$node_f->init(force_initdb => 1, allows_streaming => 'logical');
+$node_f->start;
+
+# Run pg_createsubscriber on about-to-fail node_F
 command_checks_all(
 	[
 		'pg_createsubscriber', '--verbose', '--pgdata', $node_f->data_dir,
@@ -47,7 +45,7 @@ command_checks_all(
 # ------------------------------
 # Check pg_createsubscriber fails when the target server is not running
 #
-# Set up node S as standby linking to node P
+# Set up node_s as standby linking to node_p
 $node_p->backup('backup_1');
 my $node_s = PostgreSQL::Test::Cluster->new('node_s');
 $node_s->init_from_backup($node_p, 'backup_1', has_streaming => 1);
@@ -72,14 +70,14 @@ $node_s->start;
 # Check pg_createsubscriber fails when the target server is a member of
 # the cascading standby.
 #
-# Set up node C as standby linking to node S
+# Set up node_c as standby linking to node_s
 $node_s->backup('backup_2');
 my $node_c = PostgreSQL::Test::Cluster->new('node_c');
 $node_c->init_from_backup($node_s, 'backup_2', has_streaming => 1);
 $node_c->set_standby_mode();
 $node_c->start;
 
-# Run pg_createsubscriber on node C (P -> S -> C)
+# Run pg_createsubscriber on node_c (P -> S -> C)
 command_checks_all(
 	[
 		'pg_createsubscriber', '--verbose', '--pgdata', $node_c->data_dir,
@@ -90,15 +88,15 @@ command_checks_all(
 	1,
 	[qr//],
 	[qr/primary server cannot be in recovery/],
-	'target server must be running');
+	'source server must not be another standby');
 
-# Stop node C
+# Stop node_c
 $node_c->stop;
 
 # ------------------------------
 # Check successful dry-run
 #
-# Dry run mode on node S
+# Dry run mode on node_s
 command_ok(
 	[
 		'pg_createsubscriber', '--verbose',
@@ -109,9 +107,13 @@ command_ok(
 		'--socketdir', $node_s->host,
 		'--database', 'postgres'
 	],
-	'run pg_createsubscriber --dry-run on node S');
+	'run pg_createsubscriber --dry-run on node_s');
+
+# Check if node_s is still running
+command_exit_is([ 'pg_ctl', 'status', '-D', $node_s->data_dir ],
+	0, 'pg_ctl status with server running');
 
-# Check if node S is still a standby
+# Check if node_s is still a standby
 my $result = $node_s->safe_psql('postgres', 'SELECT pg_catalog.pg_is_in_recovery()');
 is($result, 't', 'standby is in recovery');
 
@@ -154,7 +156,7 @@ $node_p->safe_psql('pg2', "CREATE TABLE tbl2 (a text);");
 
 $node_p->wait_for_replay_catchup($node_s);
 
-# Run pg_createsubscriber on node S
+# Run pg_createsubscriber on node_s
 command_ok(
 	[
 		'pg_createsubscriber', '--verbose',
@@ -165,7 +167,7 @@ command_ok(
 		'--database', 'pg1', '--database',
 		'pg2'
 	],
-	'run pg_createsubscriber on node S');
+	'run pg_createsubscriber on node_s');
 
 ok( -d $node_s->data_dir . "/pg_createsubscriber_output.d",
 	"pg_createsubscriber_output.d/ removed after pg_createsubscriber success"
@@ -184,12 +186,12 @@ is($result, qq(0),
 $node_s->{_pid} = undef;
 $node_s->start;
 
-# Confirm two subscriptions has been created
+# Confirm two subscriptions have been created
 $result = $node_s->safe_psql('postgres',
 	"SELECT count(distinct subdbid) FROM pg_subscription WHERE subname ~ '^pg_createsubscriber_';"
 );
 is($result, qq(2),
-	'Subscriptions has been created to all the specified databases'
+	'Subscriptions have been created on all the specified databases'
 );
 
 # Insert rows on P
@@ -203,7 +205,7 @@ $result = $node_s->safe_psql(
 ));
 my @subnames = split("\n", $result);
 
-# Wait subscriber to catch up
+# Wait for subscriber to catch up
 $node_s->wait_for_subscription_sync($node_p, $subnames[0]);
 $node_s->wait_for_subscription_sync($node_p, $subnames[1]);
 
-- 
2.43.0