Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 143 - Problem with reading state file in logrotate coding bug in logrotate
Summary: Problem with reading state file in logrotate coding bug in logrotate
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: logrotate
Version: 5.2
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Cristian Gafton
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1998-11-20 07:03 UTC by seth
Modified: 2018-05-02 13:03 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 1999-03-18 15:32:53 UTC


Attachments (Terms of Use)

Description seth 1998-11-20 07:03:01 UTC
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 15:30:59 UTC
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 15:32:59 UTC
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 13:03:22 UTC
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.