Chantz Chantz - 19 days ago 7
Java Question

HOWTO Resolve warning messages of "restributing to another node" when using Spymemcached client library for memcached server

I am using spymemcached client library

v2.8.0
provided by couchbase folks. The memcached server installed is version
1.4.13
.

The configuration for memcached is pretty basic >
-m 64 -p 11211 -u memcache -l 127.0.0.1
.

I am able to proper get, set, delete requests using the client library. But going through my logs I notice the warning messages from the spymemcached library like so -

WARN net.spy.memcached.MemcachedConnection: Could not redistribute to another node, retrying primary node for ...


I am not sure why is trying to redirect to another node in the cluster if there does not exist one.

I am connecting to the cache client using the below code -

String address = 127.0.0.1:11211;
new MemcachedClient(new ConnectionFactoryBuilder().setDaemon(true).build(), AddrUtil.getAddresses(address));


Any help appreciated.

Answer

By default Spymemcached will redistribute an operation to an different node if the primary node is not available. If you had another node this would happen, but since there is only one then redistributing is the same as retrying the operation on the primary node. In your case this message is a little bit confusing. If you never want to redistribute an operation then you can do the following.

String address = 127.0.0.1:11211;
new MemcachedClient(new ConnectionFactoryBuilder().setDaemon(true).setFailureMode(FailureMode.RETRY).build(), AddrUtil.getAddresses(address));

If sounds like your client might have lost connection to the server and reconnected at some point.