LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > LiteSpeed Web Server > Bug Reports > Rails on LSAPI, db connection dropping..

Reply
 
Thread Tools Display Modes
  #1  
Old 09-07-2006, 02:27 PM
marko marko is offline
New Member
 
Join Date: Sep 2006
Posts: 3
Default Rails on LSAPI, db connection dropping..

We have a Rails application running on the latest Litespeed web server (2.2). It connects to a Postgresql DB on another machine. Both machines are running Ubuntu 6.06 (with latest updates).

Per our programmer's comments, we seem to experience idle connection timeouts. After his initial observation, he did another test logging in and out of his application. First try after restart was fine. Next attempt after waiting 8 minutes or so, and the db connection was dropped again.

With the same configuration running Mongrel, the connection stays persistent.. Is this something you guys are aware of, and can it be resolved through better setup or configuration.. Or is this a bug and we need to use Mongrel a little longer?..

Many many thanks in advance to you for your help looking into this issue.

-------------------------

I finally got Pool running in its dual roles this morning. My first String testing went well and everything was fast. I logged in again to check the ordering of the active devices and everything was still fine. I logged in a 3rd time to check the Alerts Report and I got a Rails error.

I checked the logs and the error was because the database connection was terminated.

In all the time we have been running Mongrel on both sides in production the remote database connection has never been terminated.

This has me very concerned. I don't know if LiteSpeed is dropping the connection now that it controls the Ruby instance.

Can you please do some research to see if others have seen a similar problem? I am reaching the point where I don't have enough time left in the schedule for issues so if we have a major problem here I am going to have to fall back on Mongrel.

Thanks.

-- Rick
Reply With Quote
  #2  
Old 09-08-2006, 09:36 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
That's probably because LSAPI fork children processes off a parent process with Rails framework initialized, if a DB connection has been established during framework initialization, the connection pool in children processes will be messed up. The solution is to close all established DB connection after framework initialization.

Please try the solution below, replace lsws/fcgi-bin/RailsRunner.rb with the following code. Basically, it calls ActiveRecord::Base.clear_active_connections! to close all active DB connections before calling LSAPI.accept.

Code:
#!/usr/bin/ruby

require "#{ENV['RAILS_ROOT']}/config/environment"

require "dispatcher"
require "lsapi"

ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord::Base)

while LSAPI.accept != nil
        Dispatcher.dispatch
end
Please let me know it fix the problem or not.
Thanks!
Reply With Quote
  #3  
Old 09-08-2006, 01:11 PM
mavaca mavaca is offline
New Member
 
Join Date: Sep 2006
Posts: 6
Talking Problem Solved!

Thanks for the recommended solution. That did solve the problem.

I have been monitoring the child processes and database connections as we used the application today. Looks like this was a house keeping solution. I still see database connections drop off after periods of idleness, but now the application is reconnected as the next user logs in.

My boss is jumping up and down with the performance increase LiteSpeed is providing us over Mongrel. Looks like it will now be easy to get dollars from him to upgrade to your enterprise version.

You guys have a great product. Keep up the good work!
Reply With Quote
  #4  
Old 09-08-2006, 01:23 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Thanks for the update.
That's great!
We will release 2.2.1 with the fixed RailsRunner.rb on Monday.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setup for Rails via Litespeed Ruby LSAPI Justin Ruby/Rails 2 12-08-2007 07:19 PM
rails lsapi wiki clarification dr_seus Ruby/Rails 3 07-11-2007 03:45 PM
Rails, LSAPI, Rewrites, Contexts, Authentication mabonyi Install/Configuration 2 02-11-2007 06:10 PM
Standard 2.2.5 + LSAPI + Rails uses up all processes dirkbj Bug Reports 7 12-01-2006 08:52 AM
can't get rails app to run with lsapi Shelby Ruby/Rails 7 08-07-2006 02:12 PM


All times are GMT -7. The time now is 05:35 AM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.