Skip to content

Commit

Permalink
SPY-160: Queue retry op instead of redistributing it immediately.
Browse files Browse the repository at this point in the history
Motivation
----------
After making the original SPY-160 changes, the ops were correctly redistributed,
but if the latch never gets counted down it gets recursively distributed and
added. Example:

	  at net.spy.memcached.protocol.TCPMemcachedNodeImpl.addOp(TCPMemcachedNodeImpl.java:344)
	  at net.spy.memcached.MemcachedConnection.addOperation(MemcachedConnection.java:1206)
	  at net.spy.memcached.MemcachedConnection.redistributeOperation(MemcachedConnection.java:994)
	  at net.spy.memcached.protocol.TCPMemcachedNodeImpl.addOp(TCPMemcachedNodeImpl.java:350)
	  at net.spy.memcached.MemcachedConnection.addOperation(MemcachedConnection.java:1206)
	  at net.spy.memcached.MemcachedConnection.redistributeOperation(MemcachedConnection.java:994)
	  at net.spy.memcached.protocol.TCPMemcachedNodeImpl.addOp(TCPMemcachedNodeImpl.java:350)
	  at net.spy.memcached.MemcachedConnection.addOperation(MemcachedConnection.java:1206)
	  at net.spy.memcached.MemcachedConnection.redistributeOperation(MemcachedConnection.java:994)

Modifications
-------------
The changeset, instead of redistributing right now, adds the operation to the retry queue which means
it will be handled eventually, but gives the IO thread a chance to run other tasks (including retreiving
auth response information).

Result
------
The operation is queued and is not blocking the IO thread.

Change-Id: I73a8e77255a54bceeb929febcadb0e555febdd67
Reviewed-on: http://review.couchbase.org/34938
Tested-by: Michael Nitschinger <[email protected]>
Reviewed-by: Matt Ingenthron <[email protected]>
  • Loading branch information
daschl authored and Michael Nitschinger committed Mar 27, 2014
1 parent 73cd03e commit 3ba49ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/main/java/net/spy/memcached/MemcachedConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -1418,4 +1418,14 @@ private void logRunException(final Exception e) {
public boolean isShutDown() {
return shutDown;
}

/**
* Add a operation to the retry queue.
*
* @param op the operation to retry.
*/
public void retryOperation(Operation op) {
retryOps.add(op);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public final void addOp(Operation op) {
getLogger().debug("Redistributing Operation " + op + " because auth "
+ "latch taken longer than " + authWaitTime + " milliseconds to "
+ "complete on node " + getSocketAddress());
connection.redistributeOperation(op);
connection.retryOperation(op);
} else {
op.cancel();
getLogger().warn("Operation canceled because authentication "
Expand Down

0 comments on commit 3ba49ca

Please sign in to comment.