From 80dbf06651e527ec0421ce51e4712ffb2f1d078b Mon Sep 17 00:00:00 2001 From: Lars Hofhansl Date: Wed, 8 Apr 2015 21:43:01 -0700 Subject: [PATCH] HBASE-13362 Set max result size from client only (like scanner caching). --- .../org/apache/hadoop/hbase/HConstants.java | 25 ++++++++++++++++--- .../src/main/resources/hbase-default.xml | 10 ++++++++ .../hbase/regionserver/RSRpcServices.java | 4 +-- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java index 19e251ae805..fc65c474e6f 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java @@ -612,13 +612,20 @@ public final class HConstants { */ public static final UUID DEFAULT_CLUSTER_ID = new UUID(0L,0L); - /** - * Parameter name for maximum number of bytes returned when calling a - * scanner's next method. - */ + /** + * Parameter name for maximum number of bytes returned when calling a scanner's next method. + * Controlled by the client. + */ public static final String HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY = "hbase.client.scanner.max.result.size"; + /** + * Parameter name for maximum number of bytes returned when calling a scanner's next method. + * Controlled by the server. + */ + public static final String HBASE_SERVER_SCANNER_MAX_RESULT_SIZE_KEY = + "hbase.server.scanner.max.result.size"; + /** * Maximum number of bytes returned when calling a scanner's next method. * Note that when a single row is larger than this limit the row is still @@ -628,6 +635,16 @@ public final class HConstants { */ public static final long DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE = 2 * 1024 * 1024; + /** + * Maximum number of bytes returned when calling a scanner's next method. + * Note that when a single row is larger than this limit the row is still + * returned completely. + * Safety setting to protect the region server. + * + * The default value is 100MB. (a client would rarely request larger chunks on purpose) + */ + public static final long DEFAULT_HBASE_SERVER_SCANNER_MAX_RESULT_SIZE = 100 * 1024 * 1024; + /** * Parameter name for client pause value, used mostly as value to wait * before running a retry of a failed get, region lookup, etc. diff --git a/hbase-common/src/main/resources/hbase-default.xml b/hbase-common/src/main/resources/hbase-default.xml index 93776d7d841..c51ba16bc81 100644 --- a/hbase-common/src/main/resources/hbase-default.xml +++ b/hbase-common/src/main/resources/hbase-default.xml @@ -1306,6 +1306,16 @@ possible configurations would overwhelm and obscure the important. + + hbase.server.scanner.max.result.size + 104857600 + Maximum number of bytes returned when calling a scanner's next method. + Note that when a single row is larger than this limit the row is still returned completely. + The default value is 100MB. + This is a safety setting to protect the server from OOM situations. + + + hbase.status.published false diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java index 10e39a18b13..f9b8d610040 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java @@ -820,8 +820,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler, HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD, HConstants.DEFAULT_HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD); maxScannerResultSize = rs.conf.getLong( - HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, - HConstants.DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE); + HConstants.HBASE_SERVER_SCANNER_MAX_RESULT_SIZE_KEY, + HConstants.DEFAULT_HBASE_SERVER_SCANNER_MAX_RESULT_SIZE); // Set our address, however we need the final port that was given to rpcServer isa = new InetSocketAddress(initialIsa.getHostName(), rpcServer.getListenerAddress().getPort());