Re: Reopen logfile on SIGHUP
Alexander Korotkov <a.korotkov@postgrespro.ru>
From: Alexander Korotkov <a.korotkov@postgrespro.ru>
To: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: Alexander Kuzmenkov <a.kuzmenkov@postgrespro.ru>, sk@zsrv.org,
Tom Lane <tgl@sss.pgh.pa.us>, Robert Haas <robertmhaas@gmail.com>, Andres Freund <andres@anarazel.de>,
Greg Stark <stark@mit.edu>, Anastasia Lubennikova <a.lubennikova@postgrespro.ru>,
pgsql-hackers <pgsql-hackers@postgresql.org>, Grigory Smolkin <g.smolkin@postgrespro.ru>
Date: 2018-08-28T15:50:31Z
Lists: pgsql-hackers
Attachments
- pg_ctl_logrotate_v6.patch (application/octet-stream) patch v6
On Tue, Aug 21, 2018 at 4:48 AM Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp> wrote: > > At Fri, 10 Aug 2018 15:33:26 +0300, Alexander Kuzmenkov <a.kuzmenkov@postgrespro.ru> wrote in <5142559a-82e6-b3e4-d6ed-8fd2d240c77e@postgrespro.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. 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 commitfest.cputube.org have Windows checking facility now. ------ Alexander Korotkov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company
Commits
-
Implement "pg_ctl logrotate" command
- ec7436993168 12.0 landed