Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 111956 - Apache hangs on reload after logrotate
Summary: Apache hangs on reload after logrotate
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Apache Team - Bugzilla Reports
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-09 03:16 UTC by Timo A. Hummel
Modified: 2006-05-25 01:04 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Timo A. Hummel 2005-11-09 03:16:07 UTC
I've got two identically configured servers with Apache2/mod_php. I added
logrotate a few days ago (see the rotate script below), which worked perfectly
the first 2 days. After that (and since then), Apache hangs while reloading. The
master process tries to restart, leaving the child processes listening but not
answering requests. Each morning I have to restart (reload doesn't work).


System environment:

www2 ~ # /usr/sbin/apache2 -v
Server version: Apache/2.0.54
Server built:   Sep 27 2005 15:36:42

www2 ~ # /usr/sbin/apache2 -l
Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c

www2 / # uname -a
Linux www2 2.6.12-gentoo-r10 #1 SMP Tue Sep 27 14:40:30 CEST 2005 i686 AMD
Athlon(tm) XP 3000+ AuthenticAMD GNU/Linux

/srv/www/vhosts/logs/web2-access_log {
    compress
    delaycompress
    daily
    create 664 apache apache
    missingok
    postrotate
     /etc/init.d/apache2 reload
    endscript
}


Reproducible: Always
Steps to Reproduce:
1.
2.
3.
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2005-11-09 03:19:41 UTC
What does /var/log/apache2/error_log say?
Comment 2 Timo A. Hummel 2005-11-09 03:35:38 UTC
[Wed Nov 09 04:10:02 2005] [notice] Graceful restart requested, doing restart
[Wed Nov 09 04:10:02 2005] [notice] Digest: generating secret for digest
authentication ...
[Wed Nov 09 04:10:03 2005] [crit] (4)Interrupted system call: Digest: error
generating secret: Interrupted system call
Configuration Failed
[Wed Nov 09 11:50:24 2005] [notice] suEXEC mechanism enabled (wrapper:
/usr/sbin/suexec2)
[Wed Nov 09 11:50:24 2005] [notice] Digest: generating secret for digest
authentication ...
[Wed Nov 09 11:50:24 2005] [notice] Digest: done
[Wed Nov 09 11:50:24 2005] [warn] pid file /var/run/apache2.pid overwritten --
Unclean shutdown of previous Apache run?
[Wed Nov 09 11:50:24 2005] [notice] Apache configured -- resuming normal operations
Comment 3 Timo A. Hummel 2005-11-09 03:36:09 UTC
Additional note: Log entries around 11:50:24 are from the manual apache restart.
Comment 4 Jakub Moc (RETIRED) gentoo-dev 2005-11-09 03:54:31 UTC
We install out own logrotate script, which does:

/etc/init.d/apache2 reload > /dev/null 2>&1 || true

Does the above work for you?

If not, then commenting out 

LoadModule auth_digest_module            modules/mod_auth_digest.so

line in /etc/apache2/httpd.conf might solve this. 

That said, apache init script is broken. E.g., it fails when restarting apache.
Could be easily fixed with something like:

stop() {
        checkconfig || return 1
        ebegin "Stopping apache2"
        ${APACHE2} ${APACHE2_OPTS} -k stop
        sleep 10
        eend $?
}

which gives apache a chance to stop cleanly before starting it again, or doing
some more sophisticated voodoo (like in
/usr/portage/net-proxy/squid/files/squid.initd). The installed init script
essentially always fails to restart apache, except for cases when apache is idle. 
Comment 5 Timo A. Hummel 2005-11-11 02:30:46 UTC
Okay, the first solution using

/etc/init.d/apache2 reload > /dev/null 2>&1 || true

certainly didn't help. I disabled the mod_auth_digest modules and I will see if
it works.

I do think that the 10 second sleep on a restart is a good idea and shood be
implemented, or even more logic (e.g. check if apache is still running after 10
seconds, if yes, kill apache, check again, then start it).

However, I'm using reload in my logrotate scripts so that shouldn't be the cause...
Comment 6 Rene Zbinden 2005-11-17 02:48:03 UTC
I had the same problems here. I disabled the digest module, this was the solution.
Comment 7 Tomasz Orzechowski 2006-05-25 00:50:02 UTC
You can simply just do a kill -USR1 on apache, not fully restart it.  It will allow apache to finish serving all current requests, rehash its config, flush and reopen all log files, all without visible interruption.

You want something along the line of:
 kill -USR1 `cat /var/run/apache2.pid`
Comment 8 Jakub Moc (RETIRED) gentoo-dev 2006-05-25 01:04:08 UTC
Closing this, if you have entropy issues w/ auth_digest_module, then recompile apr w/ USE="urandom". Not a logrotate script bug.