No space left on device: Couldn’t create accept lock” errors? (Semaphores)

semaphores are IPC (interprocess communications structures). Semaphores like all IPC are used to allow different processes to communicate with each other.

They are basically counters that are created, accessed and destroyed using special system calls, such as sempost(3), semwait(3), semget(2) and semop(2). See sem_overview(7) on a linux system for a brief description.

The definition of communicate here is pretty primitive. “Communicate” for semaphores means reading, incrementing or decrementing a counter via the system/library calls.

 

 

I was facing same error with one of my shared server last couple of week, apache was broke on server and getting following error in apache error logs file.

 

[emerg] (28)No space left on device: Couldn't create accept lock
[notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[notice] Digest: generating secret for digest authentication ...
[notice] Digest: done
[warn] pid file /etc/httpd/run/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[emerg] (28)No space left on device: Couldn't create accept lock

 

I checked disk space, or quota limit but everything was fine. I through it seem to apache semaphore problem

Apache can create the “accept lock” is with a semaphore. A semaphore is an inter-process communication tool that is used by Apache to communicate with it’s child processes. This error message may mean that Apache couldn’t create a new semaphore.

Check to see how many semaphores are currently in use. If Apache is running correctly, you should see something like this:

 

# ipcs -s

 

If Apache is stopped, and you still see these semaphores, then you can safely kill them by running this command for each semaphore id (in the second column)

$ ipcs -s <semid>

To destroy all semaphores, you can run this from the command line (with “apache” being the apache-user:

 

for semid in `ipcs -s | grep apachec | cut -f2 -d" "`; do ipcrm -s $semid; done

OR

ipcs -s | grep apache | perl -e ‘while (<STDIN>) { @a=split(/\s+/); print `ipcrm sem $a[1]`}’

 

OR

ipcs -s | grep nobody | perl -e ‘while () { @a=split(/\s+/); print `ipcrm sem $a[1]`}’ ipcs -m | grep nobody | perl -e ‘while () { @a=split(/\s+/); print `ipcrm -m $a[1]`}’

 

OR

for i in `ipcs -s | awk ‘/httpd/ {print $2}’`; do (ipcrm -s $i); done

 

How to increase semaphore limit

 

To view the current parameters:

ipcs -l

 

To change these parameters, modify the file /etc/sysctl.conf and add the following lines:

kernel.msgmni = 1024
kernel.sem = 250 256000 32 1024

 

Then load these settings with the command:

sysctl -p
Advertisements

One thought on “No space left on device: Couldn’t create accept lock” errors? (Semaphores)

  1. Hi,

    There’s a typo in your first example…
    The one liner should be:
    for semid in `ipcs -s | grep apache | cut -f2 -d” “`; do ipcrm -s $semid; done

    Thanks though, didn’t think of a semaphore issue at first ;-).

    Sebastian

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s