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

Go Back   LiteSpeed Support Forums > External Applications > Ruby/Rails > Rails 2.2 cache_classes problem.

Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2008, 05:52 AM
Grzegorz Derebecki Grzegorz Derebecki is offline
Senior Member
 
Join Date: Jun 2007
Posts: 92
Default Rails 2.2 cache_classes problem.

Rails 2.2 is almost done. I'm testing rc release and in railties/lib/initializer they add

require_dependency

As far as i remember litespeed lsapi has problem with this. Let me explain:

When we turn on (in production mode) config.cache_classes = true
Then rails 2.2 will load all models, helpers, controllers only once at first start. But it generate strange errors like:

i will show some exemples:
undefined method `limit' for nil:NilClass
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session/active_record_store.rb:73:in `data_column_size_limit'
----------------------------------------------------------------------
undefined method `zero?' for "1":String
[RAILS_ROOT]/app/controllers/movies/home_controller.rb:17:in `index'

movies/home_controller.rb: 17:
@review = current_movie.random_review unless current_movie.reviews_count.zero?

>> Movie.first.reviews_count.class
Fixnum (it is INTEGER in DB then don't know why it is changed to STRING)

----------------------------------------------------------------------
undefined method `all_hashes' for nil:NilClass
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:564:in `select'


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

This errors are only if cache_classes = true but without this it is imposible to run rails application fast.

Rails 2.1 and before didn't used require_dependency to load all classes but some time ago i was traing use it and has simillar isuses (errors in strange places) http://litespeedtech.com/support/for...ead.php?t=1712
Reply With Quote
  #2  
Old 11-21-2008, 09:40 AM
Grzegorz Derebecki Grzegorz Derebecki is offline
Senior Member
 
Join Date: Jun 2007
Posts: 92
Default New information

I make some test to figure who is guilty

I change LSAPI to FASTCGI and my application works now ok with rails 2.2.2 and config.cache_classes = true.

This meen the problem is with lsapi
Reply With Quote
  #3  
Old 11-22-2008, 07:02 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
We will look into it. Is it possible to send a test application that we can reproduce the problem?
Reply With Quote
  #4  
Old 11-23-2008, 12:32 AM
Grzegorz Derebecki Grzegorz Derebecki is offline
Senior Member
 
Join Date: Jun 2007
Posts: 92
Quote:
Originally Posted by mistwang View Post
We will look into it. Is it possible to send a test application that we can reproduce the problem?
sorry but i can't do it (it is big webside http://fdb.pl)

i know it is hard to find bug i can test your results when you try fix it.
Reply With Quote
  #5  
Old 11-24-2008, 02:04 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
I don't mean to get your site code. Just wondering if it is possible to quickly create a simple application to reproduced this problem with Rails 2.2.

At this point, we do really know where to start to trouble shoot this problem.
Reply With Quote
  #6  
Old 11-30-2008, 03:59 PM
Grzegorz Derebecki Grzegorz Derebecki is offline
Senior Member
 
Join Date: Jun 2007
Posts: 92
Quote:
Originally Posted by mistwang View Post
At this point, we do really know where to start to trouble shoot this problem.
I had solution for described problem.

1. I use dispatcher.lsapi not RailsRunner.rb.

When i switched to RailsRunner my webpage starts working ok on lsapi BUT...
when i restart server there was errors:

Code:
Mysql::Error: MySQL server has gone away: SHOW FIELDS FROM `users`
Problem is witch db connections:

Code:
#Close all DB connections established during initialization
ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord::Base)

while LSAPI.accept != nil
        Dispatcher.dispatch
end
When lsapi starts ruby process and forks them first request get error with connection to db (about server gone) so i make litle change in dispatcher:


Code:
#Close all DB connections established during initialization
ActiveRecord::Base.connection.disconnect! and @reconnect = true if defined?(ActiveRecord::Base)

while LSAPI.accept != nil
        if defined?(ActiveRecord::Base) and @reconnect
          ActiveRecord::Base.connection.reconnect!
          @reconnect = false
        end
        Dispatcher.dispatch
end
it reconnect only at first request ofcorse.
Reply With Quote
  #7  
Old 11-30-2008, 05:12 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
That's great, we will try the fix, does it work with earlier releases of Rails?
Reply With Quote
  #8  
Old 11-30-2008, 05:24 PM
Grzegorz Derebecki Grzegorz Derebecki is offline
Senior Member
 
Join Date: Jun 2007
Posts: 92
i tested it only with 2.2 but it should works ok in all rails version becouse disconnect! and reconnect! are implemented long time and nothing else is used here.
Reply With Quote
  #9  
Old 11-30-2008, 06:21 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Tried on 2.1.0, works well.
Reply With Quote
  #10  
Old 12-04-2008, 03:53 PM
senihele senihele is offline
New Member
 
Join Date: Aug 2008
Posts: 4
I also had this problem, when I upgraded to rails 2.2.2 on my production server - 503 error - a very unpleasant surprise. When I manually ran the site with Mongrel, I had no problems. I changed the Rails context to development everything worked again. Since the site sees very limited testing right now, I can live with this for the moment, but I hope the issue is resolved quickly.

Last edited by senihele; 12-04-2008 at 03:56 PM..
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


All times are GMT -7. The time now is 08:57 AM.



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