Bug 54622 - shared memory cleanup
Summary: shared memory cleanup
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_auth_digest (show other bugs)
Version: 2.4.3
Hardware: PC Linux
: P2 normal with 3 votes (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
Keywords: PatchAvailable
Depends on:
Reported: 2013-02-28 14:33 UTC by Teodor Milkov
Modified: 2017-02-08 14:11 UTC (History)
0 users

Let apachectl cleanup stale shm and pid files (2.99 KB, patch)
2013-02-28 14:33 UTC, Teodor Milkov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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,
Comment 1 Joe Orton 2017-02-08 14:11:44 UTC
Fixed in r1782175 for 2.4.x.