Ticket #938 (closed defect: fixed)

Opened 2 years ago

Last modified 3 months ago

mod_proxy returns 500 on read() == EAGAIN (Resource temporarily unavailable)

Reported by: rlynch Assigned to: jan
Priority: normal Milestone:
Component: mod_proxy Version: 1.4.11
Severity: normal Keywords:
Cc: Blocking:
Need Feedback: 0

Description

I am using lighttpd to proxy to ruby-on-rails/mongrel, and have been seeing this message frequently in my error logs:

2006-12-14 09:39:31: (mod_proxy.c.659) unexpected end-of-file (perhaps the proxy process died): 9 Resource temporarily unavailable

Upon further investigation it appears this is due to mod_proxy abandoning a non-blocking read on the proxy backend socket after a return of EAGAIN. I patched the server to wait for one second and then retry the read (up to three times). So far it has never needed to retry more than one time, and the 500s are gone. It's a crude solution (non-configurable, and waits for a whole second) but it beats returning a bunch of 500s.

Platform details:

SunOS 91970-AA 5.11 snv_43 i86pc i386 i86pc lighttpd-1.4.11 - a light and fast webserver

Attachments

mod_proxy.c.patch (0.9 kB) - added by rlynch on 12/15/2006 10:41:49 PM.
Patch to retry reads on EAGAIN
mod_proxy-EAGAIN.patch (0.9 kB) - added by jakabosky on 12/16/2006 03:17:10 AM.
return 0 on EAGAIN error.

Change History

12/15/2006 10:41:49 PM changed by rlynch

  • attachment mod_proxy.c.patch added.

Patch to retry reads on EAGAIN

12/16/2006 03:17:10 AM changed by jakabosky

  • attachment mod_proxy-EAGAIN.patch added.

return 0 on EAGAIN error.

12/16/2006 03:23:32 AM changed by jakabosky

I created a new patch that should work better then sleeping on an EAGAIN.

Since lighttpd is simple-threaded sleeping will block processing of all other connections.

returning 0 will not kill the connection and allow lighttpd to continue processing other connections. When data comes in for this backend lighttpd will get a read event and return to proxy_demux_response function to do another read.

My patch include the same fix for mod_fastcgi.c

please try my patch and let me know if it works for you. I will then commit it to svn.

12/16/2006 06:04:42 AM changed by rlynch

Thank you for the more nuanced solution to this problem. I will apply the patch and let you know if any problems arise.

12/17/2006 12:21:44 PM changed by rlynch

The patch appears to work as expected. Please feel free to commit.

04/25/2008 08:42:20 AM changed by stbuehler

  • status changed from new to closed.
  • resolution set to fixed.
  • blocking changed.
  • pending changed.

Fixed in [1500]


Add/Change #938 (mod_proxy returns 500 on read() == EAGAIN (Resource temporarily unavailable))




Change Properties
Action