From d59af05b0f8363b91b962be6dffacd43120446b2 Mon Sep 17 00:00:00 2001 From: xincunSong <365724453@qq.com> Date: Thu, 30 Apr 2020 07:03:24 +0800 Subject: [PATCH] HBASE-24282 'scanDetail' log message is missing when responseTooSlow happens on the first scan rpc call (#1604) Signed-off-by: Guangxu Cheng Signed-off-by: stack --- .../org/apache/hadoop/hbase/ipc/RpcServer.java | 11 +++++++---- .../hadoop/hbase/regionserver/RSRpcServices.java | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 4 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 e3be15da493..d49122a4516 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 @@ -502,12 +502,15 @@ public abstract class RpcServer implements RpcServerInterface, responseInfo.put("param", stringifiedParam); if (param instanceof ClientProtos.ScanRequest && rsRpcServices != null) { ClientProtos.ScanRequest request = ((ClientProtos.ScanRequest) param); + String scanDetails; if (request.hasScannerId()) { long scannerId = request.getScannerId(); - String scanDetails = rsRpcServices.getScanDetailsWithId(scannerId); - if (scanDetails != null) { - responseInfo.put("scandetails", scanDetails); - } + scanDetails = rsRpcServices.getScanDetailsWithId(scannerId); + } else { + scanDetails = rsRpcServices.getScanDetailsWithRequest(request); + } + if (scanDetails != null) { + responseInfo.put("scandetails", scanDetails); } } if (param instanceof ClientProtos.MultiRequest) { 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 a104f495e90..4119e4f8058 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 @@ -1376,6 +1376,21 @@ public class RSRpcServices implements HBaseRPCErrorHandler, return builder.toString(); } + public String getScanDetailsWithRequest(ScanRequest request) { + try { + if (!request.hasRegion()) { + return null; + } + Region region = getRegion(request.getRegion()); + StringBuilder builder = new StringBuilder(); + builder.append("table: ").append(region.getRegionInfo().getTable().getNameAsString()); + builder.append(" region: ").append(region.getRegionInfo().getRegionNameAsString()); + return builder.toString(); + } catch (IOException ignored) { + return null; + } + } + /** * Get the vtime associated with the scanner. * Currently the vtime is the number of "next" calls.