diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2017-01-13 12:00:00 -0500 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2017-01-14 09:15:08 -0500 |
commit | 05cd12ed5bc74c853a161c5a138a0cb6f9b0cb8a (patch) | |
tree | a9af278974518bbf8b7c23c98c3a8ee001844c5f /src | |
parent | e574f15d6295b12c03ef8810c00976b65933711a (diff) | |
download | postgresql-05cd12ed5bc74c853a161c5a138a0cb6f9b0cb8a.tar.gz postgresql-05cd12ed5bc74c853a161c5a138a0cb6f9b0cb8a.zip |
pg_ctl: Change default to wait for all actions
The different actions in pg_ctl had different defaults for -w and -W,
mostly for historical reasons. Most users will want the -w behavior, so
make that the default.
Remove the -w option in most example and test code, so avoid confusion
and reduce verbosity. pg_upgrade is not touched, so it can continue to
work with older installations.
Reviewed-by: Beena Emerson <memissemerson@gmail.com>
Reviewed-by: Ryan Murphy <ryanfmurphy@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_ctl/pg_ctl.c | 15 | ||||
-rw-r--r-- | src/bin/pg_ctl/t/001_start_stop.pl | 18 | ||||
-rw-r--r-- | src/bin/pg_ctl/t/003_promote.pl | 10 | ||||
-rw-r--r-- | src/test/modules/commit_ts/t/003_standby_2.pl | 2 | ||||
-rw-r--r-- | src/test/perl/PostgresNode.pm | 12 | ||||
-rw-r--r-- | src/tools/msvc/vcregress.pl | 4 |
6 files changed, 25 insertions, 36 deletions
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index c161b199354..93e58919503 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -71,8 +71,7 @@ typedef enum #define DEFAULT_WAIT 60 -static bool do_wait = false; -static bool wait_set = false; +static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; static bool wait_seconds_arg = false; static bool silent_mode = false; @@ -1959,7 +1958,7 @@ do_help(void) printf(_(" -s, --silent only print errors, no informational messages\n")); printf(_(" -t, --timeout=SECS seconds to wait when using -w option\n")); printf(_(" -V, --version output version information, then exit\n")); - printf(_(" -w, --wait wait until operation completes\n")); + printf(_(" -w, --wait wait until operation completes (default)\n")); printf(_(" -W, --no-wait do not wait until operation completes\n")); printf(_(" -?, --help show this help, then exit\n")); printf(_("(The default is to wait for shutdown, but not for start or restart.)\n\n")); @@ -2323,11 +2322,9 @@ main(int argc, char **argv) break; case 'w': do_wait = true; - wait_set = true; break; case 'W': do_wait = false; - wait_set = true; break; case 'c': allow_core_files = true; @@ -2423,14 +2420,6 @@ main(int argc, char **argv) exit(1); } - if (!wait_set) - { - if (ctl_command == STOP_COMMAND) - do_wait = true; - else - do_wait = false; - } - if (ctl_command == RELOAD_COMMAND) { sig = SIGHUP; diff --git a/src/bin/pg_ctl/t/001_start_stop.pl b/src/bin/pg_ctl/t/001_start_stop.pl index b328f224877..8f16bf97954 100644 --- a/src/bin/pg_ctl/t/001_start_stop.pl +++ b/src/bin/pg_ctl/t/001_start_stop.pl @@ -32,24 +32,24 @@ else print CONF "listen_addresses = '127.0.0.1'\n"; } close CONF; -command_ok([ 'pg_ctl', 'start', '-D', "$tempdir/data", '-w' ], - 'pg_ctl start -w'); +command_ok([ 'pg_ctl', 'start', '-D', "$tempdir/data" ], + 'pg_ctl start'); # sleep here is because Windows builds can't check postmaster.pid exactly, # so they may mistake a pre-existing postmaster.pid for one created by the # postmaster they start. Waiting more than the 2 seconds slop time allowed # by test_postmaster_connection prevents that mistake. sleep 3 if ($windows_os); -command_fails([ 'pg_ctl', 'start', '-D', "$tempdir/data", '-w' ], - 'second pg_ctl start -w fails'); -command_ok([ 'pg_ctl', 'stop', '-D', "$tempdir/data", '-w' ], - 'pg_ctl stop -w'); -command_fails([ 'pg_ctl', 'stop', '-D', "$tempdir/data", '-w' ], +command_fails([ 'pg_ctl', 'start', '-D', "$tempdir/data" ], + 'second pg_ctl start fails'); +command_ok([ 'pg_ctl', 'stop', '-D', "$tempdir/data" ], + 'pg_ctl stop'); +command_fails([ 'pg_ctl', 'stop', '-D', "$tempdir/data" ], 'second pg_ctl stop fails'); -command_ok([ 'pg_ctl', 'restart', '-D', "$tempdir/data", '-w' ], +command_ok([ 'pg_ctl', 'restart', '-D', "$tempdir/data" ], 'pg_ctl restart with server not running'); -command_ok([ 'pg_ctl', 'restart', '-D', "$tempdir/data", '-w' ], +command_ok([ 'pg_ctl', 'restart', '-D', "$tempdir/data" ], 'pg_ctl restart with server running'); system_or_bail 'pg_ctl', 'stop', '-D', "$tempdir/data"; diff --git a/src/bin/pg_ctl/t/003_promote.pl b/src/bin/pg_ctl/t/003_promote.pl index 0b6090b6eb5..7b1df29fa3a 100644 --- a/src/bin/pg_ctl/t/003_promote.pl +++ b/src/bin/pg_ctl/t/003_promote.pl @@ -32,13 +32,13 @@ $node_standby->start; is($node_standby->safe_psql('postgres', 'SELECT pg_is_in_recovery()'), 't', 'standby is in recovery'); -command_ok([ 'pg_ctl', '-D', $node_standby->data_dir, 'promote' ], - 'pg_ctl promote of standby runs'); +command_ok([ 'pg_ctl', '-D', $node_standby->data_dir, '-W', 'promote' ], + 'pg_ctl -W promote of standby runs'); ok($node_standby->poll_query_until('postgres', 'SELECT NOT pg_is_in_recovery()'), 'promoted standby is not in recovery'); -# same again with wait option +# same again with default wait option $node_standby = get_new_node('standby2'); $node_standby->init_from_backup($node_primary, 'my_backup', has_streaming => 1); $node_standby->start; @@ -46,8 +46,8 @@ $node_standby->start; is($node_standby->safe_psql('postgres', 'SELECT pg_is_in_recovery()'), 't', 'standby is in recovery'); -command_ok([ 'pg_ctl', '-D', $node_standby->data_dir, '-w', 'promote' ], - 'pg_ctl -w promote of standby runs'); +command_ok([ 'pg_ctl', '-D', $node_standby->data_dir, 'promote' ], + 'pg_ctl promote of standby runs'); # no wait here diff --git a/src/test/modules/commit_ts/t/003_standby_2.pl b/src/test/modules/commit_ts/t/003_standby_2.pl index d37ff182c4c..043ccb14a5d 100644 --- a/src/test/modules/commit_ts/t/003_standby_2.pl +++ b/src/test/modules/commit_ts/t/003_standby_2.pl @@ -55,7 +55,7 @@ $master->restart; $master->append_conf('postgresql.conf', 'track_commit_timestamp = off'); $master->restart; -system_or_bail('pg_ctl', '-w', '-D', $standby->data_dir, 'promote'); +system_or_bail('pg_ctl', '-D', $standby->data_dir, 'promote'); $standby->poll_query_until('postgres', "SELECT pg_is_in_recovery() <> true"); $standby->safe_psql('postgres', "create table t11()"); diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm index 868492b6152..d8be1bd3e12 100644 --- a/src/test/perl/PostgresNode.pm +++ b/src/test/perl/PostgresNode.pm @@ -632,7 +632,7 @@ port = $port =item $node->start() -Wrapper for pg_ctl -w start +Wrapper for pg_ctl start Start the node and wait until it is ready to accept connections. @@ -645,7 +645,7 @@ sub start my $pgdata = $self->data_dir; my $name = $self->name; print("### Starting node \"$name\"\n"); - my $ret = TestLib::system_log('pg_ctl', '-w', '-D', $self->data_dir, '-l', + my $ret = TestLib::system_log('pg_ctl', '-D', $self->data_dir, '-l', $self->logfile, 'start'); if ($ret != 0) @@ -702,7 +702,7 @@ sub reload =item $node->restart() -Wrapper for pg_ctl -w restart +Wrapper for pg_ctl restart =cut @@ -714,7 +714,7 @@ sub restart my $logfile = $self->logfile; my $name = $self->name; print "### Restarting node \"$name\"\n"; - TestLib::system_log('pg_ctl', '-D', $pgdata, '-w', '-l', $logfile, + TestLib::system_log('pg_ctl', '-D', $pgdata, '-l', $logfile, 'restart'); $self->_update_pid; } @@ -723,7 +723,7 @@ sub restart =item $node->promote() -Wrapper for pg_ctl promote -w +Wrapper for pg_ctl promote =cut @@ -735,7 +735,7 @@ sub promote my $logfile = $self->logfile; my $name = $self->name; print "### Promoting node \"$name\"\n"; - TestLib::system_log('pg_ctl', '-D', $pgdata, '-w', '-l', $logfile, + TestLib::system_log('pg_ctl', '-D', $pgdata, '-l', $logfile, 'promote'); } diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl index f575e400529..f1b9819cd2e 100644 --- a/src/tools/msvc/vcregress.pl +++ b/src/tools/msvc/vcregress.pl @@ -448,7 +448,7 @@ sub upgradecheck print "\nRunning initdb on old cluster\n\n"; standard_initdb() or exit 1; print "\nStarting old cluster\n\n"; - my @args = ('pg_ctl', 'start', '-l', "$logdir/postmaster1.log", '-w'); + my @args = ('pg_ctl', 'start', '-l', "$logdir/postmaster1.log"); system(@args) == 0 or exit 1; print "\nCreating databases with names covering most ASCII bytes\n\n"; @@ -475,7 +475,7 @@ sub upgradecheck $bindir, '-B', $bindir); system(@args) == 0 or exit 1; print "\nStarting new cluster\n\n"; - @args = ('pg_ctl', '-l', "$logdir/postmaster2.log", '-w', 'start'); + @args = ('pg_ctl', '-l', "$logdir/postmaster2.log", 'start'); system(@args) == 0 or exit 1; print "\nSetting up stats on new cluster\n\n"; system(".\\analyze_new_cluster.bat") == 0 or exit 1; |