# Mongrel Hanging (Apache, mod\_proxy, Mongrel Cluster, Rails)

**URL:** <https://www.ruby-forum.com/t/mongrel-hanging-apache-mod-proxy-mongrel-cluster-rails/171257>\
**Category:** Mongrel\
**Created:** [June 29, 2009, 5:31pm UTC](https://www.ruby-forum.com/t/mongrel-hanging-apache-mod-proxy-mongrel-cluster-rails/171257 "2009-06-29T17:31:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin\_Erickson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@Justin\_Erickson](https://www.ruby-forum.com/u/Justin_Erickson)\
**Post date:** [June 29, 2009, 5:31pm UTC](https://www.ruby-forum.com/t/mongrel-hanging-apache-mod-proxy-mongrel-cluster-rails/171257/1 "2009-06-29T17:31:17Z")

</div>

We have been having a problem with our mongrel servers hanging at  
seemingly random times.

The problem can be most often reproduced by accessing a page, leaving  
the browser open for some time (60+ min) then making another request.  
The browser will receive a “Proxy Error” from Apache, If we look at  
mongrel via “ps aux” it says

“mongrel\_rails [8000/1/253]: handling 127.0.0.1: GET /”

Using strace we pulled this:

14:04:15 poll([{fd=12, events=POLLIN|POLLPRI}], 1, 0) = 0  
14:04:15 write(12, “\1\0\0\0\t”, 5) = 5  
14:04:15 read(12,

SEVER IS LOCKED HERE…

Then 15 min later…

14:04:15 read(12, 0x8eab758, 16384) = -1 ETIMEDOUT (Connection timed  
out)  
14:19:40 shutdown(12, 2 /\* send and receive \*/) = -1 ENOTCONN  
(Transport endpoint is not connected)  
14:19:40 close(12) = 0  
14:19:40 rt\_sigprocmask(SIG\_SETMASK, [], NULL, 8) = 0  
14:19:40 socket(PF\_INET, SOCK\_STREAM, IPPROTO\_IP) = 12  
14:19:40 fcntl64(12, F\_SETFL, O\_RDONLY) = 0  
14:19:40 fcntl64(12, F\_GETFL) = 0x2 (flags O\_RDWR)  
14:19:40 connect(12, {sa\_family=AF\_INET, sin\_port=htons(3306),  
sin\_addr=inet\_addr(“XXX.XXX.XXX.XXX”)}, 16) = 0  
14:19:40 setsockopt(12, SOL\_SOCKET, SO\_RCVTIMEO, “\2003\341\1\0\0\0\0”,  
8) = 0  
14:19:40 setsockopt(12, SOL\_SOCKET, SO\_SNDTIMEO, “\2003\341\1\0\0\0\0”,  
8) = 0  
14:19:40 setsockopt(12, SOL\_IP, IP\_TOS, [8], 4) = 0  
14:19:40 setsockopt(12, SOL\_TCP, TCP\_NODELAY, [1], 4) = 0  
14:19:40 setsockopt(12, SOL\_SOCKET, SO\_KEEPALIVE, [1], 4) = 0  
14:19:40 read(12, “F\0\0\0\n5.0.60sp1-enterprise-gpl\0\3679”…, 16384)  
= 74

We have tried all the results we can find on the internet regarding  
“Mongrel Hanging”

For Example:

We are NOT using ruby log rolling  
We ARE using the c compiled mysql Adapter  
We have tried setting “ActiveRecord::Base.verification\_timeout = 14400”  
The timeout setting on MySQL are default (interactive\_timout,  
wait\_timeout) = 28800

We have tried the TCP keepalive setting found in here:  
[http://wooga.drbacchus.com/rails-and-mysql-timeouts](http://wooga.drbacchus.com/rails-and-mysql-timeouts)

We have tried setting an apache setting:  
#Fix for Apache bug 39499  
SetEnv force-proxy-request-1.0 1  
SetEnv proxy-nokeepalive 1

We have even tried many mysql\_adapter.rb patches that “correctly”  
reconnect the connection on an error.

None of these have made any difference.

We are currently using:  
MySQL 5.0.60sp1  
Rails 2.0.2  
Mongrel 1.1.5

Thanks you very much for any help!

Justin

---

<div class="post-metadata">

**Author:** ![Justin\_Erickson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@Justin\_Erickson](https://www.ruby-forum.com/u/Justin_Erickson)\
**Post date:** [February 8, 2010, 7:19am UTC](https://www.ruby-forum.com/t/mongrel-hanging-apache-mod-proxy-mongrel-cluster-rails/171257/2 "2010-02-08T07:19:33Z")

</div>

Hi, Justin. Were you ever able to get this resolved? I’m currently  
experiencing the same behavior you describe in your post. Any help is  
much appreciated.

---

<div class="post-metadata">

**Author:** ![Justin\_Erickson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@Justin\_Erickson](https://www.ruby-forum.com/u/Justin_Erickson)\
**Post date:** [February 8, 2010, 3:08pm UTC](https://www.ruby-forum.com/t/mongrel-hanging-apache-mod-proxy-mongrel-cluster-rails/171257/3 "2010-02-08T15:08:38Z")

</div>

Hi Daniel,

I had the same issue recently and detailled it here :  
[http://groups.google.ca/group/rubyonrails-talk/browse\_thread/thread/a53e75680a98f014/81dfbf8cbb0e7c69?lnk=raot](http://groups.google.ca/group/rubyonrails-talk/browse_thread/thread/a53e75680a98f014/81dfbf8cbb0e7c69?lnk=raot)

In my case, as in Justin’s IIRC , the firewall between the mongrel and  
the  
database caused the connection to drop after some time.

Hope this was helpful

Damien

2010/2/8 Daniel S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
