roc230 / spymemcached

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

get() timeout results in broken server connection #35

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
memcachedclient 2.1, 64 bit Centos, connecting to memcached 1.2.6

If a plain MemcachedClient get() throws a TimeoutException:

2008-09-03 10:29:32.532::WARN:  EXCEPTION
net.spy.memcached.OperationTimeoutException: Timeout waiting for value
        at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:771)
        at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:784)
        <clip... >
Caused by: java.util.concurrent.TimeoutException: Timed out waiting for
operation
        at
net.spy.memcached.MemcachedClient$OperationFuture.get(MemcachedClient.java:1437)
        at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:764)

then the memcached client connection to the server is in an unusable state.
All get() and put() operations fail. 

This has happened a couple of times when a GC has taken more than 1000ms
triggering the default 1000ms timeout.

Original issue reported on code.google.com by jpvirola...@gmail.com on 4 Sep 2008 at 2:55

GoogleCodeExporter commented 9 years ago
I have the same problem on Centos 64 bit and memcache server 1.2.6.

What can i make to change the timeout or resolve the bug?

Thx,
AVC

Original comment by arekczar...@gmail.com on 9 Oct 2008 at 2:29

GoogleCodeExporter commented 9 years ago
I added some code to attempt to reproduce this problem, but can't.

Specifically, I added a unit test that definitely times out and validates that 
it
does see an operation timeout exception, and that it can see a value afterwards:

http://github.com/dustin/java-memcached-client/commit/8c489ffa

If you guys can reproduce the failure with this test, or perhaps modify it in 
such a
way that will produce a failure, that'd be helpful.

Otherwise, I'm going to have to declare this invalid as I understand it.

Original comment by dsalli...@gmail.com on 19 Dec 2008 at 4:42

GoogleCodeExporter commented 9 years ago
I can reproduce this bug in my local environment.
Client OS: Windows XP
Server OS: Ubuntu

memcached 1.2.6
spymemcached 2.2

Code:

ConnectionFactory connectionFactory = new BinaryConnectionFactory();
MemcachedClient client =
           new MemcachedClient(
                   connectionFactory,
                   AddrUtil.getAddresses("remote-host:11211")
           );

client.set("key1", 30 * 60, "value1");
System.out.println(client.get("key1"));
client.shutdown();

Original comment by sskladch...@gmail.com on 6 Feb 2009 at 10:41

GoogleCodeExporter commented 9 years ago
sskladchikov,

Version 1.2.6 doesn't support a binary protocol.  You should have better luck 
with
DefaultConnectionFactory.

Original comment by dsalli...@gmail.com on 6 Feb 2009 at 10:17

GoogleCodeExporter commented 9 years ago
Do i need to shutdown the connection each time and reconnect it while setting or
getting the value from memcached? is it possible to have only one connection of
memcached?

Original comment by babybaby...@gmail.com on 22 Apr 2009 at 5:53

GoogleCodeExporter commented 9 years ago
If I try to get something without storing it first or cache does not have when 
get is
invoked, this exception is noticed

            MemcachedClient c =                     new MemcachedClient(
                    new BinaryConnectionFactory(), AddrUtil
                    .getAddresses("localhost" + ":"
                            + 11211));

            c.get("someKey");

Please let me know, how this can be resolved?

Original comment by kmukd...@gmail.com on 3 Oct 2009 at 2:59

GoogleCodeExporter commented 9 years ago
kmukdapu:  I have no idea what you're seeing.  Is your server running?  I 
pasted that
exact code into a new class, ran it, and verified that it returned null as 
expected.

Original comment by dsalli...@gmail.com on 4 Oct 2009 at 5:55

GoogleCodeExporter commented 9 years ago
Hi there,

I am seeing the same thing when I call get().  Did you guys find a solution for 
this?

I am running:

Server: 1.2.8
Client: Spy (memcached-2[1].3.1.jar)
JDK: 1.5

Windows Sever 2003 x64 SP2

Thanks!
Matt

Original comment by mattmcdo...@gmail.com on 12 Oct 2009 at 10:17

GoogleCodeExporter commented 9 years ago
This is a bit long standing because I've not been able to reproduce it and some 
of
the closest I've seen have involved people misconfiguring something  (such as 
the
user above who had too old a version of memcached while trying to use the binary
protocol).

I would gladly fix the bug if I could see it happen.  :(

Original comment by dsalli...@gmail.com on 12 Oct 2009 at 10:34

GoogleCodeExporter commented 9 years ago
Thanks for the quick reply. 

Could it be specific to 64 bit machines? I see first user also has a 64bit.

Also, should the versions I have work together?
Server: 1.2.8
Client: Spy (memcached-2[1].3.1.jar)

thanks,
Matt

Original comment by mattmcdo...@gmail.com on 12 Oct 2009 at 11:17

GoogleCodeExporter commented 9 years ago
My machine is 32 bit

I have tried both memcached server version 1.2.1 and 1.2.0 
(http://jehiah.cz/projects/memcached-win32/)

TEST CODE

    @Test
    public void shouldNotThrowException() throws IOException {
        MemcachedClient memcachedClient = new MemcachedClient( new 
BinaryConnectionFactory(), AddrUtil.getAddresses("127.0.0.1:11211"));
        long start = System.currentTimeMillis();
        memcachedClient.set("TEST_JAVA_VALUE", -1, "a");
        System.out.println("Set took " + (System.currentTimeMillis() - start) + 
"ms.");
        start = System.currentTimeMillis();
        String value  = (String)memcachedClient.get("TEST_JAVA_VALUE");
        System.out.println("Retrieve took " + (System.currentTimeMillis() -start) + 
"ms.");
    }

if i have tried the test code with 2.4.2 i get the exception;
        net.spy.memcached.OperationTimeoutException: Timeout waiting for value
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:853)
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:868)
if i have tried the test code with memcached 2.5
        net.spy.memcached.OperationTimeoutException: Timeout waiting for value
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:924)
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:939)

If i have used SSM, there is no problem, But when i try to use memcached 
directly as 
testcode above i get timeout exception.

net.spy.memcached.OperationTimeoutException: Timeout waiting for value

I ve checked my server is running.

Original comment by osmans...@gmail.com on 24 May 2010 at 1:28

GoogleCodeExporter commented 9 years ago
I was able to fix this by adding the time out, by overriding the get() method.

 MemcachedClient c =  new MemcachedClient(new BinaryConnectionFactory(),
                        AddrUtil.getAddresses("host:1port"));
java.util.concurrent.Future<Object> f = c.asyncGet(NAMESPACE +key);
Object o = f.get(1800, TimeUnit.SECONDS);

I know that less time out is good for the application because your application 
won't wait. But in my case, I have to build huge cache during some requests, 
which takes 20 minutes. The subsequent requests will be faster.

Thanks
Abhilash

Original comment by abhih...@gmail.com on 28 Oct 2010 at 7:00

GoogleCodeExporter commented 9 years ago
I know this issue is closed, but I did want to note that I've enhanced the test 
for this a bit while working on issue 136.  The updated test definitely shows 
that once a timeout occurs, the client can recover.

Original comment by ingen...@gmail.com on 3 Jan 2011 at 1:18