repmgrd: always reopen log file after receiving SIGHUP

For whatever reason, since at least repmgr 2.0 the log file was only
ever reopened if a configuration file change took place.

GitHub #485.
This commit is contained in:
Ian Barwick
2018-08-02 10:51:18 +09:00
parent 4f4d20c30b
commit 33dedf4e96
4 changed files with 55 additions and 35 deletions

View File

@@ -15,6 +15,34 @@
See also: <xref linkend="upgrading-repmgr">
</para>
<sect1 id="release-4.1.1">
<title>Release 4.1.1</title>
<para><emphasis>??? ??? ??, 2018</emphasis></para>
<para>
</para>
<sect2>
<title>repmgrd enhancements</title>
<para>
<itemizedlist>
<listitem>
<para>
<application>repmgrd</application>: always reopen the log file after
receiving <literal>SIGHUP</literal>. Previously this only happened if
a configuration file change was detected.
(GitHub #485).
</para>
</listitem>
</itemizedlist>
</para>
</sect2>
</sect1>
<sect1 id="release-4.1.0">
<title>Release 4.1.0</title>
<para><emphasis>Tue July 31, 2018</emphasis></para>

View File

@@ -323,11 +323,16 @@ REPMGRD_ENABLED=no
<secondary>repmgrd</secondary>
</indexterm>
<indexterm>
<primary>repmgrd</primary>
<secondary>log rotation</secondary>
</indexterm>
<title>repmgrd log rotation</title>
<para>
To ensure the current <application>repmgrd</application> logfile
(specified in <filename>repmgr.conf</filename> with the parameter
<option>log_file</option> does not grow indefinitely, configure your
<option>log_file</option>) does not grow indefinitely, configure your
system's <command>logrotate</command> to regularly rotate it.
</para>
<para>
@@ -340,33 +345,12 @@ REPMGRD_ENABLED=no
rotate 52
maxsize 100M
weekly
copytruncate
create 0600 postgres postgres
postrotate
/usr/bin/killall -HUP repmgrd
endscript
}</programlisting>
</para>
<note>
<para>
Currently <application>repmgrd</application> will not reopen the log
file unless the configuration is reloaded via <literal>SIGHUP</literal>
<emphasis>and</emphasis> the configuration changes.
</para>
<para>
Therefore it's recommended to use <literal>copytruncate</literal> when
rotating logs, so that the contents of the existing file are rotated out
by creating a copy, then truncating the original file, which
<application>repmgrd</application> still holds open.
</para>
<para>
Note that any logging data written in the (short) timespan after the existing file
is copied, but before it is truncated, will be lost; see the
<ulink url="https://linux.die.net/man/8/logrotate">logrotate documentation</ulink>.
</para>
<para>
This restriction may be lifted in a future &repmgr; version by providing a
signal which causes <application>repmgrd</application> to reopen the log file,
and which can be sent from <command>logrotate</command> via a <command>postrotate</command>
script.
</para>
</note>
</sect1>
</chapter>