From f2c7a96f7743d339011a04289b894b0b02c7620a Mon Sep 17 00:00:00 2001 From: Ashu Pachauri Date: Wed, 19 Oct 2016 16:50:52 -0700 Subject: [PATCH] HBASE-16752-Addendum: Do not retry large request for client versions less than 1.3 --- .../apache/hadoop/hbase/exceptions/RequestTooBigException.java | 6 +++++- .../src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/RequestTooBigException.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/RequestTooBigException.java index 31baebb..0021f4a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/RequestTooBigException.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/RequestTooBigException.java @@ -26,13 +26,17 @@ import org.apache.hadoop.hbase.classification.InterfaceStability; * Thrown when the size of the rpc request received by the server is too large. * * On receiving such an exception, the client does not retry the offending rpc. + * @since 1.3.0 */ @InterfaceAudience.Public @InterfaceStability.Evolving public class RequestTooBigException extends DoNotRetryIOException { - private static final long serialVersionUID = -1593339239809586516L; + // Recognized only in HBase version 1.3 and higher. + public static final int MAJOR_VERSION = 1; + public static final int MINOR_VERSION = 3; + public RequestTooBigException() { super(); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java index f6ccd02..9004147 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java @@ -1652,7 +1652,14 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver { Call reqTooBig = new Call(header.getCallId(), this.service, null, null, null, null, this, responder, 0, null, this.addr,0); metrics.exception(REQUEST_TOO_BIG_EXCEPTION); - setupResponse(null, reqTooBig, REQUEST_TOO_BIG_EXCEPTION, msg); + // Make sure the client recognizes the underlying exception + // Otherwise, throw a DoNotRetryIOException. + if (VersionInfoUtil.hasMinimumVersion(connectionHeader.getVersionInfo(), + RequestTooBigException.MAJOR_VERSION, RequestTooBigException.MINOR_VERSION)) { + setupResponse(null, reqTooBig, REQUEST_TOO_BIG_EXCEPTION, msg); + } else { + setupResponse(null, reqTooBig, new DoNotRetryIOException(), msg); + } // We are going to close the connection, make sure we process the response // before that. In rare case when this fails, we still close the connection. responseWriteLock.lock(); -- 2.8.0-rc2