Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit05cd12e

Browse files
committed
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, somake that the default.Remove the -w option in most example and test code, so avoid confusionand reduce verbosity. pg_upgrade is not touched, so it can continue towork with older installations.Reviewed-by: Beena Emerson <memissemerson@gmail.com>Reviewed-by: Ryan Murphy <ryanfmurphy@gmail.com>
1 parente574f15 commit05cd12e

File tree

10 files changed

+49
-61
lines changed

10 files changed

+49
-61
lines changed

‎contrib/start-scripts/freebsd

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ PGLOG="$PGDATA/serverlog"
2828
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
2929

3030
# What to use to start up the postmaster. (If you want the script to wait
31-
# until the server has started, you could use "pg_ctl start -w" here.
32-
# But without -w, pg_ctl adds no value.)
31+
# until the server has started, you could use "pg_ctl start" here.)
3332
DAEMON="$prefix/bin/postmaster"
3433

3534
# What to use to shut down the postmaster
@@ -51,7 +50,7 @@ case $1 in
5150
su -l$PGUSER -c"$PGCTL stop -D '$PGDATA' -s"
5251
;;
5352
restart)
54-
su -l$PGUSER -c"$PGCTL stop -D '$PGDATA' -s -w"
53+
su -l$PGUSER -c"$PGCTL stop -D '$PGDATA' -s"
5554
su -l$PGUSER -c"$DAEMON -D '$PGDATA' &">>$PGLOG2>&1
5655
;;
5756
status)

‎contrib/start-scripts/linux

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ PGLOG="$PGDATA/serverlog"
6060
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
6161

6262
# What to use to start up the postmaster. (If you want the script to wait
63-
# until the server has started, you could use "pg_ctl start -w" here.
64-
# But without -w, pg_ctl adds no value.)
63+
# until the server has started, you could use "pg_ctl start" here.)
6564
DAEMON="$prefix/bin/postmaster"
6665

6766
# What to use to shut down the postmaster
@@ -102,7 +101,7 @@ case $1 in
102101
;;
103102
restart)
104103
echo -n"Restarting PostgreSQL:"
105-
su -$PGUSER -c"$PGCTL stop -D '$PGDATA' -s -w"
104+
su -$PGUSER -c"$PGCTL stop -D '$PGDATA' -s"
106105
test -e"$PG_OOM_ADJUST_FILE"&&echo"$PG_MASTER_OOM_SCORE_ADJ">"$PG_OOM_ADJUST_FILE"
107106
su -$PGUSER -c"$DAEMON_ENV$DAEMON -D '$PGDATA' &">>$PGLOG2>&1
108107
echo"ok"

‎contrib/start-scripts/osx/PostgreSQL

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ ROTATESEC="604800"
6565
PATH="$prefix/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
6666

6767
# What to use to start up the postmaster. (If you want the script to wait
68-
# until the server has started, you could use "pg_ctl start -w" here.
69-
# But without -w, pg_ctl adds no value.)
68+
# until the server has started, you could use "pg_ctl start" here.)
7069
DAEMON="$prefix/bin/postmaster"
7170

7271
# What to use to shut down the postmaster

