Problem with Memcache / forking

Discussion in 'Ruby/Rails' started by jerrett, May 13, 2009.

  1. jerrett

    jerrett New Member

    Last edited: May 13, 2009
  2. jerrett

    jerrett New Member

    This also just started happening with the new Litespeed and Rails 2.3 (Rack)..
  3. mistwang

    mistwang LiteSpeed Staff

    Yes, need to reset the connection to memcache. Just close all connections after the initialization.
  4. jerrett

    jerrett New Member

    Would it be a good place to do this in environment.rb, or is that not going to get executed when it's forked?
  5. mistwang

    mistwang LiteSpeed Staff

    It should be fine. environment.rb only get loaded once I think.
  6. jerrett

    jerrett New Member

    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?
  7. mistwang

    mistwang LiteSpeed Staff

    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.
  8. jerrett

    jerrett New Member

    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 :)
  9. mistwang

    mistwang LiteSpeed Staff

    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 .

Share This Page