Apache: No space left on device: Couldn’t create accept lock

When dealing with mem leaks in my mod_php apps I ran into a curious apache problem.

After a while apache could not be started but failed with strange errors like:

[emerg] (28)No space left on device: Couldn't create accept lock (/var/lock/apache2/accept.lock.11180) (5)

There was definitely enough space on the device where the locks are stored (default /var/lock/apache2/). I tried to explicetely different Lockfiles using the LockFile directive but this did not help. Only reboot of the system helped out of my crisis.

Solution

# ipcs -s | grep www-data

If you see a list of semaphores, Apache has not cleaned up after itself, and some semaphores are stuck.
Removing this semaphores immediately solved the problem

# for i in `ipcs -s | awk '/www-data/ {print $2}'`; do (ipcrm -s $i); done

Now, in almost all cases, Apache should start properly. If it doesn’t, you may just be completely out of available semaphores. You may want to increase your available semaphores, and you’ll need to tickle your kernel to do so. Add this to /etc/sysctl.conf:

kernel.sem = 250 256000 32 1024

And then run sysctl -p to pick up the new changes.

Semaphore

thx skif@




coded by nessus