[Pkg-graphite-maint] Bug#733856: graphite-carbon: Logrotate is not working correctly
Pierre Fersing
pierref at pierref.org
Wed Jan 1 12:28:33 UTC 2014
Package: graphite-carbon
Version: 0.9.12-1
Severity: normal
Tags: patch
Current logrotate script use "copytruncate" mode, but carbon-cache do
not behave well with such mode : after rotation logfile will start with
huge hole full of NULL character.
To reproduce, you can:
* install package (tested with 0.9.12-1 on Ubuntu "saucy" 13.10)
* Start graphite-carbon (edit /etc/default/graphite-carbon to enable
startup, start it with /etc/init.d/graphite-carbon)
* Create some message on logfile, example for listener.log, just
open/close a connection on port 2003
* Simulate logrotate action (cp listener.log listener.log.1 && echo -n > listener.log)
* Re-create some message on logfile.
* See that log file start with NULL character
It seems that code support external log rotation if the file is only moved.
>From file lib/carbon/log.py, we can see that if log file no longer
exist it will be re-opened:
> def write(self, data):
> if not self.enableRotation:
> if not exists(self.path):
> self.reopen()
Where self.enableRotation is the carbon's internal log rotation
disabled by Debian packaging.
So a solution could be to disable "copytruncate" in logrotate.
The default mode of logrotate, if I'm not wrong, is to move the file
and no recreating a new file. Thus carbon-cache will detect that
logfile no longer exist and re-open it.
I attached a debdiff with this fix.
-- System Information:
Debian Release: sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 3.11-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
-------------- next part --------------
diff -Nru graphite-carbon-0.9.12/debian/changelog graphite-carbon-0.9.12/debian/changelog
--- graphite-carbon-0.9.12/debian/changelog 2013-09-01 12:29:29.000000000 +0200
+++ graphite-carbon-0.9.12/debian/changelog 2014-01-01 12:58:28.000000000 +0100
@@ -1,3 +1,9 @@
+graphite-carbon (0.9.12-1.1) unstable; urgency=medium
+
+ * Remove "copytruncate" mode of logrotate.
+
+ -- Pierre Fersing <pierref at pierref.org> Wed, 01 Jan 2014 12:57:16 +0100
+
graphite-carbon (0.9.12-1) unstable; urgency=low
* New Upstream Version
diff -Nru graphite-carbon-0.9.12/debian/graphite-carbon.logrotate graphite-carbon-0.9.12/debian/graphite-carbon.logrotate
--- graphite-carbon-0.9.12/debian/graphite-carbon.logrotate 2013-09-01 12:29:29.000000000 +0200
+++ graphite-carbon-0.9.12/debian/graphite-carbon.logrotate 2014-01-01 13:14:44.000000000 +0100
@@ -6,5 +6,4 @@
delaycompress
notifempty
sharedscripts
- copytruncate
}
More information about the Pkg-graphite-maint
mailing list