Apache and "shared memory" issues on Linux 17

Posted by Peter Burkholder Thu, 10 Apr 2008 13:07:00 GMT

This morning I was having trouble getting Apache (2.0.X) to restart. I was getting these error messages:

[Thu Apr 10 08:32:49 2008] [crit] (17)File exists: unable to create scoreboard "/var/private/logs/apache_runtime_status" (name-based shared memory failure)

and I kept deleting the offending file, and making sure that permissions all along the path were correct. No dice.

So I restarted Apache again running strace:

strace /usr/sbin/httpd2-prefork -X -Dprivate '-CPidFile /var/run/apache2.private.pid' -f /etc/apache2/httpd.conf

and saw output like this:

unlink("/var/private/logs/apache_runtime_status") = -1 ENOENT (No such file or directory)
open("/var/private/logs/apache_runtime_status", O_WRONLY|O_CREAT|O_EXCL, 0666) = 9
stat("/var/private/logs/apache_runtime_status", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
shmget(16908303, 40824, IPC_CREAT|IPC_EXCL|0600) = -1 EEXIST (File exists)
write(2, "[Thu Apr 10 08:18:46 2008] [crit"..., 168) = 168

Red Herring

Turns out that worrying about the filesystem was a distraction. The real issue is that the previous Apache had left behind shared memory segments that it couldn’t access anymore. Now I won’t pretend that I understand the ins and outs of shared memory on Linux, but a bit of Googling led me, fortunately to Sven Vermeulen’s blog, where he shared a similar experience on Solaris. I would’ve left nice comments on his blog, but as he doesn’t take comments, I’ll give a shout out to him here.

Anyhow, the ipcs and ipcrm commands come to the rescue:

# ipcs -a

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x0102000f 99942402   root      600        40824      0

------ Semaphore Arrays --------
key        semid      owner      perms      nsems

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
0x00001f58 0          root       600        0            0

Ah-ha—there’s shmid at 99942402. Let’s rm that:

# ipcrm -m 99942402
# ipcs -a

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status

------ Semaphore Arrays --------
key        semid      owner      perms      nsems

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
0x00001f58 0          root       600        0            0

And apache started right up. Yea.

P.S. One find out more about a shared memory segment with something like: ipcs -m -i 99942402, which will report:

Shared memory Segment shmid=99942402
uid=0   gid=0   cuid=0  cgid=0
mode=0600       access_perms=0600
bytes=40824     lpid=6987       cpid=6987       nattch=0
att_time=Thu Apr 10 08:20:48 2008  
det_time=Thu Apr 10 08:21:55 2008  
change_time=Thu Apr 10 08:20:48 2008  

Comments

Leave a comment

  1. rizahnst 3 months later:
    thanks!
  2. christt 6 months later:
    Thanks Peter! You saved my day!
  3. ced about 1 year later:
    thanks
  4. smart battery charger over 2 years later:
    That you were in a position to hit the nail for the go along with typed away all devoid of side effect.
  5. pozycjonowanie over 2 years later:
    Great read You might want to follow up to this topic
  6. cheapjordans over 3 years later:
    Wonderful content, I trust this really is a great weblog. Wish to see fresh content next time. cheapjordans
  7. linux over 3 years later:
    good job
  8. darmowe krzyzowki over 3 years later:
    Thanks for this great post. Did you do it all on your own? This must've taken a lot of time
  9. darmowe programy over 3 years later:
    I think this is one of the most important information for me. And i'm glad reading your article. But wanna remark on few general things, The website style is great, the articles is really excellent. Good job, cheers
  10. Ribbons over 3 years later:
    it needs a bokmark so i can come back to it later ,nice stuff
  11. JB over 3 years later:
    It saves my life... our production server was crashed after a certificate update. Thank you for this tip !
  12. Diablo 3 over 3 years later:
    hmm ,i'm not sure if this is what i'm looking for but anyway this is interresting and could be useful some day,thanks for taking time to write such cool stuff
  13. Home Security over 3 years later:
    I'm impressed. You're truly well informed and very intelligent. You wrote something that people could understand and made the subject intriguing for everyone. I'm saving this for future use.
  14. african Mango Reviews over 3 years later:
    Corporations are challenging existing business models as they seek ways to speed innovation, focus on their core competencies, and scale to capitalize on opportunities and outpace competitors.
  15. best sleep aid over 3 years later:
    Corporations are challenging existing business models as they seek ways to speed innovation, focus on their core competencies, and scale to capitalize on opportunities and outpace competitors.
  16. Pratik over 3 years later:
    Thanks for this - the information you provided helped us track down a serious bug. It's much appreciated!
  17. Novo7 Paladin over 3 years later:
    Your article was a good read, and I like the way you write. By the way, let me recommend you an Novo7 Paladin.
Comments