Index: src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java =================================================================== --- src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (revision 954664) +++ src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (working copy) @@ -233,6 +233,9 @@ // doing a restart() to prevent closing of HDFS. private final AtomicBoolean shutdownHDFS = new AtomicBoolean(true); + // Since HADOOP-4829, we can just disable auto closing + private boolean hdfsSupportsAutoCloseDisabling = false; + private final String machineName; /** @@ -653,6 +656,13 @@ zooKeeperWrapper.close(); if (shutdownHDFS.get()) { + if(hdfsSupportsAutoCloseDisabling) { + try { + fs.close(); + } catch (IOException ioe) { + LOG.error("Error when closing fs on our way out", ioe); + } + } runThread(this.hdfsShutdownThread, this.conf.getLong("hbase.dfs.shutdown.wait", 30000)); } @@ -751,6 +761,7 @@ // accessors will be going against wrong filesystem (unless all is set // to defaults). this.conf.set("fs.default.name", this.conf.get("hbase.rootdir")); + this.conf.setBoolean("fs.automatic.close", false); this.fs = FileSystem.get(this.conf); // Register shutdown hook for HRegionServer, runs an orderly shutdown @@ -987,7 +998,13 @@ if (hdfsClientFinalizer == null) { throw new RuntimeException("client finalizer is null, can't suppress!"); } - Runtime.getRuntime().removeShutdownHook(hdfsClientFinalizer); + boolean registered = + Runtime.getRuntime().removeShutdownHook(hdfsClientFinalizer); + if (!registered) { + LOG.info("The HDFS shutdown hook isn't where we expect it, " + + "will call close during shutdown"); + hdfsSupportsAutoCloseDisabling = true; + } return hdfsClientFinalizer; } catch (NoSuchFieldException nsfe) {