Skip to content

Commit fd7e071

Browse files
daschlMichael Nitschinger
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é <simon@couchbase.com> Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com> Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
1 parent 905c13c commit fd7e071

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
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:

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@
2525

2626
import java.net.InetSocketAddress;
2727
import java.util.Map;
28+
import java.util.Random;
2829
import java.util.concurrent.ExecutionException;
2930

3031
import net.spy.memcached.internal.GetFuture;
3132
import net.spy.memcached.internal.OperationFuture;
33+
import net.spy.memcached.ops.OperationErrorType;
34+
import net.spy.memcached.ops.OperationException;
3235
import net.spy.memcached.ops.StatusCode;
36+
import net.spy.memcached.transcoders.SerializingTranscoder;
3337

3438
/**
3539
* This test assumes a binary server is running on the host specified int the
@@ -221,4 +225,22 @@ public void testAsyncDecrementWithDefault() throws Exception {
221225
assertEquals(6, (long) f.get());
222226
}
223227

228+
@Override
229+
public void testStupidlyLargeSetAndSizeOverride() throws Exception {
230+
Random r = new Random();
231+
SerializingTranscoder st = new SerializingTranscoder(Integer.MAX_VALUE);
232+
233+
st.setCompressionThreshold(Integer.MAX_VALUE);
234+
235+
byte[] data = new byte[21 * 1024 * 1024];
236+
r.nextBytes(data);
237+
238+
OperationFuture<Boolean> setResult = client.set("bigassthing", 60, data, st);
239+
assertFalse(setResult.get());
240+
assertEquals(StatusCode.ERR_2BIG, setResult.getStatus().getStatusCode());
241+
242+
client.set("k", 5, "Blah");
243+
assertEquals("Blah", client.get("k"));
244+
}
245+
224246
}

0 commit comments

Comments
 (0)