On 12/20/16 3:43 PM, Peter Eisentraut wrote: > On 12/20/16 3:31 PM, Ryan Murphy wrote: >> I'm concerned some new users may not understand this behavior of pg_ctl, >> so I wanted to suggest that we add some additional messaging after >> "server starting" - something like: >> >> $ pg_ctl -D datadir -l logfile start >> server starting >> (to wait for confirmation that server actually started, try pg_ctl again >> with --wait) > > Maybe the fix is to make --wait the default?
Here is a patch for that. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>From 400c5445381596c1b5b5083a56d130498ade421b Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <pete...@gmx.net> Date: Fri, 23 Dec 2016 12:00:00 -0500 Subject: [PATCH] pg_ctl: Change default to wait for all actions --- doc/src/sgml/ref/pg_ctl-ref.sgml | 36 +++++++++++++++++++----------------- src/bin/pg_ctl/pg_ctl.c | 15 ++------------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/doc/src/sgml/ref/pg_ctl-ref.sgml b/doc/src/sgml/ref/pg_ctl-ref.sgml index 5fb6898699..7587355164 100644 --- a/doc/src/sgml/ref/pg_ctl-ref.sgml +++ b/doc/src/sgml/ref/pg_ctl-ref.sgml @@ -31,7 +31,7 @@ <cmdsynopsis> <command>pg_ctl</command> <arg choice="plain"><option>start</option></arg> - <arg choice="opt"><option>-w</option></arg> + <arg choice="opt"><option>-W</option></arg> <arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg> <arg choice="opt"><option>-s</option></arg> <arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg> @@ -60,7 +60,7 @@ <cmdsynopsis> <command>pg_ctl</command> <arg choice="plain"><option>restart</option></arg> - <arg choice="opt"><option>-w</option></arg> + <arg choice="opt"><option>-W</option></arg> <arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg> <arg choice="opt"><option>-s</option></arg> <arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg> @@ -91,7 +91,7 @@ <cmdsynopsis> <command>pg_ctl</command> <arg choice="plain"><option>promote</option></arg> - <arg choice="opt"><option>-w</option></arg> + <arg choice="opt"><option>-W</option></arg> <arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg> <arg choice="opt"><option>-s</option></arg> <arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg> @@ -117,7 +117,7 @@ <arg choice="plain"><option>d[emand]</option></arg> </group> </arg> - <arg choice="opt"><option>-w</option></arg> + <arg choice="opt"><option>-W</option></arg> <arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg> <arg choice="opt"><option>-s</option></arg> <arg choice="opt"><option>-o</option> <replaceable>options</replaceable></arg> @@ -391,17 +391,7 @@ <title>Options</title> Wait for an operation to complete. This is supported for the modes <literal>start</literal>, <literal>stop</literal>, <literal>restart</literal>, <literal>promote</literal>, - and <literal>register</literal>. - </para> - - <para> - Waiting is the default option for shutdowns, but not startups, - restarts, or promotions. This is mainly for historical reasons; the - waiting option is almost always preferable. If waiting is not - selected, the requested action is triggered, but there is no feedback - about its success. In that case, the server log file or an external - monitoring system would have to be used to check the progress and - success of the operation. + and <literal>register</literal>, and is the default for those modes. </para> <para> @@ -424,6 +414,18 @@ <title>Options</title> Do not wait for an operation to complete. This is the opposite of the option <option>-w</option>. </para> + + <para> + If waiting is disabled, the requested action is triggered, but there + is no feedback about its success. In that case, the server log file + or an external monitoring system would have to be used to check the + progress and success of the operation. + </para> + + <para> + In prior releases of PostgreSQL, this was the default except for + the <literal>stop</literal> mode. + </para> </listitem> </varlistentry> @@ -593,7 +595,7 @@ <title>Starting the Server</title> To start the server, waiting until the server is accepting connections: <screen> -<prompt>$</prompt> <userinput>pg_ctl -w start</userinput> +<prompt>$</prompt> <userinput>pg_ctl start</userinput> </screen> </para> @@ -637,7 +639,7 @@ <title>Restarting the Server</title> To restart the server, waiting for it to shut down and restart: <screen> -<prompt>$</prompt> <userinput>pg_ctl -w restart</userinput> +<prompt>$</prompt> <userinput>pg_ctl restart</userinput> </screen> </para> diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 4b476022c0..91d4e0d080 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; -- 2.11.0
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers