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

Apache9 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 0db9a7fbf6c Revert "HBASE-30119 Stop JmxCacheBuster in HBTU (#8145)"
0db9a7fbf6c is described below

commit 0db9a7fbf6c9968d9f5615762c734acdfc55f302
Author: Duo Zhang <[email protected]>
AuthorDate: Tue Apr 28 09:54:06 2026 +0800

    Revert "HBASE-30119 Stop JmxCacheBuster in HBTU (#8145)"
    
    This reverts commit 4787994107c7c7bbdc45b388265d4742f520eb99.
---
 .../org/apache/hadoop/hbase/HBaseTestingUtil.java     | 19 -------------------
 .../procedure/TestCreateTableNoRegionServer.java      |  8 ++++++++
 2 files changed, 8 insertions(+), 19 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 1c01319d30a..4ada86e2be1 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,7 +153,6 @@ 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;
@@ -215,24 +214,6 @@ 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 e1f8d925b43..5119133e7b0 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,6 +38,7 @@ 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;
@@ -111,6 +112,13 @@ 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