<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. Since Mongrel has a lock around the dispatcher, and you’ve got an action that isn’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’t answer right away, and even opening too many files. Look for any actions which could possibly cause something like this, especially if you’re using an external program to do some processing.<BR>
<BR>
I’ve added a –B option and also created a small set of debugging handlers which dump lots of information for you. 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 –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’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’re able to let me view your code, I’d like to work through this with you. It’s a <B>very</B> common problem but I’d like to go through helping someone fix it. Can you get together with me at some point?<BR>
<BR>
Zed<BR>
<BR>
<BR>
On 4/28/06 10:48 AM, "Jeremy Hopple" <jeremy@jthopple.com> 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"><http://0.3.12.4></a> ) for a Rails (1.1.2) application (on ruby 1.8.4). The setup is great, but I'm experiencing some nightly failures. 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>
# Rails is not thread safe so must be run entirely within synchronize <BR>
Dispatcher.dispatch (cgi, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, response.body)<BR>
end<BR>
<BR>
Prior to doing a "mongrel_rails restart" the mongrel log is normal and there's nothing unusual in my rails log. Once I do a "mongrel_rails restart," 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 #<Mongrel::StopServer: Timed out thread.><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"><http://0.3.12.4/lib/mongrel.rb:472:in></a> `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 <a href="http://0.3.12.4/lib/mongrel/rails.rb:64:in"><http://0.3.12.4/lib/mongrel/rails.rb:64:in></a> `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"><http://0.3.12.4/lib/mongrel.rb:425:in></a> `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"><http://0.3.12.4/lib/mongrel.rb:424:in></a> `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"><http://0.3.12.4/lib/mongrel.rb:495:in></a> `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"><http://0.3.12.4/lib/mongrel.rb:494:in></a> `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"><http://0.3.12.4/lib/mongrel.rb:483:in></a> `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"><http://0.3.12.4/lib/mongrel.rb:774:in></a> `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"><http://0.3.12.4/lib/mongrel.rb:772:in></a> `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"><http://0.3.12.4/bin/mongrel_rails:97:in></a> `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"><http://0.3.12.4/lib/mongrel/command.rb:163:in></a> `run'<BR>
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.12.4/bin/mongrel_rails:194 <a href="http://0.3.12.4/bin/mongrel_rails:194"><http://0.3.12.4/bin/mongrel_rails:194></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>