‎doc/src/sgml/ref/pg_ctl-ref.sgml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ PostgreSQL documentation
3131
<cmdsynopsis>
3232
<command>pg_ctl</command>
3333
<arg choice="plain"><option>start</option></arg>
34-
<arg choice="opt"><option>-w</option></arg>
34+
<arg choice="opt"><option>-W</option></arg>
3535
<arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg>
3636
<arg choice="opt"><option>-s</option></arg>
3737
<arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
@@ -60,7 +60,7 @@ PostgreSQL documentation
6060
<cmdsynopsis>
6161
<command>pg_ctl</command>
6262
<arg choice="plain"><option>restart</option></arg>
63-
<arg choice="opt"><option>-w</option></arg>
63+
<arg choice="opt"><option>-W</option></arg>
6464
<arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg>
6565
<arg choice="opt"><option>-s</option></arg>
6666
<arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
@@ -91,7 +91,7 @@ PostgreSQL documentation
9191
<cmdsynopsis>
9292
<command>pg_ctl</command>
9393
<arg choice="plain"><option>promote</option></arg>
94-
<arg choice="opt"><option>-w</option></arg>
94+
<arg choice="opt"><option>-W</option></arg>
9595
<arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg>
9696
<arg choice="opt"><option>-s</option></arg>
9797
<arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
@@ -117,7 +117,7 @@ PostgreSQL documentation
117117
<arg choice="plain"><option>d[emand]</option></arg>
118118
</group>
119119
</arg>
120-
<arg choice="opt"><option>-w</option></arg>
120+
<arg choice="opt"><option>-W</option></arg>
121121
<arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg>
122122
<arg choice="opt"><option>-s</option></arg>
123123
<arg choice="opt"><option>-o</option> <replaceable>options</replaceable></arg>
@@ -391,17 +391,7 @@ PostgreSQL documentation
391391
Wait for an operation to complete. This is supported for the
392392
modes <literal>start</literal>, <literal>stop</literal>,
393393
<literal>restart</literal>, <literal>promote</literal>,
394-
and <literal>register</literal>.
395-
</para>
396-
397-
<para>
398-
Waiting is the default option for shutdowns, but not startups,
399-
restarts, or promotions. This is mainly for historical reasons; the
400-
waiting option is almost always preferable. If waiting is not
401-
selected, the requested action is triggered, but there is no feedback
402-
about its success. In that case, the server log file or an external
403-
monitoring system would have to be used to check the progress and
404-
success of the operation.
394+
and <literal>register</literal>, and is the default for those modes.
405395
</para>
406396

407397
<para>
@@ -424,6 +414,18 @@ PostgreSQL documentation
424414
Do not wait for an operation to complete. This is the opposite of the
425415
option <option>-w</option>.
426416
</para>
417+
418+
<para>
419+
If waiting is disabled, the requested action is triggered, but there
420+
is no feedback about its success. In that case, the server log file
421+
or an external monitoring system would have to be used to check the
422+
progress and success of the operation.
423+
</para>
424+
425+
<para>
426+
In prior releases of PostgreSQL, this was the default except for
427+
the <literal>stop</literal> mode.
428+
</para>
427429
</listitem>
428430
</varlistentry>
429431

@@ -593,7 +595,7 @@ PostgreSQL documentation
593595
To start the server, waiting until the server is
594596
accepting connections:
595597
<screen>
596-
<prompt>$</prompt> <userinput>pg_ctl-wstart</userinput>
598+
<prompt>$</prompt> <userinput>pg_ctl start</userinput>
597599
</screen>
598600
</para>
599601

@@ -637,7 +639,7 @@ PostgreSQL documentation
637639
To restart the server,
638640
waiting for it to shut down and restart:
639641
<screen>
640-
<prompt>$</prompt> <userinput>pg_ctl-wrestart</userinput>
642+
<prompt>$</prompt> <userinput>pg_ctl restart</userinput>
641643
</screen>
642644
</para>
643645

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ typedef enum
7171

7272
#defineDEFAULT_WAIT60
7373

74-
staticbooldo_wait= false;
75-
staticboolwait_set= false;
74+
staticbooldo_wait= true;
7675
staticintwait_seconds=DEFAULT_WAIT;
7776
staticboolwait_seconds_arg= false;
7877
staticboolsilent_mode= false;
@@ -1959,7 +1958,7 @@ do_help(void)
19591958
printf(_(" -s, --silent only print errors, no informational messages\n"));
19601959
printf(_(" -t, --timeout=SECS seconds to wait when using -w option\n"));
19611960
printf(_(" -V, --version output version information, then exit\n"));
1962-
printf(_(" -w, --wait wait until operation completes\n"));
1961+
printf(_(" -w, --wait wait until operation completes (default)\n"));
19631962
printf(_(" -W, --no-wait do not wait until operation completes\n"));
19641963
printf(_(" -?, --help show this help, then exit\n"));
19651964
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)
23232322
break;
23242323
case'w':
23252324
do_wait= true;
2326-
wait_set= true;
23272325
break;
23282326
case'W':
23292327
do_wait= false;
2330-
wait_set= true;
23312328
break;
23322329
case'c':
23332330
allow_core_files= true;
@@ -2423,14 +2420,6 @@ main(int argc, char **argv)
24232420
exit(1);
24242421
}
24252422

