Bug 143 - Problem with reading state file in logrotate coding bug in logrotate
Problem with reading state file in logrotate coding bug in logrotate
Product: Red Hat Linux
Classification: Retired
Component: logrotate (Show other bugs)
All Linux
low Severity low
: ---
: ---
Assigned To: Cristian Gafton
Depends On:
  Show dependency treegraph
Reported: 1998-11-20 02:03 EST by seth
Modified: 2018-05-02 09:03 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 1999-03-18 10:32:53 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
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

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
            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.

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
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.
Comment 3 Fedora Update System 2018-05-02 09:03:22 EDT
auter-0.11-5.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-428fe8d2cd

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