Re: [HACKERS] Clarifying "server starting" messaging in pg_ctl start without --wait
> Making --wait the default may or may not be sensible -- I'm not sure > -- but removing --no-wait is clearly a bad idea, and we shouldn't do > it. The fact that the problems created by removing it might be > solvable doesn't mean that it's a good idea to create them in the > first place. > > > I agree with Robert - pg_ctl is no doubt used in all kinds of scripts that would then have to change. It may make sense to have --wait be the default though - certainly less confusing to new users!
Re: [HACKERS] Clarifying "server starting" messaging in pg_ctl start without --wait
On Fri, Dec 23, 2016 at 7:25 PM, Jim Nasby wrote: > On 12/23/16 6:10 PM, Tom Lane wrote: >> Michael Paquier writes: >>> Is there still a use case for --no-wait in the real world? >> >> Sure. Most system startup scripts aren't going to want to wait. >> If we take it out those people will go back to starting the postmaster >> by hand. > > Presumably they could just background it... since it's not going to be > long-lived it's presumably not that big a deal. Though, seems like many > startup scripts like to make sure what they're starting is actually working. Making --wait the default may or may not be sensible -- I'm not sure -- but removing --no-wait is clearly a bad idea, and we shouldn't do it. The fact that the problems created by removing it might be solvable doesn't mean that it's a good idea to create them in the first place. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Clarifying "server starting" messaging in pg_ctl start without --wait
On 12/23/16 6:10 PM, Tom Lane wrote: Michael Paquier writes: Is there still a use case for --no-wait in the real world? Sure. Most system startup scripts aren't going to want to wait. If we take it out those people will go back to starting the postmaster by hand. Presumably they could just background it... since it's not going to be long-lived it's presumably not that big a deal. Though, seems like many startup scripts like to make sure what they're starting is actually working. What might be interesting is a mode that waited for everything but recovery so at least you know the config is valid, the port is available, etc. That would be much harder to handle externally. -- Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX Experts in Analytics, Data Architecture and PostgreSQL Data in Trouble? Get it in Treble! http://BlueTreble.com 855-TREBLE2 (855-873-2532) -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Clarifying "server starting" messaging in pg_ctl start without --wait
Michael Paquier writes: > Is there still a use case for --no-wait in the real world? Sure. Most system startup scripts aren't going to want to wait. If we take it out those people will go back to starting the postmaster by hand. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Clarifying "server starting" messaging in pg_ctl start without --wait
On Fri, Dec 23, 2016 at 10:47 PM, Peter Eisentraut wrote: > 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. Is there still a use case for --no-wait in the real world? Why not simply ripping it out? -- Michael -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Clarifying "server starting" messaging in pg_ctl start without --wait
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 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 @@ pg_ctl start - -w + -W -t seconds -s -D datadir @@ -60,7 +60,7 @@ pg_ctl restart - -w + -W -t seconds -s -D datadir @@ -91,7 +91,7 @@ pg_ctl promote - -w + -W -t seconds -s -D datadir @@ -117,7 +117,7 @@ d[emand] - -w + -W -t seconds -s -o options @@ -391,17 +391,7 @@ Options Wait for an operation to complete. This is supported for the modes start, stop, restart, promote, -and register. - - - -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 register, and is the default for those modes. @@ -424,6 +414,18 @@ Options Do not wait for an operation to complete. This is the opposite of the option -w. + + +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. + + + +In prior releases of PostgreSQL, this was the default except for +the stop mode. + @@ -593,7 +595,7 @@ Starting the Server To start the server, waiting until the server is accepting connections: -$ pg_ctl -w start +$ pg_ctl start @@ -637,7 +639,7 @@ Restarting the Server To restart the server, waiting for it to shut down and restart: -$ pg_ctl -w restart +$ pg_ctl restart 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
Re: [HACKERS] Clarifying "server starting" messaging in pg_ctl start without --wait
On 12/20/16 3:49 PM, Tom Lane wrote: > Peter Eisentraut writes: >> Maybe the fix is to make --wait the default? > I was wondering about that too ... does anyone remember the rationale > for the current behavior? Probably because that didn't work reliably before pg_ctl learned how to get the right port number and PQping() and such things. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Clarifying "server starting" messaging in pg_ctl start without --wait
On Tue, Dec 20, 2016 at 1:49 PM, Tom Lane wrote: > Peter Eisentraut writes: > > Maybe the fix is to make --wait the default? > > I was wondering about that too ... does anyone remember the rationale > for the current behavior? But the message for the non-wait case seems > like it could stand to be improved independently of that. > Not totally independent. If the default is changed to --wait then the message can be written assuming the user understands what "--no-wait" does; but if the default is left "--no-wait" then cluing the user into the asynchronous behavior and telling them how to get the more expected synchronous behavior would be helpful. David J.
Re: [HACKERS] Clarifying "server starting" messaging in pg_ctl start without --wait
Tom Lane wrote: > Ryan Murphy writes: > > 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) > > That seems annoyingly verbose and nanny-ish. Perhaps we could get the > point across like this: > > $ pg_ctl -D datadir -l logfile start > requested server to start +1, but also +1 to making --wait the default. Extra points if systemd start scripts are broken by the change ;-) -- Álvaro Herrerahttps://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Clarifying "server starting" messaging in pg_ctl start without --wait
Peter Eisentraut writes: > Maybe the fix is to make --wait the default? I was wondering about that too ... does anyone remember the rationale for the current behavior? But the message for the non-wait case seems like it could stand to be improved independently of that. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Clarifying "server starting" messaging in pg_ctl start without --wait
Ryan Murphy writes: > 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) That seems annoyingly verbose and nanny-ish. Perhaps we could get the point across like this: $ pg_ctl -D datadir -l logfile start requested server to start $ regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Clarifying "server starting" messaging in pg_ctl start without --wait
On Tue, Dec 20, 2016 at 03:43:11PM -0500, 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? +1 It's not super useful to have the prompt return while the server is still starting up. Best, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Clarifying "server starting" messaging in pg_ctl start without --wait
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? -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
[HACKERS] Clarifying "server starting" messaging in pg_ctl start without --wait
Hi Postgres Devs, I had a suggestion regarding the output pg_ctl gives when you use it to start the postgres server. At first I was going to write a patch, but then I decided to just ask you guys first to see what you think. I had an issue earlier where I was trying to upgrade my postgres database to a new major version and incidentally a new pg_catalog version, and therefore the new code could no longer run the existing data directory without pg_upgrade or pg_dump (I ended up needing pg_dump). Initially I was very confused because I tried running "pg_ctl -D datadir -l logfile start" like normal, and it just said "server starting", yet the server was not starting. It took me a while to realize that I needed to use the "--wait" / "-w" option to actually wait and test whether the server was really starting, at which point it told me there was a problem and to check the log. 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) What do you guys think? Is it important to keep pg_ctl output more terse than this? I do think something like this could help new users avoid frustration. I'm happy to write a patch for this if it's helpful, though it's such a simple change that if one of the core devs wants this s/he can probably more easily just add it themselves. Cheers, Ryan