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

Go Back   LiteSpeed Support Forums > External Applications > Ruby/Rails > Problem with Memcache / forking

Reply
 
Thread Tools Display Modes
  #1  
Old 05-13-2009, 12:30 PM
jerrett jerrett is offline
Member
 
Join Date: Jan 2007
Posts: 13
Default Problem with Memcache / forking

http://www.modrails.com/documentatio...haring_harmful


I'm running into a similar problem with Litespeed... Memcache is returning incorrect objects, sometimes.

Any ideas of a solution? How would one go about reseting the connection to memcache each time it's forked, if this is the problem?

Last edited by jerrett; 05-13-2009 at 01:07 PM..
Reply With Quote
  #2  
Old 05-13-2009, 01:07 PM
jerrett jerrett is offline
Member
 
Join Date: Jan 2007
Posts: 13
This also just started happening with the new Litespeed and Rails 2.3 (Rack)..
Reply With Quote
  #3  
Old 05-13-2009, 01:37 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Yes, need to reset the connection to memcache. Just close all connections after the initialization.
Reply With Quote
  #4  
Old 05-13-2009, 01:42 PM
jerrett jerrett is offline
Member
 
Join Date: Jan 2007
Posts: 13
Would it be a good place to do this in environment.rb, or is that not going to get executed when it's forked?
Reply With Quote
  #5  
Old 05-13-2009, 01:47 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
It should be fine. environment.rb only get loaded once I think.
Reply With Quote
  #6  
Old 05-13-2009, 02:01 PM
jerrett jerrett is offline
Member
 
Join Date: Jan 2007
Posts: 13
Doesn't seem to help, if it's only loaded once i'm assuming that means it won't reset when the process gets forked.. where would we hook into that?
Reply With Quote
  #7  
Old 05-13-2009, 02:23 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
maybe it is too early as the connection to memcache was established after loading environment.rb.

Please try to patch RailsRunner.rb, at where "ActiveRecord::Base.clear_active_connections!" is called.
Reply With Quote
  #8  
Old 05-13-2009, 06:45 PM
jerrett jerrett is offline
Member
 
Join Date: Jan 2007
Posts: 13
It worked, but we had to manually create a cache object for the session store so we could call reset on it (and then just SESSION_CACHE.reset right before the clear_active_connections!)

In the edge of rails it looks like there is a way to access the Session memcache instance, which would mean it could in the future be fixed in RailsRunner.rb by default.. something to look forward to perhaps
Reply With Quote
  #9  
Old 05-13-2009, 08:18 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Yes, please keep us posted when it is available, so we can add som generic code like "clear_active_connections!" to address it in RailsRunner.rb .
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 06:50 AM.



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