petergoldstein / dalli

High performance memcached client for Ruby
MIT License
3.1k stars 450 forks source link

NoMethodError when memcache server is not running #196

Closed mavenlink closed 11 years ago

mavenlink commented 12 years ago

We are testing a condition where the memcached server is unavailable.

In memcache-client a sensible MemCacheError is raised: MemCache::MemCacheError: No connection to server (localhost:11211 DEAD (Errno::ECONNREFUSED: Connection refused - connect(2)), will retry at Mon Apr 09 12:23:52 -0700 2012)

However in Dalli we get a much less useful result:

NoMethodError: private methodsplit' called for true:TrueClass from /Users/mavenlink/.rvm/gems/ree-1.8.7-2012.01@mavenlink/gems/dalli-2.0.2/lib/dalli/server.rb:29:in initialize' from /Users/mavenlink/.rvm/gems/ree-1.8.7-2012.01@mavenlink/gems/dalli-2.0.2/lib/dalli/client.rb:234:innew' from /Users/mavenlink/.rvm/gems/ree-1.8.7-2012.01@mavenlink/gems/dalli-2.0.2/lib/dalli/client.rb:234:in ring' from /Users/mavenlink/.rvm/gems/ree-1.8.7-2012.01@mavenlink/gems/dalli-2.0.2/lib/dalli/client.rb:233:inmap' from /Users/mavenlink/.rvm/gems/ree-1.8.7-2012.01@mavenlink/gems/dalli-2.0.2/lib/dalli/client.rb:233:in ring' from /Users/mavenlink/.rvm/gems/ree-1.8.7-2012.01@mavenlink/gems/dalli-2.0.2/lib/dalli/client.rb:249:inperform' from /Users/mavenlink/.rvm/gems/ree-1.8.7-2012.01@mavenlink/gems/dalli-2.0.2/lib/dalli/client.rb:126:in add_without_newrelic_trace' from (eval):7:inadd' from /Users/mavenlink/.rvm/gems/ree-1.8.7-2012.01@mavenlink/gems/newrelic_rpm-3.3.1/lib/new_relic/agent/method_tracer.rb:242:in trace_execution_scoped' from (eval):4:inadd' from /Users/mavenlink/workspace/morlock/lib/morlock/gem_client.rb:30:in add' from /Users/mavenlink/workspace/morlock/lib/morlock/base.rb:13:inlock' from (irb):2`

caseysackett commented 12 years ago

Another place where dalli does not gracefully handle memcached not running is when invalidating a cache. Ideally it would rescue from this exception and output an informative message, like it does in other places.

Dalli::RingError (No server available):
  dalli (2.0.2) lib/dalli/ring.rb:45:in `server_for_key'
  dalli (2.0.2) lib/dalli/client.rb:249:in `perform'
  dalli (2.0.2) lib/dalli/client.rb:138:in `delete'
  dalli (2.0.2) lib/active_support/cache/dalli_store.rb:75:in `delete'
  actionpack (3.2.3) lib/action_controller/caching/fragments.rb:117:in `block in expire_fragment'
  actionpack (3.2.3) lib/action_controller/caching/fragments.rb:123:in `block in instrument_fragment_cache'
  activesupport (3.2.3) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.3) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.3) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.3) lib/action_controller/caching/fragments.rb:123:in `instrument_fragment_cache'
  actionpack (3.2.3) lib/action_controller/caching/fragments.rb:113:in `expire_fragment'
mperham commented 12 years ago

@caseysackett Thanks, that's a bug which I can easily fix.

mperham commented 12 years ago

@mavenlink I honestly don't see how you are getting that trace. Are you monkeypatching Dalli?

mavenlink commented 12 years ago

We saw it in https://github.com/mavenlink/morlock (our new locking gem) when we either didn't start a memcached server, or killed the running one.