mgalushka / spymemcached

Automatically exported from code.google.com/p/spymemcached
0 stars 0 forks source link

Error while using idle MemcachedClient... #264

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Memcache 2.7.3 on windows...

Am using spy memcache……Am getting following error while making an operation 
- get/set on MemcachedClient which is idle for some period of time….how to 
check if the MemcachedClient is alive????

My code sample…

public void setMemcachedServersList(List memcachedServersList) {

this.memcachedServersList = memcachedServersList;
try {
m = new MemcachedClient?[getMemcachedClientPoolSize()]; for (int i = 0; i < 
m.length; i ++) {
MemcachedClient? mc = new MemcachedClient?(new 
BinaryConnectionFactory?(),AddrUtil?.getAddresses(getMemcachedServersStr())); 
mi? = mc;
}
} catch (Exception e) {
e.printStackTrace();
}
}

public MemcachedClient? getMemcachedClient() {

MemcachedClient? mc= null; try {
int i = (int) (Math.random() m.length); mc = mi?;
} catch(Exception e) {
return mc;
} return mc;
}

public Object get(String key) {

// Try to get a value, for up to getTimeout seconds, and cancel if it doesn’t 
return
Object value = null; Future f = null; try {
f = getMemcachedClient().asyncGet(key);
value = f.get(getLookUpTimeout(),TimeUnit?.SECONDS);
} catch (Exception e) {
e.printStackTrace();
f.cancel(true); //Handle Exception
} return value;
}

Exception during get operation….

2012-12-17 20:03:27.352 INFO net.spy.memcached.MemcachedConnection?: 
Reconnecting due to exception on {QA 
sa=mail-memcache02.lax.qa1.untd.com/10.111.30.46:1918, #Rops=1, #Wops=0, #iq=0, 
topRop=Cmd: 0 Opaque: 69 Key: WRONG_PWD_COUNT_FOR_AN_IP-11.245.28.134, 
topWop=null, toWrite=0, interested=1} java.io.IOException: An established 
connection was aborted by the software in your host machine

at sun.nio.ch.SocketDispatcher?.read0(Native Method) at 
sun.nio.ch.SocketDispatcher?.read(Unknown Source) at 
sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source) at 
sun.nio.ch.IOUtil.read(Unknown Source) at 
sun.nio.ch.SocketChannelImpl?.read(Unknown Source) at 
net.spy.memcached.MemcachedConnection?.handleReads(MemcachedConnection?.java:478
) at 
net.spy.memcached.MemcachedConnection?.handleIO(MemcachedConnection?.java:418) 
at 
net.spy.memcached.MemcachedConnection?.handleIO(MemcachedConnection?.java:275) 
at net.spy.memcached.MemcachedClient?.run(MemcachedClient?.java:2030)

Original issue reported on code.google.com by shiva.cs...@gmail.com on 18 Dec 2012 at 12:22

GoogleCodeExporter commented 9 years ago
It appears the connection is getting dropped, but the client won't know until 
it tries to use it.  I think you need to solve whatever is aborting the TCP 
connection there.

If it is a get operation, you can probably simply retry it.  The client library 
won't do that for you, but it's simple enough to do from a do-while wrapping a 
try/catch.

I don't think there's anything we should do from the client here.

Original comment by ingen...@gmail.com on 1 Jan 2013 at 7:44