logrotate fails to run, if status file is corrupt (logrotate running during reboot?)

Bug #1385464 reported by Daniel Holbach
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical System Image
Fix Released
High
Unassigned
upstart (Ubuntu)
Fix Released
Undecided
Unassigned
upstart (Ubuntu RTM)
Fix Released
Undecided
Ricardo Salveti

Bug Description

phablet@ubuntu-phablet:~$ du -h /var/log/syslog
654M /var/log/syslog
phablet@ubuntu-phablet:~$ sudo logrotate -f /etc/logrotate.conf
error: bad top line in state file /var/lib/logrotate/status
phablet@ubuntu-phablet:~$ cat /var/lib/logrotate/status
/opt/click.ubuntu.com/com.ubuntu.developer.webapps.webapp-gmail/1.0.25phablet@ubuntu-phablet:~$

Revision history for this message
Daniel Holbach (dholbach) wrote :
tags: added: rtm14
Revision history for this message
James Hunt (jamesodhunt) wrote :

To be clear, this issue was observed on Touch.

Interestingly, we already have a fix for this, but it hasn't landed in the archive or on Tocuh; the upstart session init has a logrotate job (/usr/share/upstart/sessions/logrotate.conf) which is used to rotate the users session init log files. I'd noticed the corruption issue and put a fix in the tip of lp:ubuntu/upstart. Essentially, the solution is to remove the status file as it will be regenerated on next logrotate run. However, if the status file is corrupt, logrotate will never rewrite it and as such, no logrotation occurs leading to unlimited logfile growth.

Here's the fix from the upstart job:

__________

# Sometimes the state file can become corrupt (probably caused by
# logrotate updating it on shutdown). In these cases the file ends in
# nul bytes which causes a subsequent logrotate run (even a forced run)
# to refuse to process it meaning no files get rotated.
#
# Hence, if nul bytes are detected, reset the state file to allow logrotate
# to work.
[ -e "$statefile" ] && egrep '[^[:print:]]' "$statefile" && rm "$statefile"

__________

Olli Ries (ories)
tags: added: touch-2014-10-30
Revision history for this message
Daniel Holbach (dholbach) wrote :

Can we land this soon?

Revision history for this message
James Hunt (jamesodhunt) wrote :

Looks like the corruption issue is caused by bug 1387214.

Changed in canonical-devices-system-image:
importance: Undecided → High
milestone: none → ww05-2015
status: New → Confirmed
Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

 sync ./debian/user-conf/logrotate.conf from lp:ubuntu/upstart to the upstart package used on touch
so ~/.cache/upstart/ shrinks a lot

Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

to get someone assigned, nit sure we will see corrupt files anymore but better to be safe

Changed in logrotate (Ubuntu RTM):
assignee: nobody → Ricardo Salveti (rsalveti)
affects: logrotate (Ubuntu) → upstart (Ubuntu)
Changed in upstart (Ubuntu):
status: New → Fix Released
affects: logrotate (Ubuntu RTM) → upstart (Ubuntu RTM)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package upstart - 1.13.2-0ubuntu1rtm1

---------------
upstart (1.13.2-0ubuntu1rtm1) 14.09; urgency=medium

  [ James Hunt ]
  * debian/user-conf/logrotate.conf: Handle corrupt status files.
    (LP: #1385464)
 -- Ricardo Salveti de Araujo <email address hidden> Fri, 23 Jan 2015 22:53:28 -0200

Changed in upstart (Ubuntu RTM):
status: New → Fix Released
Changed in canonical-devices-system-image:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.