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

From ilmari@ilmari.org (Dagfinn Ilmari Mannsåker)
Subject Re: Reopen logfile on SIGHUP
Date
Msg-id d8jsh9ms8hw.fsf@dalvik.ping.uio.no
Whole thread Raw
In response to Reopen logfile on SIGHUP  (Anastasia Lubennikova <a.lubennikova@postgrespro.ru>)
List pgsql-hackers
Anastasia Lubennikova <a.lubennikova@postgrespro.ru> writes:

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

+1 for the feature, but:

>    syslogFile = logfile_open(last_file_name, "a", false);

This will cause a fatal error if opening the logfile fails for any
reason (even transient errors like ENFILE/EMFILE).  There is already the
logfile_rotate() function that can reopen log files safely based on time
and date limits.  I'd suggest extending that by adding a config option
that controls whether to always reopen the log file on SIGHUP.

- ilmari
-- 
- Twitter seems more influential [than blogs] in the 'gets reported in
  the mainstream press' sense at least.               - Matt McLeod
- That'd be because the content of a tweet is easier to condense down
  to a mainstream media article.                      - Calle Dybedahl


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [HACKERS] path toward faster partition pruning
Next
From: Catalin Iacob
Date:
Subject: Re: prokind column (was Re: [HACKERS] SQL procedures)