Wednesday, February 22, 2006

Cryptic Apache Error

Each night our webmail servers automatically restart httpd to clean up memory and start fresh. Last night one of our servers hit this error upon restart:

[crit] (28)No space left on device: mod_rewrite: could not create rewrite_log_lock Configuration Failed

I had never seen this error before and had no idea what it meant, but Google helped me out:

http://www.goldfisch.at/knowledge/224

After some testing, I found that Apache leaks a couple of semaphores after each restart and eventually w/o a server reboot will run out of resources. So I changed our restart script to clean up these semaphores each night.

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

In case you are wondering, it's not a big deal if a webmail server doesn't restart properly. Our load balancers quickly take a down server out of rotation so that customers are not affected. Thank you keepalived.