Reopen logfile on SIGHUP

Anastasia Lubennikova <a.lubennikova@postgrespro.ru>

From: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2018-02-27T14:41:38Z
Lists: pgsql-hackers

Attachments

Large percentage of postgres installations, for example PGDG packages 
for Debian/Ubuntu,
assume by default that log management will be handled by extrernals 
tools such as logrotate.

Unfortunately such tools have no way to tell postgres to reopen log file 
after rotation
and forced to use copy-truncate strategy that leads to a loss of log 
messages which is unacceptable.

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().

I hope you will find this feature useful.

-- 
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Commits

  1. Implement "pg_ctl logrotate" command