<HTML>
<HEAD>
<TITLE>Re: [Mongrel] Nightly mongrel issues...</TITLE>
</HEAD>
<BODY>
<FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>Usually this happens if you have a Rails handler that gets to a point and then stops for some reason. &nbsp;Since Mongrel has a lock around the dispatcher, and you&#8217;ve got an action that isn&#8217;t exiting, then all subsequent requests will become jammed.<BR>
<BR>
Typical things that can do this are not closing files, forking or spawning processes and not waiting for them, connecting to remote servers that don&#8217;t answer right away, and even opening too many files. &nbsp;Look for any actions which could possibly cause something like this, especially if you&#8217;re using an external program to do some processing.<BR>
<BR>
I&#8217;ve added a &#8211;B option and also created a small set of debugging handlers which dump lots of information for you. &nbsp;It slows your application down, so the best way to do it is this:<BR>
<BR>
</SPAN></FONT><OL><LI><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>Run mongrel with &#8211;B so it dumps thread, memory, etc. information to log/mongrel_debug/*.log files.
</SPAN></FONT><LI><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>Write a Watir or Selenium test that goes through your application like a user.
</SPAN></FONT><LI><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>Run the test and watch the mongrel_debug logs, paying attention to the ones reporting files and threads.
</SPAN></FONT><LI><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>If you see an action that seems to have lots of objects created, lots of threads left open, or dangling files then that&#8217;s probably the one.
</SPAN></FONT><LI><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>Go in and fix it.<BR>
</SPAN></FONT></OL><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'><BR>
If you&#8217;re able to let me view your code, I&#8217;d like to work through this with you. &nbsp;It&#8217;s a <B>very</B> common problem but I&#8217;d like to go through helping someone fix it. &nbsp;Can you get together with me at some point?<BR>
<BR>
Zed<BR>
<BR>
<BR>
On 4/28/06 10:48 AM, &quot;Jeremy Hopple&quot; &lt;jeremy@jthopple.com&gt; wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>Hi,<BR>
<BR>
I have Apache (2.2) setup to proxy requests through to Mongrel (0.3.12.4 <a href="http://0.3.12.4">&lt;http://0.3.12.4&gt;</a> ) for a Rails (1.1.2) application (on ruby 1.8.4). &nbsp;The setup is great, but I'm experiencing some nightly failures. &nbsp;I thought I'd post here before digging in too deeply, but it looks like Rails is going into lala land and Mongrel can't recover... <BR>
<BR>
Seems like everything gets all backed up in mongrel/rails.rb:64 at:<BR>
<BR>
@guard.synchronize do<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Rails is not thread safe so must be run entirely within synchronize <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dispatcher.dispatch (cgi, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, response.body)<BR>
end<BR>
<BR>
Prior to doing a &quot;mongrel_rails restart&quot; the mongrel log is normal and there's nothing unusual in my rails log. &nbsp;Once I do a &quot;mongrel_rails restart,&quot; I get a bunch of the following dumped into the mongrel.log (I assume one for each thread that's chillin' at @guard.synchronize)...<BR>
<BR>
Error calling Dispatcher.dispatch #&lt;Mongrel::StopServer: Timed out thread.&gt;<BR>
/usr/local/lib/ruby/gems/1.8/gems/mongrel- 0.3.12.4/lib/mongrel.rb:472:in <a href="http://0.3.12.4/lib/mongrel.rb:472:in">&lt;http://0.3.12.4/lib/mongrel.rb:472:in&gt;</a> &nbsp;`lock'<BR>
/usr/local/lib/ruby/1.8/thread.rb:133:in `synchronize'<BR>
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.12.4/lib/mongrel/rails.rb:64:in &nbsp;<a href="http://0.3.12.4/lib/mongrel/rails.rb:64:in">&lt;http://0.3.12.4/lib/mongrel/rails.rb:64:in&gt;</a> &nbsp;`process'<BR>
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.12.4/lib/mongrel.rb:425:in <a href="http://0.3.12.4/lib/mongrel.rb:425:in">&lt;http://0.3.12.4/lib/mongrel.rb:425:in&gt;</a> &nbsp;`process_client'<BR>
/usr/local/lib/ruby/gems/1.8/gems/mongrel- 0.3.12.4/lib/mongrel.rb:424:in <a href="http://0.3.12.4/lib/mongrel.rb:424:in">&lt;http://0.3.12.4/lib/mongrel.rb:424:in&gt;</a> &nbsp;`process_client'<BR>
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.12.4/lib/mongrel.rb:495:in <a href="http://0.3.12.4/lib/mongrel.rb:495:in">&lt;http://0.3.12.4/lib/mongrel.rb:495:in&gt;</a> &nbsp;`run'<BR>
/usr/local/lib/ruby/gems/1.8/gems/mongrel- 0.3.12.4/lib/mongrel.rb:494:in <a href="http://0.3.12.4/lib/mongrel.rb:494:in">&lt;http://0.3.12.4/lib/mongrel.rb:494:in&gt;</a> &nbsp;`run'<BR>
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.12.4/lib/mongrel.rb:483:in <a href="http://0.3.12.4/lib/mongrel.rb:483:in">&lt;http://0.3.12.4/lib/mongrel.rb:483:in&gt;</a> &nbsp;`run' <BR>
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.12.4/lib/mongrel.rb:774:in <a href="http://0.3.12.4/lib/mongrel.rb:774:in">&lt;http://0.3.12.4/lib/mongrel.rb:774:in&gt;</a> &nbsp;`run'<BR>
/usr/local/lib/ruby/gems/1.8/gems/mongrel- 0.3.12.4/lib/mongrel.rb:772:in <a href="http://0.3.12.4/lib/mongrel.rb:772:in">&lt;http://0.3.12.4/lib/mongrel.rb:772:in&gt;</a> &nbsp;`run'<BR>
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.12.4/bin/mongrel_rails:97:in <a href="http://0.3.12.4/bin/mongrel_rails:97:in">&lt;http://0.3.12.4/bin/mongrel_rails:97:in&gt;</a> &nbsp;`run'<BR>
/usr/local/lib/ruby/gems/1.8/gems/mongrel- 0.3.12.4/lib/mongrel/command.rb:163:in <a href="http://0.3.12.4/lib/mongrel/command.rb:163:in">&lt;http://0.3.12.4/lib/mongrel/command.rb:163:in&gt;</a> &nbsp;`run'<BR>
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.12.4/bin/mongrel_rails:194 &nbsp;<a href="http://0.3.12.4/bin/mongrel_rails:194">&lt;http://0.3.12.4/bin/mongrel_rails:194&gt;</a> <BR>
/usr/local/bin/mongrel_rails:18<BR>
<BR>
If anyone has any ideas please let me know... I promise I'll jump up and down!<BR>
<BR>
Thanks,<BR>
Jeremy<BR>
<BR>
<HR ALIGN=CENTER SIZE="3" WIDTH="95%"></SPAN></FONT><FONT SIZE="2"><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:10.0px'>_______________________________________________<BR>
Mongrel-users mailing list<BR>
Mongrel-users@rubyforge.org<BR>
<a href="http://rubyforge.org/mailman/listinfo/mongrel-users">http://rubyforge.org/mailman/listinfo/mongrel-users</a><BR>
</SPAN></FONT></FONT></BLOCKQUOTE><FONT SIZE="2"><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:10.0px'><BR>
</SPAN></FONT></FONT>
</BODY>
</HTML>