ConnectionTimeOut

463 views
Skip to first unread message

Jarlakxen

unread,
Nov 30, 2011, 2:52:46 PM11/30/11
to spymemcached
Hi,

I was looking through the code and i noticed that spymemcached doesn't
handle a connection timeout during a reconnect.

In the code, i see that it always uses:

ch.connect(qa.getSocketAddress())

instead of something like this:

ch.socket().connect(qa.getSocketAddress(), timeout);

Is it correct, that there's no timeout?

ingenthr

unread,
Jan 7, 2012, 5:18:05 PM1/7/12
to spymemcached
The timeout for operations destined for that node are handled at a
higher level in the client.

The client just keeps on trying. I think (not certain) with the
continuous operation timeout, that connect attempt will eventually be
thrown away and tried again, so it effectively does the same thing.

Have you run into an issue, or was it just something you've observed?

SONAL AGARWAL

unread,
May 1, 2013, 7:49:53 AM5/1/13
to spymem...@googlegroups.com

Hi,

Can you tell me how to configure spymemcached properties via hibernate?
We are using com.googlecode.hibernate.memcached.MemcachedCacheProvider class as hibernate.cache.provider_class
I have found property to confgiure operationTimeout but could not find way to configure maxReconnectDelay or FailureMode, or any other way to set connection timeout.

If server crashes down or is unavailable, we dont want client to retry again n again for that request to connect to server.
I am getting lot of exceptions:

2013-05-01 04:48:39.821 WARN net.spy.memcached.MemcachedConnection:  Closing, and reopening {QA sa=localhost/127.0.0.1:11211, #Rops=0, #Wops=2, #iq=0, topRop=null, topWop=net.spy.memcached.protocol.ascii.StoreOperationImpl@45ae90c9, toWrite=0, interested=0}, attempt 141.
2013-05-01 04:49:09.851 INFO net.spy.memcached.MemcachedConnection:  Reconnecting {QA sa=localhost/127.0.0.1:11211, #Rops=0, #Wops=2, #iq=0, topRop=null, topWop=net.spy.memcached.protocol.ascii.StoreOperationImpl@45ae90c9, toWrite=0, interested=0}
2013-05-01 04:49:09.852 INFO net.spy.memcached.MemcachedConnection:  Connection state changed for sun.nio.ch.SelectionKeyImpl@261b2759
2013-05-01 04:49:09.852 INFO net.spy.memcached.MemcachedConnection:  Reconnecting due to failure to connect to {QA sa=localhost/127.0.0.1:11211, #Rops=0, #Wops=2, #iq=0, topRop=null, topWop=net.spy.memcached.protocol.ascii.StoreOperationImpl@45ae90c9, toWrite=0, interested=0}
java.net.ConnectException: Connection refused
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:567)
    at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:414)
    at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:278)
    at net.spy.memcached.MemcachedClient.run(MemcachedClient.java:1981)

Matt Ingenthron

unread,
May 1, 2013, 3:25:45 PM5/1/13
to spymem...@googlegroups.com
At the moment, that's done through code so it'd be up to the hibernate plugin.

That said, what I see from your logs actually is what you probably want.  It shows the client detecting a closed connection, then closing and reopening that connection in background on it's own IO thread.

Your application requests may proceed just fine to the alternate node if you're using the Ketama NodeLocator.

Does that help?

Matt


--
You received this message because you are subscribed to the Google Groups "spymemcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spymemcached...@googlegroups.com.

To post to this group, send email to spymem...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Message has been deleted

SONAL AGARWAL

unread,
May 2, 2013, 2:33:10 AM5/2/13
to spymem...@googlegroups.com
Hi,

I am using below entries for hibernate memcached :
        <entry key="hibernate.show_sql" value="false" />
        <entry key="hibernate.cache.use_second_level_cache" value="true"/>
        <entry key="hibernate.cache.use_query_cache" value="true" />
        <entry key="hibernate.cache.provider_class" value="com.googlecode.hibernate.memcached.MemcachedCacheProvider" />
        <entry key="hibernate.memcached.operationTimeout" value="500" />

I want something like this to set failuremode and max reconnect delay :

        <entry key="hibernate.memcached.maxReconnectDelay" value="5" />
        <entry key="hibernate.memcached.timeoutExceptionThreshold" value="50" />

As configuring hibernate.cache.provider_class" as "com.googlecode.hibernate.memcached.MemcachedCacheProvider"
just uses all default values along with DefaultConnectionFactory, for creating memcached client.

I checked the source code of hibernate-memcached, i am not using any alternate node, just one memcached instance running, just wanted that if connection is not available to memcached server, it should not try to reconnect again n again for that request, as it causes application to slow down significantly, instead, it should just get data from database, after first trial.
Is there any way we can do this?


-Sonal
Reply all
Reply to author
Forward
0 new messages