This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 143 - Problem with reading state file in logrotate coding bug in logrotate
Problem with reading state file in logrotate coding bug in logrotate
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: logrotate (Show other bugs)
5.2
All Linux
low Severity low
: ---
: ---
Assigned To: Cristian Gafton
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1998-11-20 02:03 EST by seth
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 1999-03-18 10:32:53 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description seth 1998-11-20 02:03:01 EST
I ran two logrotates simultaneously as a cron job.

(in abbreviated form)

26 02 * * * logrotate file1
26 02 * * * logrotate file2

(I realize that the idea is to run logrotate once
and then use includes to pull in various files...
but since when did "stupid users" (tm) follow the
intentions of software designers. )

Anyway, I got this error message in the mail:

Subject: Cron <root@pc126> /usr/sbin/logrotate
/etc/logrotate.d/cron

error: bad line 134538360 in state file

Question:  Was this because of a possible file locking
problem with both logrotates trying to read the status
file at the same time?

Bug report:  The relevant piece of the source code
starts on line 687 in the function readState()

  if (sscanf(buf, "%s %d-%d-%d\n", buf2, &year, &month,
&day) != 4) {
            message(MESS_ERROR, "bad line %d in state file
%s\n",
                    stateFilename);
            fclose(f);
            return 1;
        }

The "error" report that I got is not so helpful, because
there is a value missing in the message() statement.

Shouldn't it be:
 message(MESS_ERROR, "bad line %d in state file %s\n",
                    line, stateFilename);

But I am still curious to understand why the problem
appeared at all.  In fact, the log that was supposed
to be rotated simply disappeared.  Not very nice behavior.
I can provide more specific details on request.

Cheers,
  Seth
Comment 1 Preston Brown 1999-03-18 10:30:59 EST
We have fixed the problem with the line number reported.  Yes there is
a race condition here, which you triggered by starting two logrotates
at the exact same time.  If you want to run one logrotate followed by
another, I suggest that you leave at least a minute in between the
runs.
Comment 2 Preston Brown 1999-03-18 10:32:59 EST
The fix can be found in logrotate 3.0 or greater, in the RawHide tree
and releases of Red Hat Linux > 5.2.

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