NullReferenceException at MemcachedNode+InternalPoolImpl.<Dispose>

I recently updated to Couchbase Client Library .NET 1.3.4 and I’ve been experiencing daily incidences of the following NullReferenceException:

System.NullReferenceException
Stack:
at Enyim.Caching.Memcached.MemcachedNode+InternalPoolImpl.b__7(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.TimerQueueTimer.CallCallback()
at System.Threading.TimerQueueTimer.Fire()
at System.Threading.TimerQueue.FireNextTimers()

The exception is particularly problematic because it appears to happen within the Timer callback here: https://github.com/couchbase/couchbase-net-client/blob/master/src/Enyim.Caching/Memcached/MemcachedNode.cs#L472-L498 which means that it bubbles up as an AppDomain.CurrentDomain.UnhandledException and terminates my process

I’m going to enable logging as described here (http://docs.couchbase.com/couchbase-sdk-net-1.3/#configuring-logging) in hopes that I get some more information to go on

Any other suggestions?

Hi darryljjennings -

I am curious what version were using before 1.3.4? Also, are using a MemcachedClient or a CouchbaseClient client instance? Note that you should probably be using the memcached bucket via the CouchbaseClient; it has the newer connection pool and is the officially support client.

From what you have described, this looks like a bug. However, this code hasn’t changed since 1.2.X, so I am curious as to which version you upgraded from.

Also, you can always file a jira ticket here: http://www.couchbase.com/issues/browse/NCBC

Or, even better if you think you can do a patch, fix it and send a pull request and assuming it’s accepted, will go into a future release and you will be credited as a contributor.

Thanks,

-Jeff

Thanks Jeff

I updated from Enyim.Memcached 2.11.0 - https://www.nuget.org/packages/EnyimMemcached/2.11.0, so the 1.2.X changes may be relevant

I created a patch with this change https://github.com/darryljjennings/couchbase-net-client/commit/e4a757a320b988446ab0e5a63db314c67dc3818f and I’ll send a pull request once I’m convinced that it resolves the problem

Cheers,
Darryl

“I updated from Enyim.Memcached 2.11.0 - https://www.nuget.org/packages/EnyimMemcached/2.11.0, so the 1.2.X changes may be relevant”

Ah! That’s actually a separate fork of Enyim.Memcached that we don’t maintain at Couchbase. If possible, I would try to upgrade your client instance as well - just swap your MemcachedClient instances to CouchbaseCient, the interfaces should be the same, but you’ll get a more updated fork of Enyim.Memcached since the CouchbaseClient sits on top of it.

Switching to CouchbaseClient will likely resolve this issue, since it’s using a different socket pool implementation.

Thanks,

Jeff