You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2016/04/01 23:12:37 UTC

hbase git commit: HBASE-15212 RPCServer should enforce max request size

Repository: hbase
Updated Branches:
  refs/heads/0.98 04502d8d3 -> 0418b47ca


HBASE-15212 RPCServer should enforce max request size

Amending-Author: Andrew Purtell <apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/0418b47c
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/0418b47c
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/0418b47c

Branch: refs/heads/0.98
Commit: 0418b47ca4d7df6b55d476f43d13719b4280772a
Parents: 04502d8
Author: Enis Soztutar <en...@apache.org>
Authored: Tue Mar 22 16:23:15 2016 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Fri Apr 1 14:10:32 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/hadoop/hbase/ipc/RpcServer.java   | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/0418b47c/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java
----------------------------------------------------------------------
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 49eb883..6ab976d 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
@@ -259,15 +259,18 @@ public class RpcServer implements RpcServerInterface {
 
   protected HBaseRPCErrorHandler errorHandler = null;
 
+  static final String MAX_REQUEST_SIZE = "hbase.ipc.max.request.size";
   private static final String WARN_RESPONSE_TIME = "hbase.ipc.warn.response.time";
   private static final String WARN_RESPONSE_SIZE = "hbase.ipc.warn.response.size";
 
   /** Default value for above params */
+  private static final int DEFAULT_MAX_REQUEST_SIZE = DEFAULT_MAX_CALLQUEUE_SIZE / 4; // 256M
   private static final int DEFAULT_WARN_RESPONSE_TIME = 10000; // milliseconds
   private static final int DEFAULT_WARN_RESPONSE_SIZE = 100 * 1024 * 1024;
 
   private static final ObjectMapper MAPPER = new ObjectMapper();
 
+  private final int maxRequestSize;
   private final int warnResponseTime;
   private final int warnResponseSize;
   private final Object serverInstance;
@@ -1604,10 +1607,16 @@ public class RpcServer implements RpcServerInterface {
             }
           }
           if (dataLength < 0) {
-            throw new IllegalArgumentException("Unexpected data length "
+            throw new DoNotRetryIOException("Unexpected data length "
                 + dataLength + "!! from " + getHostAddress());
           }
-          // TODO: check dataLength against some limit so that the client cannot OOM the server
+
+          if (dataLength > maxRequestSize) {
+            throw new DoNotRetryIOException("RPC data length of " + dataLength + " received from "
+                + getHostAddress() + " is greater than max allowed " + maxRequestSize + ". Set \""
+                + MAX_REQUEST_SIZE + "\" on server to override this limit (not recommended)");
+          }
+
           data = ByteBuffer.allocate(dataLength);
           incRpcCount();  // Increment the rpc count
         }
@@ -2019,6 +2028,7 @@ public class RpcServer implements RpcServerInterface {
         2 * HConstants.DEFAULT_HBASE_RPC_TIMEOUT));
     this.warnResponseTime = conf.getInt(WARN_RESPONSE_TIME, DEFAULT_WARN_RESPONSE_TIME);
     this.warnResponseSize = conf.getInt(WARN_RESPONSE_SIZE, DEFAULT_WARN_RESPONSE_SIZE);
+    this.maxRequestSize = conf.getInt(MAX_REQUEST_SIZE, DEFAULT_MAX_REQUEST_SIZE);
 
     // Start the listener here and let it bind to the port
     listener = new Listener(name);