Bug 735093 - Logrotate doesn't rotate logs if /var/lib/logrotate.status is corrupted
Summary: Logrotate doesn't rotate logs if /var/lib/logrotate.status is corrupted
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: logrotate
Version: 5.7
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: 5.8
Assignee: Jan Kaluža
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks: 743405
TreeView+ depends on / blocked
 
Reported: 2011-09-01 12:43 UTC by Kamal Maiti
Modified: 2018-11-14 10:49 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-03-06 07:26:49 UTC


Attachments (Terms of Use)

Description Kamal Maiti 2011-09-01 12:43:52 UTC
Description of problem:

[root@delmxv1 ~]# which logrotate
/usr/sbin/logrotate
[root@delmxv1 ~]# logrotate /etc/logrotate.conf
error: line 1218 too long in state file /var/lib/logrotate.status
error: could not read state file, will not attempt to write into it

Version-Release number of selected component (if applicable):


How reproducible:
[root@delmxv1 ~]# which logrotate
/usr/sbin/logrotate
[root@delmxv1 ~]# logrotate /etc/logrotate.conf
error: line 1218 too long in state file /var/lib/logrotate.status
error: could not read state file, will not attempt to write into it

Steps to Reproduce:
1. Stated above
2.
3.
  
Actual results:

error: line 1218 too long in state file /var/lib/logrotate.status
error: could not read state file, will not attempt to write into it

Expected results:
No error

Additional info:

Used RHEL 5.7
This appeared for logrotate.x86_64 3.7.4-12

Similar bug: 447022 , but issue is still there on RHEL 5.7. Case#00523837, sfdc

Comment 1 Jan Kaluža 2011-09-05 05:58:02 UTC
The log file should be rotated even with this error. Could you attach /var/lib/logrotate.status (or just the longest line from that) to see what exactly is there? Also, do you know how logrotate.status gets corrupted?

Comment 2 Kamal Maiti 2011-09-05 06:07:08 UTC
Hi Jan,

Thanks for your reply. I agree with you that log file should be rotated even with this error. Here is this line (it looks syntax issue) :

At the line 1218 in /var/lib/logrotate.status, we could see following line :

[kmaiti@kmaiti 00523837]$ cat -n logrotate.status  |grep 1218
  1218	"/u01/h
[kmaiti@kmaiti 00523837]$ cat -n logrotate.status  |grep 1217
  1217	"/u01/home/tomcat/apache-tomcat-5.5.26/logs/xplanner2009-02-15.log" 2010-8-27
[kmaiti@kmaiti 00523837]$

Warm Regards,
/kamal

Comment 3 Jan Kaluža 2011-09-12 11:32:34 UTC
It would be interesting to find out how that corruption happened, but I understand it's probably not doable.

logrotate.c part of this upstream patch can be used to allow rotation even when state file is corrupted: https://fedorahosted.org/logrotate/changeset/254 . It's already in RHEL6/Fedora.

However, it's not possible to do anything with corrupted state file automatically. It has to be checked and fixed manually.

Comment 4 RHEL Product and Program Management 2011-09-23 00:23:24 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated in the
current release, Red Hat is unfortunately unable to address this
request at this time. Red Hat invites you to ask your support
representative to propose this request, if appropriate and relevant,
in the next release of Red Hat Enterprise Linux.

Comment 5 Jan Kaluža 2012-05-11 08:39:09 UTC
I've tried to reproduce it again and log files are rotate properly even with that error for me. Just to clarify it, are you sure log files are not rotated? The error itself can't be fixed automatically.

Comment 7 RHEL Product and Program Management 2012-06-12 01:10:46 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated in the
current release, Red Hat is unfortunately unable to address this
request at this time. Red Hat invites you to ask your support
representative to propose this request, if appropriate and relevant,
in the next release of Red Hat Enterprise Linux.

Comment 8 Jan Kaluža 2013-03-06 07:26:49 UTC
I'm not able to reproduce this bug and reporter is not active anymore. Closing as WORKSFORME.

Comment 9 manoj.kumar.mbm 2016-10-21 09:17:51 UTC
[Problem]
Logrotate failed if logrotate status file got corrupted.
[root]# /usr/sbin/logrotate /etc/logrotate.conf
error: line 92 too long in state file /var/lib/logrotate.status
error: could not read state file, will not attempt to write into it
[Reason] 
logroatet.c check each line of logrotate status file which is terminated with new line,
if it fails it return and exist with error.
while (fgets(buf, sizeof(buf) - 1, f)) {
argv = NULL;
line++;
i = strlen(buf);
if (buf[i - 1] != '\n') {
message(MESS_ERROR, "line %d too long in state file %s\n",
line, stateFilename);
fclose(f);
return 1;
}

/var/lib/logrotate.status contains line number 92 ,
which exist without newline and thus causing this issue.
89 "/var/log/vsftpd.log" 2016-3-18
90 "/var/log/actlog.exports/meminfo" 2016-10-8
91 "/var/log/boot.log" 2016-10-2
92 "/var/log/network/update_swi
[Workaround]
Remove bad line and restart log rotate.

[Reference]
https://github.com/logrotate/logrotate/issues/78 ---->reproduced


Note You need to log in before you can comment on or make changes to this bug.