Re: Reopen logfile on SIGHUP

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: a(dot)korotkov(at)postgrespro(dot)ru
Cc: a(dot)kuzmenkov(at)postgrespro(dot)ru, sk(at)zsrv(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us, robertmhaas(at)gmail(dot)com, andres(at)anarazel(dot)de, stark(at)mit(dot)edu, a(dot)lubennikova(at)postgrespro(dot)ru, pgsql-hackers(at)postgresql(dot)org, g(dot)smolkin(at)postgrespro(dot)ru
Subject: Re: Reopen logfile on SIGHUP
Date: 2018-08-29 02:04:34
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

At Tue, 28 Aug 2018 18:50:31 +0300, Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru> wrote in <CAPpHfduqEyyjLXCNx_t7K2ugCDGVW7WLKL+zrfDEd5wzkvmg-w(at)mail(dot)gmail(dot)com>
> On Tue, Aug 21, 2018 at 4:48 AM Kyotaro HORIGUCHI
> <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> wrote:
> >
> > At Fri, 10 Aug 2018 15:33:26 +0300, Alexander Kuzmenkov <a(dot)kuzmenkov(at)postgrespro(dot)ru> wrote in <5142559a-82e6-b3e4-d6ed-8fd2d240c77e(at)postgrespro(dot)ru>
> > > On 08/09/2018 10:33 AM, Kyotaro HORIGUCHI wrote:
> > > >
> > > > - Since I'm not sure unlink is signal-handler safe on all
> > > > supported platforms, I moved unlink() call out of
> > > > checkLogrotateSignal() to SysLoggerMain, just before rotating
> > > > log file.
> > >
> > > Which platforms specifically do you have in mind? unlink() is required
> > > to be async-signal-safe by POSIX.1-2001, which is required by UNIX 03,
> > > and these are rather old.
> >
> > I suspect that something bad can happen on Windows. Another
> > reason for the movement I didn't mention was it is not necesarry
> > to be there. So I applied the principle that a signal handler
> > should be as small and simple as possible. As the result the
> > flow of logrotate signal handling becomes similar to that for
> > promote signal.
> I went through this thread. It started from discussion about changing
> signal handling in syslogger, which has spotted set of problems.
> However, now there is a patch which add new pg_ctl command, which
> issues SIGUSR1 to syslogger. It seems that nobody in the thread
> object against this feature.


> I've revised this patch a bit. It appears to me that only postmaster
> cares about logrotate file, while syslogger just handles SIGUSR1 as it
> did before. So, I've moved code that deletes logrotate file into
> postmaster.c.

As replied to Michael's commnet, I agree to the change.

> Also I found that this new pg_ctl isn't covered with tests at all. So
> I've added very simple tap tests, which ensures that when log file was
> renamed, it reappeared again after pg_ctl logrotate. I wonder how
> that would work on Windows. Thankfully have
> Windows checking facility now.

Thanks for the test. Documentaion and help message looks fine
including the changed ordering. (180 seconds retry may be a bit
too long but I'm fine with it.)


Kyotaro Horiguchi
NTT Open Source Software Center

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-08-29 02:56:58 Re: buildfarm: could not read block 3 in file "base/16384/2662": read only 0 of 8192 bytes
Previous Message Michael Paquier 2018-08-29 01:34:41 Re: BUG #15182: Canceling authentication due to timeout aka Denial of Service Attack