This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-3
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-3 by this push:
     new f80bd5699e7 HBASE-29802 NPE when shutting down mini cluster cause 
tests hang (#7604)
f80bd5699e7 is described below

commit f80bd5699e7db4db4ce1caabd725ed19d952aa3d
Author: Duo Zhang <[email protected]>
AuthorDate: Sat Jan 10 16:15:49 2026 +0800

    HBASE-29802 NPE when shutting down mini cluster cause tests hang (#7604)
    
    Remove the 'shutdownHook' in SingleProcessHBaseCluster where we close
    the FileSystem instance of a region server.
    Set DistributedFileSystem cache to false when creating MiniMRCluster so
    when shutting down MiniMRCluster it will not close the shared FileSystem
    instance.
    Also re-enable TestExportSnapshot.
    
    Signed-off-by: Nick Dimiduk <[email protected]>
    (cherry picked from commit d11ee6a4586bd2afd7201f525a68f76de98e279d)
---
 .../hadoop/hbase/snapshot/TestExportSnapshot.java  |  2 -
 .../org/apache/hadoop/hbase/HBaseTestingUtil.java  |  6 ++-
 .../hadoop/hbase/SingleProcessHBaseCluster.java    | 42 +------------------
 .../org/apache/hadoop/hbase/MiniHBaseCluster.java  | 48 +---------------------
 4 files changed, 7 insertions(+), 91 deletions(-)

diff --git 
a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java
 
b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java
index 806d87c69d0..33deeeba2a2 100644
--- 
a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java
+++ 
b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java
@@ -63,7 +63,6 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -79,7 +78,6 @@ import 
org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.Snapshot
 /**
  * Test Export Snapshot Tool
  */
-@Ignore // HBASE-24493
 @Category({ VerySlowMapReduceTests.class, LargeTests.class })
 public class TestExportSnapshot {
 
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtil.java 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtil.java
index 759d3ea4955..dd7dff90c5b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtil.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtil.java
@@ -2343,10 +2343,14 @@ public class HBaseTestingUtil extends 
HBaseZKTestingUtil {
         jvmOpts + " --add-opens java.base/java.lang=ALL-UNNAMED");
     }
 
+    // Disable fs cache for DistributedFileSystem, to avoid YARN RM close the 
shared FileSystem
+    // instance and cause trouble in HBase. See HBASE-29802 for more details.
+    JobConf mrClusterConf = new JobConf(conf);
+    mrClusterConf.setBoolean("fs.hdfs.impl.disable.cache", true);
     // Allow the user to override FS URI for this map-reduce cluster to use.
     mrCluster =
       new MiniMRCluster(servers, FS_URI != null ? FS_URI : 
FileSystem.get(conf).getUri().toString(),
-        1, null, null, new JobConf(this.conf));
+        1, null, null, mrClusterConf);
     JobConf jobConf = MapreduceTestingShim.getJobConf(mrCluster);
     if (jobConf == null) {
       jobConf = mrCluster.createJobConf();
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/SingleProcessHBaseCluster.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/SingleProcessHBaseCluster.java
index df4f30befa3..7fa49344fef 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/SingleProcessHBaseCluster.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/SingleProcessHBaseCluster.java
@@ -24,7 +24,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.hbase.client.RegionInfoBuilder;
 import org.apache.hadoop.hbase.client.RegionReplicaUtil;
 import org.apache.hadoop.hbase.master.HMaster;
@@ -44,8 +43,6 @@ import org.apache.yetus.audience.InterfaceStability;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import 
org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStartupResponse;
-
 /**
  * This class creates a single process HBase cluster. each server. The master 
uses the 'default'
  * FileSystem. The RegionServers, if we are running on DistributedFilesystem, 
create a FileSystem
@@ -123,7 +120,7 @@ public class SingleProcessHBaseCluster extends 
HBaseClusterInterface {
    * only, not All filesystems as the FileSystem system exit hook does.
    */
   public static class MiniHBaseClusterRegionServer extends HRegionServer {
-    private Thread shutdownThread = null;
+
     private User user = null;
     /**
      * List of RegionServers killed so far. ServerName also comprises 
startCode of a server, so any
@@ -138,14 +135,6 @@ public class SingleProcessHBaseCluster extends 
HBaseClusterInterface {
       this.user = User.getCurrent();
     }
 
-    @Override
-    protected void handleReportForDutyResponse(final 
RegionServerStartupResponse c)
-      throws IOException {
-      super.handleReportForDutyResponse(c);
-      // Run this thread to shutdown our filesystem on way out.
-      this.shutdownThread = new 
SingleFileSystemShutdownThread(getFileSystem());
-    }
-
     @Override
     public void run() {
       try {
@@ -158,12 +147,6 @@ public class SingleProcessHBaseCluster extends 
HBaseClusterInterface {
         });
       } catch (Throwable t) {
         LOG.error("Exception in run", t);
-      } finally {
-        // Run this on the way out.
-        if (this.shutdownThread != null) {
-          this.shutdownThread.start();
-          Threads.shutdown(this.shutdownThread, 30000);
-        }
       }
     }
 
@@ -193,29 +176,6 @@ public class SingleProcessHBaseCluster extends 
HBaseClusterInterface {
     }
   }
 
-  /**
-   * Alternate shutdown hook. Just shuts down the passed fs, not all as 
default filesystem hook
-   * does.
-   */
-  static class SingleFileSystemShutdownThread extends Thread {
-    private final FileSystem fs;
-
-    SingleFileSystemShutdownThread(final FileSystem fs) {
-      super("Shutdown of " + fs);
-      this.fs = fs;
-    }
-
-    @Override
-    public void run() {
-      try {
-        LOG.info("Hook closing fs=" + this.fs);
-        this.fs.close();
-      } catch (IOException e) {
-        LOG.warn("Running hook", e);
-      }
-    }
-  }
-
   private void init(final int nMasterNodes, final int numAlwaysStandByMasters,
     final int nRegionNodes, List<Integer> rsPorts, Class<? extends HMaster> 
masterClass,
     Class<? extends SingleProcessHBaseCluster.MiniHBaseClusterRegionServer> 
regionserverClass)
diff --git 
a/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
 
b/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
index 42036fbc79b..72192371ffe 100644
--- 
a/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
+++ 
b/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
@@ -24,7 +24,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.hbase.client.RegionInfoBuilder;
 import org.apache.hadoop.hbase.client.RegionReplicaUtil;
 import org.apache.hadoop.hbase.master.HMaster;
@@ -43,8 +42,6 @@ import org.apache.yetus.audience.InterfaceAudience;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import 
org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStartupResponse;
-
 /**
  * This class creates a single process HBase cluster. each server. The master 
uses the 'default'
  * FileSystem. The RegionServers, if we are running on DistributedFilesystem, 
create a FileSystem
@@ -123,7 +120,7 @@ public class MiniHBaseCluster extends HBaseCluster {
    * only, not All filesystems as the FileSystem system exit hook does.
    */
   public static class MiniHBaseClusterRegionServer extends HRegionServer {
-    private Thread shutdownThread = null;
+
     private User user = null;
     /**
      * List of RegionServers killed so far. ServerName also comprises 
startCode of a server, so any
@@ -138,20 +135,6 @@ public class MiniHBaseCluster extends HBaseCluster {
       this.user = User.getCurrent();
     }
 
-    /*
-     * @param currentfs We return this if we did not make a new one.
-     * @param uniqueName Same name used to help identify the created fs.
-     * @return A new fs instance if we are up on DistributeFileSystem.
-     */
-
-    @Override
-    protected void handleReportForDutyResponse(final 
RegionServerStartupResponse c)
-      throws IOException {
-      super.handleReportForDutyResponse(c);
-      // Run this thread to shutdown our filesystem on way out.
-      this.shutdownThread = new 
SingleFileSystemShutdownThread(getFileSystem());
-    }
-
     @Override
     public void run() {
       try {
@@ -164,12 +147,6 @@ public class MiniHBaseCluster extends HBaseCluster {
         });
       } catch (Throwable t) {
         LOG.error("Exception in run", t);
-      } finally {
-        // Run this on the way out.
-        if (this.shutdownThread != null) {
-          this.shutdownThread.start();
-          Threads.shutdown(this.shutdownThread, 30000);
-        }
       }
     }
 
@@ -199,29 +176,6 @@ public class MiniHBaseCluster extends HBaseCluster {
     }
   }
 
-  /**
-   * Alternate shutdown hook. Just shuts down the passed fs, not all as 
default filesystem hook
-   * does.
-   */
-  static class SingleFileSystemShutdownThread extends Thread {
-    private final FileSystem fs;
-
-    SingleFileSystemShutdownThread(final FileSystem fs) {
-      super("Shutdown of " + fs);
-      this.fs = fs;
-    }
-
-    @Override
-    public void run() {
-      try {
-        LOG.info("Hook closing fs=" + this.fs);
-        this.fs.close();
-      } catch (IOException e) {
-        LOG.warn("Running hook", e);
-      }
-    }
-  }
-
   private void init(final int nMasterNodes, final int numAlwaysStandByMasters,
     final int nRegionNodes, List<Integer> rsPorts, Class<? extends HMaster> 
masterClass,
     Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> 
regionserverClass)

Reply via email to