Skip to content

Commit 3ba49ca

Browse files
daschlMichael Nitschinger
authored andcommitted
SPY-160: Queue retry op instead of redistributing it immediately.
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 <michael.nitschinger@couchbase.com> Reviewed-by: Matt Ingenthron <matt@couchbase.com>
1 parent 73cd03e commit 3ba49ca

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/main/java/net/spy/memcached/MemcachedConnection.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,4 +1418,14 @@ private void logRunException(final Exception e) {
14181418
public boolean isShutDown() {
14191419
return shutDown;
14201420
}
1421+
1422+
/**
1423+
* Add a operation to the retry queue.
1424+
*
1425+
* @param op the operation to retry.
1426+
*/
1427+
public void retryOperation(Operation op) {
1428+
retryOps.add(op);
1429+
}
1430+
14211431
}

src/main/java/net/spy/memcached/protocol/TCPMemcachedNodeImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ public final void addOp(Operation op) {
347347
getLogger().debug("Redistributing Operation " + op + " because auth "
348348
+ "latch taken longer than " + authWaitTime + " milliseconds to "
349349
+ "complete on node " + getSocketAddress());
350-
connection.redistributeOperation(op);
350+
connection.retryOperation(op);
351351
} else {
352352
op.cancel();
353353
getLogger().warn("Operation canceled because authentication "

0 commit comments

Comments
 (0)