Bug 54622

Summary: shared memory cleanup
Product: Apache httpd-2 Reporter: Teodor Milkov <tm>
Component: mod_auth_digestAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: RESOLVED FIXED    
Severity: normal Keywords: PatchAvailable
Priority: P2    
Version: 2.4.3   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: Let apachectl cleanup stale shm and pid files

Description Teodor Milkov 2013-02-28 14:33:14 UTC
Created attachment 30005 [details]
Let apachectl cleanup stale shm and pid files

If httpd dies for some reason (see bellow) it leaves shared memory segments behind, and won't start until shm is cleaned up manually.

One of the reasons for unclean shutdown might be bug in the apache itself (or some module like mod_php etc.).

Another reason might be Linux oom killer.

Yet another reason might be: shared hosting environment, heavy server load (maybe incoming DoS), you want to restart apache — execute httpd -k stop, wait several seconds or even a minute, finally give up and kill -9.

The error mod_auth_digest spits is:

[Sun Feb 17 04:28:02.765535 2013] [auth_digest:error] [pid 17934] (17)File exists: AH01762: Failed to create shared memory segment on file /apache/logs/authdigest_shm.17934
[Sun Feb 17 04:28:02.765580 2013] [auth_digest:error] [pid 17934] (17)File exists: AH01760: failed to initialize shm - all nonce-count checking, one-time nonces, and MD5-sess algorithm disabled
[Sun Feb 17 04:28:02.765588 2013] [:emerg] [pid 17934] AH00020: Configuration Failed, exiting

My solutions for now is patched apachectl (see attached patch).

Our best case scenario is if apache could improve on this, so we don't have to do it ourselves.

If that cannot be done, at least changing owner of shm segments to apache, so that we could more easily / safely select them for cleanup.


Related issues:
 * https://issues.apache.org/bugzilla/show_bug.cgi?id=7838 (Apache leaves shared memory segments and dies after unclean shutdown)
 * https://issues.apache.org/bugzilla/show_bug.cgi?id=16056 (Shared memory & mutex ownership not correctly established for SysV mutexes)


Best regards,
Teodor
Comment 1 Joe Orton 2017-02-08 14:11:44 UTC
Fixed in r1782175 for 2.4.x.