roc230 / spymemcached

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

Get IllegalArgumentException when reading from memcached in a tight loop #179

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the product are you using? On what operating system?
memcachedclient 2.6 release running Ubuntu 11.04 release with memcached 1.4.5

Tell me more...
When running a unit test that accesses 5 memcached servers in a tight loop, I 
get the following exception from the Memcached IO thread (which then died after 
I let it exception continue and no more read/write operations could succeed):

Thread [Memcached IO over {MemcachedConnection to /127.0.0.1:11211 
/127.0.0.1:11212 /127.0.0.1:11213 /127.0.0.1:11214 /127.0.0.1:11215}] 
(Suspended (exception IllegalArgumentException))    
    GetOperationImpl(BaseOperationImpl).isTimedOut(long) line: 179  
    AsciiMemcachedNodeImpl(TCPMemcachedNodeImpl).fillWriteBuffer(boolean) line: 165 
    MemcachedConnection.handleWrites(SelectionKey, MemcachedNode) line: 365 
    MemcachedConnection.handleInputQueue() line: 254    
    MemcachedConnection.handleIO() line: 162    
    MemcachedClient.run() line: 1622    

This usually happens after I kill one of the memcached servers, but it does 
happen when the memcached server is not taken down. I then changed 
BaseOperationImpl.isTimedOut to not throw the IllegalArgumentException (new 
code shown below) and that seemed to have fixed the issue.

        public boolean isTimedOut(long ttlMillis) {
                long elapsed = System.nanoTime();
                long ttlNanos = ttlMillis * 1000 * 1000;
                if (elapsed - creationTime > ttlNanos) {
                        assert (state != OperationState.READING || state != OperationState.COMPLETE);
                        this.transitionState(OperationState.TIMEDOUT);
                        timedOutUnsent = true;
                        timedout = true;
                } else {
                        if (timedout) {
                                getLogger().info("Operation already timed out");
                        }
                }
                return timedout;
        }

Do you see an issue with this fix? It doesn't seem to be a good API contract to 
have isTimedOut throw IllegalArgumentException.

Original issue reported on code.google.com by xuha...@gmail.com on 19 May 2011 at 9:00

GoogleCodeExporter commented 9 years ago

Original comment by ingen...@gmail.com on 22 Nov 2011 at 4:34