Bug 429807
Summary: | Apache fails to re-open logfiles after SIGHUP from logrotate | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 5 | Reporter: | Jon Jensen <jon> |
Component: | httpd | Assignee: | Joe Orton <jorton> |
Status: | CLOSED NOTABUG | QA Contact: | |
Severity: | medium | Docs Contact: | |
Priority: | low | ||
Version: | 5.1 | ||
Target Milestone: | rc | ||
Target Release: | --- | ||
Hardware: | x86_64 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2008-01-28 11:15:25 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Jon Jensen
2008-01-23 06:38:58 UTC
Sunday at 4am is special in the above configuration because on that day, the parent will get SIGHUP-ed *twice* by logrotate in a very short period of time - once for each section specified above. (The "sharedscripts" does not apply across the two sections.) Can you clarify what you mean by "fails to re-open the files"? Are the access_log/error_log files simply not created; or are they created, but stay empty? Is the httpd logging configuration otherwise as default? Oh, of course; I was forgetting that the default is weekly, so that plus the daily config above = Sunday specialness. Thanks for pointing that out. IIRC, access_log/error_log are created but remain empty. My guess is that the files are being created by logrotate, though, and Apache doesn't touch them at all. The logging setup is pretty standard. In each virtual host: ErrorLog logs/sites/$domain/error_log CustomLog logs/sites/$domain/access_log combined With $domain varying, of course. And an additional log for SSL: CustomLog logs/sites/$domain/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" Perhaps a simple kludge such as a "sleep 10" command in the custom logrotate stanza's script would help? There's a period of time during the restart process in which httpd has opened the log files but is ignoring SIGHUP. I can see that this results in a race condition with the double-logrotate; in the above config, when the weekly logrotate comes along, it may rename the files but fail to restart the server. This would leave the server logging to the old log files (those renamed during rotation) until the subsequent daily logrotate run; with no default access_log/error_log files in existence (logrotate does not create them, AFAIK). Putting a "sleep 10" or similar before the reload in *both* the stanzas would be necessary to avoid that race. I can't see how it would be possible for the server to end up in a state where the new empty access_log/error_log are created but not being logged to, however. I'm going to mark this as NOTABUG on the assumption that the race being hit is as described in comment 3 (which is essentially by design); the "sleep" hack should be able to work around the particular logrotate configurations. Another workaround would be to disable the logrotate configuration for httpd completely, create a separate logrotate config (outside the default directory), which does *not* run the httpd reload internally, and cron a daily job which does simply: logrotate /etc/special-httpd-logrotate.conf service httpd reload Ok, thanks for your help, Joe. It really seems like something Apache should be able to handle, but I imagine it'd be complicated. In any case, I've consolidated stanzas and expect that to solve my immediate problem. I appreciate your input. |