From 508cb1bd987530790290dd6ec33bc6007bcc7f27 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Thu, 18 Jul 2013 17:01:44 +0000 Subject: [PATCH] HBASE-8979 JVMClusterUtil will join forever on a stuck regionserver <--- zombie maker git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1504527 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/hadoop/hbase/util/JVMClusterUtil.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java index 149b057f81b..27f76adbf3e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java @@ -251,16 +251,17 @@ public class JVMClusterUtil { } boolean wasInterrupted = false; - final long maxTime = System.currentTimeMillis() + 120 * 1000; + final long maxTime = System.currentTimeMillis() + 30 * 1000; if (regionservers != null) { // first try nicely. for (RegionServerThread t : regionservers) { t.getRegionServer().stop("Shutdown requested"); } for (RegionServerThread t : regionservers) { - if (t.isAlive() && !wasInterrupted && System.currentTimeMillis() < maxTime) { + long now = System.currentTimeMillis(); + if (t.isAlive() && !wasInterrupted && now < maxTime) { try { - t.join(maxTime); + t.join(maxTime - now); } catch (InterruptedException e) { LOG.info("Got InterruptedException on shutdown - " + "not waiting anymore on region server ends", e); @@ -270,17 +271,20 @@ public class JVMClusterUtil { } // Let's try to interrupt the remaining threads if any. - for (int i = 0; i < 10; ++i) { + for (int i = 0; i < 100; ++i) { + boolean atLeastOneLiveServer = false; for (RegionServerThread t : regionservers) { if (t.isAlive()) { + atLeastOneLiveServer = true; try { LOG.warn("RegionServerThreads remaining, give one more chance before interrupting"); - t.join(10); + t.join(1000); } catch (InterruptedException e) { wasInterrupted = true; } } } + if (!atLeastOneLiveServer) break; for (RegionServerThread t : regionservers) { if (t.isAlive()) { LOG.warn("RegionServerThreads taking too long to stop, interrupting");