views:

614

answers:

2

I'm using the awesome cache-money gem with a large rails project. I frequently get these exceptions

MemCache::MemCacheError: execution expired"

There doesn't seem to be a rhyme nor reason. What exactly does this mean, and how to fix?

EDIT:

Here is a representative stack trace:

lib/authenticated_system.rb:100:in `login_from_session'
lib/authenticated_system.rb:12:in `current_user'
lib/authenticated_system.rb:6:in `logged_in?'
lib/authenticated_system.rb:35:in `authorized?'
lib/authenticated_system.rb:53:in `login_required'

The line in question is from RESTful_Authentication:

self.current_user = User.find(session[:user_id]) if session[:user_id]
A: 

I've heard through teammates that Rails' default memcache client does not attempt to automatically reconnect to the memcache daemon if for some reason it stops and restarts, though I haven't confirmed it myself. The fiveruns memcache-client library fixes this issue.

Brian Guthrie
A: 

I think that Michael Simons answered my question via his blog post. In essence, this is a known problem that exists between Passenger and Memcached.

Here was Michael's fix:

# environment.rb
begin
   PhusionPassenger.on_event(:starting_worker_process) do |forked|
     if forked
       # We're in smart spawning mode, so...
       # Close duplicated memcached connections - they will open themselves
       CACHE.reset
     end
   end
# In case you're not running under Passenger (i.e. devmode with mongrel)
rescue NameError => error
end
Matt Darby