Skip to content

Commit 1dd6a2f

Browse files
daschlsurybala
authored andcommitted
SPY-191: Don't force reconnect on E2BIG with binary protocol.
Motivation ---------- In the current codebase, a socket is forcefully reset when the server returns an E2BIG response, that is when the document is larger than the possible value size. Modifications ------------- While this needs to be done on the ASCII protocol, doing so is not needed with binary protocol and can be considered a bug/leftover. The code is modified so that E2BIG just translates into a non-success response like any other error and the proper error code identifies the cause. The test cases have been modified for binary to reflect the change. Result ------ Do not force reconnect / treat the issue as a server error on the binary protocol - the ASCII protocol is unaffected. Change-Id: Idf392d146d30b2e96dc198a93a3cc6598dae3fc6 Reviewed-on: http://review.couchbase.org/61927 Reviewed-by: Simon Baslé <[email protected]> Tested-by: Michael Nitschinger <[email protected]> Reviewed-by: Sergey Avseyev <[email protected]>
1 parent 642d99a commit 1dd6a2f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/it/java/net/spy/memcached/BinaryClientTest.java

+19
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,16 @@
4242

4343
import java.net.InetSocketAddress;
4444
import java.util.Map;
45+
import java.util.Random;
4546
import java.util.concurrent.ExecutionException;
4647

4748
import net.spy.memcached.categories.StandardTests;
4849
import net.spy.memcached.internal.GetFuture;
4950
import net.spy.memcached.internal.OperationFuture;
51+
import net.spy.memcached.ops.OperationErrorType;
52+
import net.spy.memcached.ops.OperationException;
5053
import net.spy.memcached.ops.StatusCode;
54+
import net.spy.memcached.transcoders.SerializingTranscoder;
5155

5256
import org.junit.Test;
5357
import org.junit.experimental.categories.Category;
@@ -263,4 +267,19 @@ public void testAsyncDecrementWithDefault() throws Exception {
263267
assertEquals(6, (long) f.get());
264268
}
265269

270+
@Override
271+
public void testStupidlyLargeSetAndSizeOverride() throws Exception {
272+
Random r = new Random();
273+
SerializingTranscoder st = new SerializingTranscoder(Integer.MAX_VALUE);
274+
275+
st.setCompressionThreshold(Integer.MAX_VALUE);
276+
277+
byte[] data = new byte[2 * 1024 * 1024];
278+
r.nextBytes(data);
279+
280+
OperationFuture<Boolean> setResult = client.set("bigassthing", 60, data, st);
281+
assertFalse(setResult.get());
282+
assertEquals(StatusCode.ERR_2BIG, setResult.getStatus().getStatusCode());
283+
}
284+
266285
}

src/main/java/net/spy/memcached/protocol/binary/OperationImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ protected OperationStatus getStatusForErrorCode(int errCode, byte[] errPl)
239239
case ERR_NOT_STORED:
240240
return new CASOperationStatus(false, new String(errPl),
241241
CASResponse.NOT_FOUND, statusCode);
242-
case ERR_2BIG:
243242
case ERR_INTERNAL:
244243
handleError(OperationErrorType.SERVER, new String(errPl));
244+
case ERR_2BIG:
245245
case ERR_INVAL:
246246
case ERR_DELTA_BADVAL:
247247
case ERR_NOT_MY_VBUCKET:

0 commit comments

Comments
 (0)