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

1

7

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.

Tashia answered 16/5, 2012 at 14:29 Comment(0)
S
5

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.

Synodic answered 17/5, 2012 at 7:24 Comment(3)
but dong so will not cause any overhead or potential loss of operations... right?Tashia
You shouldn't ever lose operations. In the worst case scenario your operation might timeout if the node is unreachable. If you only plan on using a single server then redistribute and retry are exactly the same. You can also take a look at the code path here: github.com/dustin/java-memcached-client/blob/master/src/main/…Synodic
This did not work for me. I can still se this warning in the logs : Could not redistribute to another node, retrying primary node forNinon

© 2022 - 2024 — McMap. All rights reserved.