v15-0005-Avoid-stopping-starting-standby-server-in-dry_ru.patch

application/octet-stream

Filename: v15-0005-Avoid-stopping-starting-standby-server-in-dry_ru.patch
Type: application/octet-stream
Part: 4
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 v15-0005
Subject: Avoid stopping/starting standby server in dry_run mode
File+
src/bin/pg_basebackup/pg_createsubscriber.c 17 8
src/bin/pg_basebackup/t/041_pg_createsubscriber_standby.pl 0 4
From 012750083003446dfc4557c5c0739b818341b65a Mon Sep 17 00:00:00 2001
From: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Date: Fri, 2 Feb 2024 09:07:40 +0000
Subject: [PATCH v15 5/6] Avoid stopping/starting standby server in dry_run
 mode

---
 src/bin/pg_basebackup/pg_createsubscriber.c   | 25 +++++++++++++------
 .../t/041_pg_createsubscriber_standby.pl      |  4 ---
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index 9530b11816..fd40ed5317 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -1816,10 +1816,13 @@ main(int argc, char **argv)
 		if (!setup_publisher(dbinfo))
 			exit(1);
 
-		/* Stop the standby server. */
-		pg_log_info("standby is up and running");
-		pg_log_info("stopping the server to start the transformation steps");
-		stop_standby_server(pg_ctl_path, opt.subscriber_dir);
+		if (!dry_run)
+		{
+			/* Stop the standby server. */
+			pg_log_info("standby is up and running");
+			pg_log_info("stopping the server to start the transformation steps");
+			stop_standby_server(pg_ctl_path, opt.subscriber_dir);
+		}
 	}
 	else
 	{
@@ -1879,8 +1882,11 @@ main(int argc, char **argv)
 	/*
 	 * Start subscriber and wait until accepting connections.
 	 */
-	pg_log_info("starting the subscriber");
-	start_standby_server(pg_ctl_path, opt.subscriber_dir, server_start_log);
+	if (!dry_run)
+	{
+		pg_log_info("starting the subscriber");
+		start_standby_server(pg_ctl_path, opt.subscriber_dir, server_start_log);
+	}
 
 	/*
 	 * Waiting the subscriber to be promoted.
@@ -1921,8 +1927,11 @@ main(int argc, char **argv)
 	/*
 	 * Stop the subscriber.
 	 */
-	pg_log_info("stopping the subscriber");
-	stop_standby_server(pg_ctl_path, opt.subscriber_dir);
+	if (!dry_run)
+	{
+		pg_log_info("stopping the subscriber");
+		stop_standby_server(pg_ctl_path, opt.subscriber_dir);
+	}
 
 	/*
 	 * Change system identifier from subscriber.
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 a9d03acc87..a6ba58879f 100644
--- a/src/bin/pg_basebackup/t/041_pg_createsubscriber_standby.pl
+++ b/src/bin/pg_basebackup/t/041_pg_createsubscriber_standby.pl
@@ -73,10 +73,6 @@ command_ok(
 	],
 	'run pg_createsubscriber --dry-run on node S');
 
-# PID sets to undefined because subscriber was stopped behind the scenes.
-# Start subscriber
-$node_s->{_pid} = undef;
-$node_s->start;
 # Check if node S is still a standby
 is($node_s->safe_psql('postgres', 'SELECT pg_is_in_recovery()'),
 	't', 'standby is in recovery');
-- 
2.43.0