roc230 / spymemcached

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

Queue full exception with v2.3.1 #176

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
spymemcache 2.3.1 
memcached 1.4.4
Both of the above on Linux version 2.6.18-164.15.1.0.1.el5 
(mockbuild@ca-build9.us.oracle.com)

When I test executing mc.set(x,y) for a large times, e.g 
35 Million, Following exception would be thrown all the time. I saw Issue#38 
for the same exception but said fixed in v2.2. Though I'm using 2.3.1 still 
facing same issue. Any help would be higly appreciated. 

java.lang.IllegalStateException: Queue full
    at java.util.AbstractQueue.add(AbstractQueue.java:71)
    at java.util.concurrent.ArrayBlockingQueue.add(ArrayBlockingQueue.java:209)
    at net.spy.memcached.protocol.TCPMemcachedNodeImpl.addOp(TCPMemcachedNodeImpl.java:241)
    at net.spy.memcached.MemcachedConnection.addOperation(MemcachedConnection.java:553)
    at net.spy.memcached.MemcachedConnection.addOperation(MemcachedConnection.java:543)
    at net.spy.memcached.MemcachedClient.addOp(MemcachedClient.java:256)
    at net.spy.memcached.MemcachedClient.asyncStore(MemcachedClient.java:287)
    at net.spy.memcached.MemcachedClient.set(MemcachedClient.java:612)
    at net.spy.memcached.MemcachedClient.set(MemcachedClient.java:646)

Original issue reported on code.google.com by lakshmip...@gmail.com on 4 May 2011 at 7:28

GoogleCodeExporter commented 9 years ago
I would like to which version should use instead of v2.3.1 so I do not run in 
to the above exception even though I write millions of items continuously. 

Writing millions of items is something we do regularly. So, any help would be 
appreciated.

Original comment by lakshmip...@gmail.com on 4 May 2011 at 7:36

GoogleCodeExporter commented 9 years ago
There is a method for waiting for queues to get through some of the work, or I 
believe you can pass in your own queue implementation.  2.3.1 is quite old 
though, can you update to 2.5?

Original comment by ingen...@gmail.com on 4 May 2011 at 10:47

GoogleCodeExporter commented 9 years ago
Could you confirm that this issue doesn't exist in v2.5 ?

If not, could you please let me know the method that exists to wait for the 
queue to to get through some of the work so I can use the sam?

Original comment by lakshmip...@gmail.com on 5 May 2011 at 2:22

GoogleCodeExporter commented 9 years ago
I used v2.5, but landed on a new exception instead of queue full (below). 
I tried using waitforqueue(), but this doesn't ensure not to hit queue full 
error ever. So, looking for ever a solution for it. 

java.lang.IllegalStateException: Timed out waiting to add 
net.spy.memcached.protocol.ascii.StoreOperationImpl@6143408f(max wait=10000ms)
    at net.spy.memcached.protocol.TCPMemcachedNodeImpl.addOp(TCPMemcachedNodeImpl.java:273)
    at net.spy.memcached.MemcachedConnection.addOperation(MemcachedConnection.java:602)
    at net.spy.memcached.MemcachedConnection.addOperation(MemcachedConnection.java:582)
    at net.spy.memcached.MemcachedClient.addOp(MemcachedClient.java:277)
    at net.spy.memcached.MemcachedClient.asyncStore(MemcachedClient.java:314)
    at net.spy.memcached.MemcachedClient.set(MemcachedClient.java:691)

Original comment by lakshmip...@gmail.com on 5 May 2011 at 9:53

GoogleCodeExporter commented 9 years ago
WaitforQueues():
I tried using waitforQueues() with various timings but once or twice ran in to 
the same exception though was successful occasionally.  

I would like to ensure I never run in to this issue. 

v2.5 jar:
I have set the following in JVM start options. Still I get 
java.lang.IllegalStateException: Timed out waiting to add 
net.spy.memcached.protocol.ascii.StoreOperationImpl@6143408f(max wait=10000ms). 
Where max wait shows 10seconds where as I have set 20 seconds for timeout in my 
JVM start options. Please suggest if any setting need to be added/modified.

-Dnet.spy.memcached.DefaultConnectionFactory.defaultOperationTimeout=20000
-Dnet.spy.memcached.DefaultConnectionFactory.defaultOpQueueLen=100 
-Dnet.spy.memcached.DefaultConnectionFactory.defaultReadBufferSize=1048576 

Original comment by lakshmip...@gmail.com on 6 May 2011 at 10:29

GoogleCodeExporter commented 9 years ago
The reason for this issue is the asynchronous characteristic of "set" function, 
which puts your request into a queue and returns immediately, regardless of 
whether the work has been done or not. If you set items too fast, the queue 
will be full and the exception is thrown out. One solution is to get the item 
you have just set before setting another item, forcing 
the program to wait until the work has been done. 
e.g :
mc.set(x,y)
mc.get(x)
...

Original comment by linhu...@gmail.com on 19 Mar 2012 at 12:23

GoogleCodeExporter commented 9 years ago
Can someone verify that this issue is still present in Spy 2.8.x?

Original comment by mikewie...@gmail.com on 3 Jun 2012 at 6:36

GoogleCodeExporter commented 9 years ago
maybe this reason(all the versions): 
net.spy.memcached.MemcachedConnection
 public void addOperations(final Map<MemcachedNode, Operation> ops) {

    for (Map.Entry<MemcachedNode, Operation> me : ops.entrySet()) {
      final MemcachedNode node = me.getKey();
      Operation o = me.getValue();
      o.setHandlingNode(node);
      o.initialize();
//!!! when exceptions here, Operations had been added can't be cancel or execute
      node.addOp(o);
      addedQueue.offer(node);
    }
    Selector s = selector.wakeup();
    assert s == selector : "Wakeup returned the wrong selector.";
  }

Original comment by syu....@gmail.com on 29 Nov 2012 at 5:44