From 4d5dbe4010341bd0f025b34ab1b6a205323998c9 Mon Sep 17 00:00:00 2001 From: Ray Mattingly Date: Sat, 22 Apr 2023 00:16:57 -0400 Subject: [PATCH] HBASE-27535: Separate slowlog thresholds for scans vs other requests (#5188) Signed-off-by: Bryan Beaudreault Signed-off-by: Viraj Jasani --- .../apache/hadoop/hbase/ipc/RpcServer.java | 42 +++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) 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 8ae0e3e321f7..54c18edc12cc 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 @@ -176,6 +176,8 @@ public abstract class RpcServer implements RpcServerInterface, ConfigurationObse protected static final String WARN_RESPONSE_TIME = "hbase.ipc.warn.response.time"; protected static final String WARN_RESPONSE_SIZE = "hbase.ipc.warn.response.size"; + protected static final String WARN_SCAN_RESPONSE_TIME = "hbase.ipc.warn.response.time.scan"; + protected static final String WARN_SCAN_RESPONSE_SIZE = "hbase.ipc.warn.response.size.scan"; /** * Minimum allowable timeout (in milliseconds) in rpc request's header. This configuration exists @@ -198,6 +200,8 @@ public abstract class RpcServer implements RpcServerInterface, ConfigurationObse protected final int maxRequestSize; protected volatile int warnResponseTime; protected volatile int warnResponseSize; + protected volatile int warnScanResponseTime; + protected volatile int warnScanResponseSize; protected final int minClientRequestTimeout; @@ -277,6 +281,8 @@ public RpcServer(final Server server, final String name, this.warnResponseTime = getWarnResponseTime(conf); this.warnResponseSize = getWarnResponseSize(conf); + this.warnScanResponseTime = getWarnScanResponseTime(conf); + this.warnScanResponseSize = getWarnScanResponseSize(conf); this.minClientRequestTimeout = conf.getInt(MIN_CLIENT_REQUEST_TIMEOUT, DEFAULT_MIN_CLIENT_REQUEST_TIMEOUT); this.maxRequestSize = conf.getInt(MAX_REQUEST_SIZE, DEFAULT_MAX_REQUEST_SIZE); @@ -326,6 +332,14 @@ private void refreshSlowLogConfiguration(Configuration newConf) { if (warnResponseSize != newWarnResponseSize) { warnResponseSize = newWarnResponseSize; } + int newWarnResponseTimeScan = getWarnScanResponseTime(newConf); + if (warnScanResponseTime != newWarnResponseTimeScan) { + warnScanResponseTime = newWarnResponseTimeScan; + } + int newWarnScanResponseSize = getWarnScanResponseSize(newConf); + if (warnScanResponseSize != newWarnScanResponseSize) { + warnScanResponseSize = newWarnScanResponseSize; + } } private static boolean getIsOnlineLogProviderEnabled(Configuration conf) { @@ -341,6 +355,14 @@ private static int getWarnResponseSize(Configuration conf) { return conf.getInt(WARN_RESPONSE_SIZE, DEFAULT_WARN_RESPONSE_SIZE); } + private static int getWarnScanResponseTime(Configuration conf) { + return conf.getInt(WARN_SCAN_RESPONSE_TIME, getWarnResponseTime(conf)); + } + + private static int getWarnScanResponseSize(Configuration conf) { + return conf.getInt(WARN_SCAN_RESPONSE_SIZE, getWarnResponseSize(conf)); + } + protected void initReconfigurable(Configuration confToLoad) { this.allowFallbackToSimpleAuth = confToLoad.getBoolean(FALLBACK_TO_INSECURE_CLIENT_AUTH, false); if (isSecurityEnabled && allowFallbackToSimpleAuth) { @@ -441,9 +463,8 @@ public Pair call(RpcCall call, MonitoredRPCHandler status) metrics.sentResponse(responseSize); // log any RPC responses that are slower than the configured warn // response time or larger than configured warning size - boolean tooSlow = (processingTime > warnResponseTime && warnResponseTime > -1); - boolean tooLarge = (warnResponseSize > -1 - && (responseSize > warnResponseSize || responseBlockSize > warnResponseSize)); + boolean tooSlow = isTooSlow(call, processingTime); + boolean tooLarge = isTooLarge(call, responseSize, responseBlockSize); if (tooSlow || tooLarge) { final String userName = call.getRequestUserName().orElse(StringUtils.EMPTY); // when tagging, we let TooLarge trump TooSmall to keep output simple @@ -560,6 +581,21 @@ void logResponse(Message param, String methodName, String call, boolean tooLarge LOG.warn("(response" + tag + "): " + GSON.toJson(responseInfo)); } + private boolean isTooSlow(RpcCall call, int processingTime) { + long warnResponseTime = call.getParam() instanceof ClientProtos.ScanRequest + ? warnScanResponseTime + : this.warnResponseTime; + return (processingTime > warnResponseTime && warnResponseTime > -1); + } + + private boolean isTooLarge(RpcCall call, long responseSize, long responseBlockSize) { + long warnResponseSize = call.getParam() instanceof ClientProtos.ScanRequest + ? warnScanResponseSize + : this.warnResponseSize; + return (warnResponseSize > -1 + && (responseSize > warnResponseSize || responseBlockSize > warnResponseSize)); + } + /** * Truncate to number of chars decided by conf hbase.ipc.trace.log.max.length if TRACE is on else * to 150 chars Refer to Jira HBASE-20826 and HBASE-20942