Page MenuHomeFreeBSD

newsyslog: fix one hour rotation with frequent execution
ClosedPublic

Authored by glebius on Tue, Sep 23, 8:10 PM.
Tags
None
Referenced Files
F132554103: D52700.id162995.diff
Fri, Oct 17, 10:33 PM
Unknown Object (File)
Wed, Oct 15, 6:39 AM
Unknown Object (File)
Tue, Oct 14, 10:11 PM
Unknown Object (File)
Tue, Oct 14, 10:11 PM
Unknown Object (File)
Sat, Oct 11, 2:42 PM
Unknown Object (File)
Fri, Oct 10, 4:07 AM
Unknown Object (File)
Thu, Oct 9, 10:52 PM
Unknown Object (File)
Thu, Oct 9, 10:52 PM
Subscribers

Details

Summary

If a newsyslog.conf(5) has an entry that is configured to be rotated every
hour, and crontab(8) is set to execute newsyslog several times per hour,
the logic of age_old_log() is broken and it would rotate the entry too
often. AFAIU, the extra 1800 seconds were added to allow some leeway for
the previous newsyslog invocation, that could have been too slow and the
timestamp on the old file is newer than actual time of the previous
newsyslog invocation. But 30 minutes of leeway is way to much. Reduce
this down to 3 minutes, which would be a compromise between a potential
need to run newsyslogd every 5 minutes and a situation when newsyslog
takes a significant time to rotate the logs.

Provide a test case for that.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

The current logic looks like it was effectively rounding the elapsed time to the nearest hour (with a 30-minute bias). That means a file only 30 minutes old could be considered "1 hour old," which isn’t what a user would normally expect if they configured rotation every hour. A user would reasonably expect “1h” to mean exactly 60 minutes, with perhaps a small tolerance for cron jitter or a slow rotation run.

Reducing the leeway from 30 minutes to a small number of minutes makes sense in practice. It aligns better with user expectations while still accounting for jitter in cron (between 0 to 60 seconds with Vixie cron).

The only open question (this might be debatable, so I'm leaving "Src Committers" open for now) is the exact value—3 minutes seems like a reasonable compromise in my opinion, while any small tolerance (1–5 minutes) would serve the same purpose.

This revision is now accepted and ready to land.Sun, Sep 28, 8:17 AM