Bug#460542: logrotate spins out of control when files are missing

2008-01-15 Thread Paul Martin
severity 460542 minor
tags 460542 wontfix
thanks

On Sun, Jan 13, 2008 at 01:59:24PM +, Aaron Swartz wrote:
 I woke up this morning to find my webserver (lighttpd) unresponsive and
 logrotate using up 100% CPU. When I ran strace on logrotate I found:
 
 rename(/service/lighttpd/logs/error.log.638155266.gz, 
 /service/lighttpd/logs/error.log.638155267.gz) = -1 ENOENT (No such file or 
 directory)
 rename(/service/lighttpd/logs/error.log.638155265.gz, 
 /service/lighttpd/logs/error.log.638155266.gz) = -1 ENOENT (No such file or 
 directory)
 rename(/service/lighttpd/logs/error.log.638155264.gz, 
 /service/lighttpd/logs/error.log.638155265.gz) = -1 ENOENT (No such file or 
 directory)
 rename(/service/lighttpd/logs/error.log.638155263.gz, 
 /service/lighttpd/logs/error.log.638155264.gz) = -1 ENOENT (No such file or 
 directory)
 rename(/service/lighttpd/logs/error.log.638155262.gz, 
 /service/lighttpd/logs/error.log.638155263.gz) = -1 ENOENT (No such file or 
 directory)
 rename(/service/lighttpd/logs/error.log.638155261.gz, 
 /service/lighttpd/logs/error.log.638155262.gz) = -1 ENOENT (No such file or 
 directory)
 rename(/service/lighttpd/logs/error.log.638155260.gz, 
 /service/lighttpd/logs/error.log.638155261.gz) = -1 ENOENT (No such file or 
 directory)
 rename(/service/lighttpd/logs/error.log.638155259.gz, 
 /service/lighttpd/logs/error.log.638155260.gz) = -1 ENOENT (No such file or 
 directory)
 rename(/service/lighttpd/logs/error.log.638155258.gz, 
 /service/lighttpd/logs/error.log.638155259.gz) = -1 ENOENT (No such file or 
 directory)

 /service/lighttpd/logs/*.log {
 weekly
 missingok
 copytruncate
 rotate 9

That line is your problem, and here is the loop that runs based on that
value:

for (i = rotateCount + logStart - 1; (i = 0)  !hasErrors; i--) {
tmp = newName;
newName = oldName;
oldName = tmp;
sprintf(oldName, %s/%s.%d%s%s, dirName, baseName, i,
fileext, compext);

message(MESS_DEBUG, renaming %s to %s (rotatecount %d, logstart %d, i 
%d), \n, oldName, newName,
rotateCount, logStart, i);

if (!debug  rename(oldName, newName)) {
if (errno == ENOENT) {
message(MESS_DEBUG, old log %s does not exist\n,
oldName);
} else {
message(MESS_ERROR, error renaming %s to %s: %s\n,
oldName, newName, strerror(errno));
hasErrors = 1;
}
}
} 

Might I suggest you use dateext instead, as that avoids all the renames?

eg:
 rotate 9
 dateext

PS. 9 days is 2.7 million years.

-- 
Paul Martin [EMAIL PROTECTED]



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#460542: logrotate spins out of control when files are missing

2008-01-13 Thread Aaron Swartz
Package: logrotate
Version: 3.7.1-3
Severity: critical
Justification: breaks unrelated software


I woke up this morning to find my webserver (lighttpd) unresponsive and 
logrotate 
using up 100% CPU. When I ran strace on logrotate I found:

rename(/service/lighttpd/logs/error.log.638155266.gz, 
/service/lighttpd/logs/error.log.638155267.gz) = -1 ENOENT (No such file or 
directory)
rename(/service/lighttpd/logs/error.log.638155265.gz, 
/service/lighttpd/logs/error.log.638155266.gz) = -1 ENOENT (No such file or 
directory)
rename(/service/lighttpd/logs/error.log.638155264.gz, 
/service/lighttpd/logs/error.log.638155265.gz) = -1 ENOENT (No such file or 
directory)
rename(/service/lighttpd/logs/error.log.638155263.gz, 
/service/lighttpd/logs/error.log.638155264.gz) = -1 ENOENT (No such file or 
directory)
rename(/service/lighttpd/logs/error.log.638155262.gz, 
/service/lighttpd/logs/error.log.638155263.gz) = -1 ENOENT (No such file or 
directory)
rename(/service/lighttpd/logs/error.log.638155261.gz, 
/service/lighttpd/logs/error.log.638155262.gz) = -1 ENOENT (No such file or 
directory)
rename(/service/lighttpd/logs/error.log.638155260.gz, 
/service/lighttpd/logs/error.log.638155261.gz) = -1 ENOENT (No such file or 
directory)
rename(/service/lighttpd/logs/error.log.638155259.gz, 
/service/lighttpd/logs/error.log.638155260.gz) = -1 ENOENT (No such file or 
directory)
rename(/service/lighttpd/logs/error.log.638155258.gz, 
/service/lighttpd/logs/error.log.638155259.gz) = -1 ENOENT (No such file or 
directory)

Apparently it had missed a lighttpd log file or something and was now 
proceeding 
to logrotate every imaginary file it could think of. (It's hard to be sure of 
exactly what's going on without looking at the code.)

I killed it and the site came back, but I thought a developer would know better 
what's going on.

I haven't changed the logrotate conf files in months and this has never 
happened 
before. The relevant config is:

/service/lighttpd/logs/*.log {
weekly
missingok
copytruncate
rotate 9
compress
notifempty
sharedscripts
postrotate
   if [ -f /var/run/lighttpd.pid ]; then \
 if [ -x /usr/sbin/invoke-rc.d ]; then \
invoke-rc.d lighttpd force-reload  /dev/null; \
 else \
/etc/init.d/lighttpd force-reload  /dev/null; \
 fi; \
   fi;
endscript
}

-- Package-specific info:
Contents of /etc/logrotate.d
total 24
-rw-r--r-- 1 root root 240 Jun 19  2007 apache2
-rw-r--r-- 1 root root  79 Sep  3  2006 aptitude
-rw-r--r-- 1 root root  69 Dec 15  2006 backupninja
-rw-r--r-- 1 root root 111 Oct 13  2006 dpkg
-rw-r--r-- 1 root root 488 Dec 18 05:11 lighttpd
-rw-r--r-- 1 root root 153 Aug 15 01:50 postgresql-common


-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16.29-xen
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages logrotate depends on:
ii  base-passwd3.5.11Debian base system master password
ii  cron   3.0pl1-100management of regular background p
ii  libc6  2.3.6.ds1-13etch4 GNU C Library: Shared libraries
ii  libpopt0   1.10-3lib for parsing cmdline parameters
ii  libselinux11.32-3SELinux shared libraries

Versions of packages logrotate recommends:
ii  mailx1:8.1.2-0.20050715cvs-1 A simple mail user agent

-- no debconf information



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]