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

Apache9 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/master by this push:
     new 9af77151403 HBASE-30119 Stop JmxCacheBuster in HBTU (#8145)
9af77151403 is described below

commit 9af771514036da3db37da23381d7aa403f0e0f5f
Author: Duo Zhang <[email protected]>
AuthorDate: Tue Apr 28 09:27:52 2026 +0800

    HBASE-30119 Stop JmxCacheBuster in HBTU (#8145)
    
    Signed-off-by: Xiao Liu <[email protected]>
---
 .../org/apache/hadoop/hbase/HBaseTestingUtil.java     | 19 +++++++++++++++++++
 .../procedure/TestCreateTableNoRegionServer.java      |  8 --------
 2 files changed, 19 insertions(+), 8 deletions(-)

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 365855bbd3c..22e19a31fd7 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
@@ -153,6 +153,7 @@ import 
org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi;
 import org.apache.hadoop.hdfs.server.namenode.EditLogFileOutputStream;
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.hadoop.mapred.MiniMRCluster;
+import org.apache.hadoop.metrics2.impl.JmxCacheBuster;
 import org.apache.hadoop.minikdc.MiniKdc;
 import org.apache.yetus.audience.InterfaceAudience;
 import org.apache.yetus.audience.InterfaceStability;
@@ -214,6 +215,24 @@ public class HBaseTestingUtil extends HBaseZKTestingUtil {
   /** This is for unit tests parameterized with a single boolean. */
   public static final List<Object[]> MEMSTORETS_TAGS_PARAMETRIZED = 
memStoreTSAndTagsCombination();
 
+  static {
+    // JmxCacheBuster may cause dead lock in test environment. As on master 
side, the table/region
+    // related metrics updating will finally lead to a meta access, so if meta 
is not online yet, we
+    // will block when updating while holding the metrics lock. But when we 
assign meta, there are
+    // bunch of places where we need to register a new metrics thus need to 
get the metrics lock,
+    // and then lead to a dead lock and cause the test to hang forever.
+    // The code is in hadoop so there is no easy way for us to fix, so here we 
just stop
+    // JmxCacheBuster to stabilize our tests first. See HBASE-30118 for more 
details and future
+    // plans.
+    try {
+      JmxCacheBuster.stop();
+    } catch (NullPointerException e) {
+      // Expected, the scheduled job has not been initialized so it will throw 
a NPE, but before
+      // throwing we have already set the stopped flag to false. Since there 
is no public method to
+      // only set stopped flag to false, we use this try-catch trick here to 
avoid using reflection.
+    }
+  }
+
   /**
    * Checks to see if a specific port is available.
    * @param port the port number to check for availability
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateTableNoRegionServer.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateTableNoRegionServer.java
index 5119133e7b0..e1f8d925b43 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateTableNoRegionServer.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateTableNoRegionServer.java
@@ -38,7 +38,6 @@ import org.apache.hadoop.hbase.procedure2.Procedure;
 import org.apache.hadoop.hbase.testclassification.MasterTests;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.metrics2.impl.JmxCacheBuster;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Tag;
@@ -112,13 +111,6 @@ public class TestCreateTableNoRegionServer {
   public static void setUp() throws Exception {
     UTIL.startMiniCluster(
       
StartTestingClusterOption.builder().masterClass(HMasterForTest.class).build());
-    // this may cause dead lock if there is no live region server and want to 
start a new server.
-    // In JmxCacheBuster we will reinitialize the metrics system so it will 
get some metrics which
-    // will need to access meta, since there is no region server, the request 
will hang there for a
-    // long time while holding the lock of MetricsSystemImpl, but when start a 
new region server, we
-    // also need to update metrics in handleReportForDutyResponse, since we 
are all in the same
-    // process and uses the same metrics instance, we hit dead lock.
-    JmxCacheBuster.stop();
   }
 
   @AfterAll

Reply via email to