[Mongrel] random cpu spikes, EBADF errors

Zed A. Shaw zedshaw at zedshaw.com
Tue Oct 30 08:42:19 EDT 2007

On Mon, 29 Oct 2007 16:09:17 -0400
"Zachary Powell" <zach at plugthegap.co.uk> wrote:

> Hi All,
> Follow up to the CPU/EBADF issue I was having with lsws:
> http://www.litespeedtech.com/support/forum/showthread.php?t=1012&goto=newpost
> Here is the message that has just been posted:
> ***************
> The problem is on mongrel side. As shown in the strace output, file handle 5
> is the reverse proxy connection from LSWS to mongrel. Mongrel read the
> request, then it closed the connection immediately without sending back
> anything, then try to close it again with result EBADF, because the file
> descriptor has been closed already.

Take a look in the mongel.log with debugging on as there might be a complaint about LSWS's interpretation of the HTTP protocol which is causing mongrel to close the connection due to a malformed request.  Normally, the only time that Mongrel will abort a connection is when the client (LSWS in this case) sends a malformed request according to the HTTP grammar.  When Mongrel reports what caused the close it tells you the full request that was bad.  The error is usually BAD CLIENT.

Also go use ethereal to get a packet trace of the traffic between the two servers to see what is being sent.  You'll probably find that LSWS is doing something that no other web server does, or at least some clue as to what is making Mongrel barf.  One thing to watch for is that some web servers acting as a proxy don't honor the Connection:close header on responses and try to keep the socket forced open, which also violates the RFC.

Finally, a stack trace of where the EBADF shows up would let the Mongrel team just not close it if it's already closed (again).  Ultimately Ruby shouldn't be throwing these errnos as separate exceptions since it means having to compensate for every platform's interpretation of the sockets API and what should be thrown when.

Zed A. Shaw
- Hate: http://savingtheinternetwithhate.com/
- Good: http://www.zedshaw.com/
- Evil: http://yearofevil.com/

More information about the Mongrel-users mailing list