Idea: closing the loop for "pg_ctl reload" - Mailing list pgsql-hackers

From Tom Lane
Subject Idea: closing the loop for "pg_ctl reload"
Date
Msg-id 20583.1424395605@sss.pgh.pa.us
Whole thread Raw
Responses Re: Idea: closing the loop for "pg_ctl reload"  (Jan de Visser <jan@de-visser.net>)
Re: Idea: closing the loop for "pg_ctl reload"  (Jan de Visser <jan@de-visser.net>)
Re: Idea: closing the loop for "pg_ctl reload"  (Greg Stark <stark@mit.edu>)
List pgsql-hackers
Bug #12788 reminded me of a problem I think we've discussed before:
if you use "pg_ctl reload" to trigger reload of the postmaster's
config files, and there's something wrong with those files, there's
no warning to you of that.  The postmaster just bleats to its log and
keeps running.  If you don't think to look in the log to confirm
successful reload, you're left with a time bomb: the next attempt
to restart the postmaster will fail altogether because of the bad
config file.

I commented in the bug thread that there wasn't much that pg_ctl
could do about this, but on reflection it seems like something we
could fix, because pg_ctl must be able to read the postmaster.pid
file in order to issue a reload signal.  Consider a design like this:

1. Extend the definition of the postmaster.pid file to add another
line, which will contain the time of the last postmaster configuration
load attempt (might as well be a numeric Unix-style timestamp) and
a boolean indication of whether that attempt succeeded or not.

2. Change pg_ctl so that after sending a reload signal, it sleeps
for a second and checks for a change in the config load timestamp
(repeat as necessary till timeout).  Once it sees the timestamp
change, it's in a position to report success or failure using the
boolean.  I think this should become the default behavior, though
you could define -W to mean that there should be no wait or feedback.

It's tempting to think of storing a whole error message rather than
just a boolean, but I think that would complicate the pidfile definition
undesirably.  A warning to look in the postmaster log ought to be
sufficient here.

For extra credit, the pg_reload_conf() function could be made to behave
similarly.

I don't have the time to pursue this idea myself, but perhaps someone
looking for a not-too-complicated project could take it on.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: Combining Aggregates
Next
From: Alfred Perlstein
Date:
Subject: Question about durability and postgresql.