From 0425bf8936e2f6da9ea8a98697e5483ef701c4e8 Mon Sep 17 00:00:00 2001 From: Hayato Kuroda Date: Fri, 2 Feb 2024 09:07:40 +0000 Subject: [PATCH v16 5/7] 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.34.1