2426-
if (!wait_set)
2427-
{
2428-
if (ctl_command==STOP_COMMAND)
2429-
do_wait= true;
2430-
else
2431-
do_wait= false;
2432-
}
2433-
24342423
if (ctl_command==RELOAD_COMMAND)
24352424
{
24362425
sig=SIGHUP;

‎src/bin/pg_ctl/t/001_start_stop.pl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,24 @@
3232
print CONF"listen_addresses = '127.0.0.1'\n";
3333
}
3434
close CONF;
35-
command_ok(['pg_ctl','start','-D',"$tempdir/data",'-w' ],
36-
'pg_ctl start -w');
35+
command_ok(['pg_ctl','start','-D',"$tempdir/data" ],
36+
'pg_ctl start');
3737

3838
# sleep here is because Windows builds can't check postmaster.pid exactly,
3939
# so they may mistake a pre-existing postmaster.pid for one created by the
4040
# postmaster they start. Waiting more than the 2 seconds slop time allowed
4141
# by test_postmaster_connection prevents that mistake.
4242
sleep 3if ($windows_os);
43-
command_fails(['pg_ctl','start','-D',"$tempdir/data",'-w' ],
44-
'second pg_ctl start-wfails');
45-
command_ok(['pg_ctl','stop','-D',"$tempdir/data",'-w' ],
46-
'pg_ctl stop -w');
47-
command_fails(['pg_ctl','stop','-D',"$tempdir/data",'-w' ],
43+
command_fails(['pg_ctl','start','-D',"$tempdir/data" ],
44+
'second pg_ctl start fails');
45+
command_ok(['pg_ctl','stop','-D',"$tempdir/data" ],
46+
'pg_ctl stop');
47+
command_fails(['pg_ctl','stop','-D',"$tempdir/data" ],
4848
'second pg_ctl stop fails');
4949

50-
command_ok(['pg_ctl','restart','-D',"$tempdir/data",'-w' ],
50+
command_ok(['pg_ctl','restart','-D',"$tempdir/data" ],
5151
'pg_ctl restart with server not running');
52-
command_ok(['pg_ctl','restart','-D',"$tempdir/data",'-w' ],
52+
command_ok(['pg_ctl','restart','-D',"$tempdir/data" ],
5353
'pg_ctl restart with server running');
5454

5555
system_or_bail'pg_ctl','stop','-D',"$tempdir/data";

‎src/bin/pg_ctl/t/003_promote.pl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@
3232
is($node_standby->safe_psql('postgres','SELECT pg_is_in_recovery()'),
3333
't','standby is in recovery');
3434

35-
command_ok(['pg_ctl','-D',$node_standby->data_dir,'promote' ],
36-
'pg_ctl promote of standby runs');
35+
command_ok(['pg_ctl','-D',$node_standby->data_dir,'-W','promote' ],
36+
'pg_ctl-Wpromote of standby runs');
3737

3838
ok($node_standby->poll_query_until('postgres','SELECT NOT pg_is_in_recovery()'),
3939
'promoted standby is not in recovery');
4040

41-
# same again with wait option
41+
# same again withdefaultwait option
4242
$node_standby = get_new_node('standby2');
4343
$node_standby->init_from_backup($node_primary,'my_backup',has_streaming=> 1);
4444
$node_standby->start;
4545

4646
is($node_standby->safe_psql('postgres','SELECT pg_is_in_recovery()'),
4747
't','standby is in recovery');
4848

49-
command_ok(['pg_ctl','-D',$node_standby->data_dir,'-w','promote' ],
50-
'pg_ctl-wpromote of standby runs');
49+
command_ok(['pg_ctl','-D',$node_standby->data_dir,'promote' ],
50+
'pg_ctl promote of standby runs');
5151

5252
# no wait here
5353

‎src/test/modules/commit_ts/t/003_standby_2.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
$master->append_conf('postgresql.conf','track_commit_timestamp = off');
5656
$master->restart;
5757

58-
system_or_bail('pg_ctl','-w','-D',$standby->data_dir,'promote');
58+
system_or_bail('pg_ctl','-D',$standby->data_dir,'promote');
5959
$standby->poll_query_until('postgres',"SELECT pg_is_in_recovery() <> true");
6060

6161
$standby->safe_psql('postgres',"create table t11()");

‎src/test/perl/PostgresNode.pm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ port = $port
632632
633633
=item$node->start()
634634
635-
Wrapper for pg_ctl-wstart
635+
Wrapper for pg_ctl start
636636
637637
Start the node and wait until it is ready to accept connections.
638638
@@ -645,7 +645,7 @@ sub start
645645
my$pgdata =$self->data_dir;
646646
my$name =$self->name;
647647
print("### Starting node\"$name\"\n");
648-
my$ret = TestLib::system_log('pg_ctl','-w','-D',$self->data_dir,'-l',
648+
my$ret = TestLib::system_log('pg_ctl','-D',$self->data_dir,'-l',
649649
$self->logfile,'start');
650650

651651
if ($ret != 0)
@@ -702,7 +702,7 @@ sub reload
702702
703703
=item$node->restart()
704704
705-
Wrapper for pg_ctl-wrestart
705+
Wrapper for pg_ctl restart
706706
707707
=cut
708708

@@ -714,7 +714,7 @@ sub restart
714714
my$logfile =$self->logfile;
715715
my$name =$self->name;
716716
print"### Restarting node\"$name\"\n";
717-
TestLib::system_log('pg_ctl','-D',$pgdata,'-w','-l',$logfile,
717+
TestLib::system_log('pg_ctl','-D',$pgdata,'-l',$logfile,
718718
'restart');
719719
$self->_update_pid;
720720
}
@@ -723,7 +723,7 @@ sub restart
723723
724724
=item$node->promote()
725725
726-
Wrapper for pg_ctl promote -w
726+
Wrapper for pg_ctl promote
727727
728728
=cut
729729

@@ -735,7 +735,7 @@ sub promote
735735
my$logfile =$self->logfile;
736736
my$name =$self->name;
737737
print"### Promoting node\"$name\"\n";
738-
TestLib::system_log('pg_ctl','-D',$pgdata,'-w','-l',$logfile,
738+
TestLib::system_log('pg_ctl','-D',$pgdata,'-l',$logfile,
739739
'promote');
740740
}
741741

‎src/tools/msvc/vcregress.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ sub upgradecheck
448448
print"\nRunning initdb on old cluster\n\n";
449449
standard_initdb()orexit 1;
450450
print"\nStarting old cluster\n\n";
451-
my@args = ('pg_ctl','start','-l',"$logdir/postmaster1.log",'-w');
451+
my@args = ('pg_ctl','start','-l',"$logdir/postmaster1.log");
452452
system(@args) == 0orexit 1;
453453

454454
print"\nCreating databases with names covering most ASCII bytes\n\n";
@@ -475,7 +475,7 @@ sub upgradecheck
475475
$bindir,'-B',$bindir);
476476
system(@args) == 0orexit 1;
477477
print"\nStarting new cluster\n\n";
478-
@args = ('pg_ctl','-l',"$logdir/postmaster2.log",'-w','start');
478+
@args = ('pg_ctl','-l',"$logdir/postmaster2.log",'start');
479479
system(@args) == 0orexit 1;
480480
print"\nSetting up stats on new cluster\n\n";
481481
system(".\\analyze_new_cluster.bat") == 0orexit 1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp