From 085c65107e920b8931256b8b1bb06f07be4c4686 Mon Sep 17 00:00:00 2001 From: Duo Zhang Date: Sun, 17 Apr 2022 22:56:52 +0800 Subject: [PATCH] HBASE-26941 LocalHBaseCluster.waitOnRegionServer should not call join while interrupted (#4352) Signed-off-by: Xin Sun (cherry picked from commit 35aa57e4452c6f0a7f5037371edca64163913345) --- .../apache/hadoop/hbase/LocalHBaseCluster.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java index ca7e82a6071..1c721eef5c4 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java @@ -310,15 +310,20 @@ public class LocalHBaseCluster { * @return Name of region server that just went down. */ public String waitOnRegionServer(JVMClusterUtil.RegionServerThread rst) { + boolean interrupted = false; while (rst.isAlive()) { try { LOG.info("Waiting on " + rst.getRegionServer().toString()); rst.join(); } catch (InterruptedException e) { - e.printStackTrace(); + LOG.error("Interrupted while waiting for {} to finish. Retrying join", rst.getName(), e); + interrupted = true; } } regionThreads.remove(rst); + if (interrupted) { + Thread.currentThread().interrupt(); + } return rst.getName(); } @@ -382,15 +387,21 @@ public class LocalHBaseCluster { * @return Name of master that just went down. */ public String waitOnMaster(JVMClusterUtil.MasterThread masterThread) { + boolean interrupted = false; while (masterThread.isAlive()) { try { LOG.info("Waiting on " + masterThread.getMaster().getServerName().toString()); masterThread.join(); } catch (InterruptedException e) { - e.printStackTrace(); + LOG.error("Interrupted while waiting for {} to finish. Retrying join", + masterThread.getName(), e); + interrupted = true; } } masterThreads.remove(masterThread); + if (interrupted) { + Thread.currentThread().interrupt(); + } return masterThread.getName(); }