Re: Reopen logfile on SIGHUP - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Reopen logfile on SIGHUP
Date
Msg-id 8839.1519771940@sss.pgh.pa.us
Whole thread Raw
In response to Re: Reopen logfile on SIGHUP  (Greg Stark <stark@mit.edu>)
Responses Re: Reopen logfile on SIGHUP
List pgsql-hackers
Greg Stark <stark@mit.edu> writes:
> On 27 February 2018 at 14:41, Anastasia Lubennikova
> <a.lubennikova@postgrespro.ru> wrote:
>> Small patch in the attachment implements logfile reopeninig on SIGHUP.
>> It only affects the file accessed by logging collector, which name you can
>> check with pg_current_logfile().

> HUP will cause Postgres to reload its config files. That seems like a
> fine time to reopen the log files as well but it would be nice if
> there was also some way to get it to *just* do that and not reload the
> config files.

There's already a pretty substantial amount of logic in syslogger.c
to decide whether to force a rotation if any of the logging collection
parameters changed.  I don't especially like the proposed patch, aside
from its lack of error handling, because it is completely disconnected
from that logic and thus is likely to produce unnecessary thrashing
of the output file.

> I wonder if it would be easiest to just have the syslogger watch for
> some other signal as well (I'm guessing the the syslogger doesn't use
> relcache invalidations so it could reuse USR1 for example). That would
> be a bit inconvenient as the admins would have to find the syslogger
> and deliver the signal directly, rather than through the postmaster
> but it would be pretty easy for them.

It already does treat SIGUSR1 as a log rotation request.  Apparently
the point of this patch is that some people don't find that easy enough
to use, which is fair, because finding out the collector's PID from
outside isn't very easy.

            regards, tom lane


pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Reopen logfile on SIGHUP
Next
From: Tom Kazimiers
Date:
Subject: Re: Unexpected behavior with transition tables in update statementtrigger