This is an automated email from the ASF dual-hosted git repository.
taklwu pushed a commit to branch HBASE-29081
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/HBASE-29081 by this push:
new e08c3678367 HBASE-29715: AssignmentManager is trying to pick up the
active cluster's tables before refreshing meta and hfiles (#7474)
e08c3678367 is described below
commit e08c3678367071aab8b9c47e27c7bba0ae3a8eaa
Author: Kevin Geiszler <[email protected]>
AuthorDate: Mon Dec 15 09:06:21 2025 -0800
HBASE-29715: AssignmentManager is trying to pick up the active cluster's
tables before refreshing meta and hfiles (#7474)
Signed-off-by: Tak Lon (Stephen) Wu <[email protected]>
Signed-off-by: Andor Molnár <[email protected]>
Reviewed by: Kota-SH <[email protected]>
---
.../org/apache/hadoop/hbase/master/HMaster.java | 15 ++---
.../hadoop/hbase/master/TestMasterMetrics.java | 69 ++++++++++++++++++++++
2 files changed, 73 insertions(+), 11 deletions(-)
diff --git
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
index f849a19a251..e32082208ca 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -3116,16 +3116,9 @@ public class HMaster extends
HBaseServerBase<MasterRpcServices> implements Maste
if (isActiveMaster() && isInitialized() && assignmentManager !=
null) {
try {
Map<TableName, RegionStatesCount> tableRegionStatesCountMap =
new HashMap<>();
- Map<String, TableDescriptor> tableDescriptorMap =
getTableDescriptors().getAll();
- for (TableDescriptor tableDescriptor :
tableDescriptorMap.values()) {
+ List<TableDescriptor> tableDescriptors =
listTableDescriptors(null, null, null, true);
+ for (TableDescriptor tableDescriptor : tableDescriptors) {
TableName tableName = tableDescriptor.getTableName();
- if (
- tableName.isSystemTable() &&
tableName.getQualifierAsString().startsWith("meta")
- && !tableName.equals(TableName.META_TABLE_NAME)
- ) {
- LOG.info("Skipping foreign meta table {} in cluster
metrics", tableName);
- continue;
- }
RegionStatesCount regionStatesCount =
assignmentManager.getRegionStatesCount(tableName);
tableRegionStatesCountMap.put(tableName, regionStatesCount);
@@ -3828,7 +3821,7 @@ public class HMaster extends
HBaseServerBase<MasterRpcServices> implements Maste
}
/**
- * Return a list of table table descriptors after applying any provided
filter parameters. Note
+ * Return a list of table descriptors after applying any provided filter
parameters. Note
* that the user-facing description of this filter logic is presented on the
class-level javadoc
* of {@link NormalizeTableFilterParams}.
*/
@@ -3839,7 +3832,7 @@ public class HMaster extends
HBaseServerBase<MasterRpcServices> implements Maste
// request for all TableDescriptors
Collection<TableDescriptor> allHtds;
if (namespace != null && namespace.length() > 0) {
- // Do a check on the namespace existence. Will fail if does not exist.
+ // Do a check on the namespace existence. Will fail if it does not
exist.
this.clusterSchemaService.getNamespace(namespace);
allHtds = tableDescriptors.getByNamespace(namespace).values();
} else {
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java
index 07dacf6f35c..0f2d1a17634 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java
@@ -22,14 +22,17 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.UncheckedIOException;
+import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ClusterMetrics;
import org.apache.hadoop.hbase.CompatibilityFactory;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
+import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.ServerMetricsBuilder;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.SingleProcessHBaseCluster;
@@ -225,4 +228,70 @@ public class TestMasterMetrics {
master.getTableDescriptors().remove(replicaMetaTable);
}
}
+
+ @Test
+ public void testClusterMetricsForeignTableSkipping() throws Exception {
+ List<TableName> allTables = new ArrayList<>();
+
+ // These tables, including the cluster's meta table, should not be foreign
to the cluster.
+ // The cluster should be able to find their state.
+ allTables.add(TableName.META_TABLE_NAME);
+ List<TableName> familiarTables = new ArrayList<>();
+ familiarTables.add(TableName.valueOf(null, "familiarTable1"));
+ familiarTables.add(TableName.valueOf("", "familiarTable2"));
+ familiarTables.add(TableName.valueOf("default", "familiarTable3"));
+ familiarTables.add(TableName.valueOf("familiarNamespace",
"familiarTable4"));
+ familiarTables.add(TableName.valueOf("familiarNamespace",
"familiarTable5"));
+
+ // Create these "familiar" tables so their state can be found
+
TEST_UTIL.getAdmin().createNamespace(NamespaceDescriptor.create("familiarNamespace").build());
+ for (TableName familiarTable : familiarTables) {
+ TEST_UTIL.createTable(familiarTable, "cf");
+ allTables.add(familiarTable);
+ }
+
+ // These tables should be foreign to the cluster.
+ // The cluster should not be able to find their state.
+ allTables.add(TableName.valueOf("hbase", "meta_replica"));
+ allTables.add(TableName.valueOf(null, "defaultNamespaceTable1"));
+ allTables.add(TableName.valueOf("", "defaultNamespaceTable2"));
+ allTables.add(TableName.valueOf("default", "defaultNamespaceTable3"));
+ allTables.add(TableName.valueOf("customNamespace",
"customNamespaceTable1"));
+ allTables.add(TableName.valueOf("customNamespace",
"customNamespaceTable2"));
+ allTables.add(TableName.valueOf("anotherNamespace",
"anotherNamespaceTable"));
+ allTables.add(TableName.valueOf("sharedNamespace",
"sharedNamespaceTable1"));
+ allTables.add(TableName.valueOf("sharedNamespace",
"sharedNamespaceTable2"));
+
+ // Update master's table descriptors to have all tables
+ TableDescriptor foreignTableDescriptor;
+ for (TableName tableName : allTables) {
+ foreignTableDescriptor = TableDescriptorBuilder.newBuilder(tableName)
+ .setColumnFamily(ColumnFamilyDescriptorBuilder.of("cf")).build();
+ master.getTableDescriptors().update(foreignTableDescriptor, true);
+ }
+
+ // The state of the meta table and the familiar tables we created should
exist.
+ // The other tables' state should not exist.
+ for (TableName tableName : allTables) {
+ try {
+ ClusterMetrics metrics = master.getClusterMetricsWithoutCoprocessor(
+ EnumSet.of(ClusterMetrics.Option.TABLE_TO_REGIONS_COUNT));
+ Map<TableName, RegionStatesCount> tableRegionStatesCount =
+ metrics.getTableRegionStatesCount();
+
+ if (
+ tableName.equals(TableName.META_TABLE_NAME)
+ || tableName.getQualifierAsString().startsWith("familiar")
+ ) {
+ assertTrue("Expected this table's state to exist: " + tableName,
+ tableRegionStatesCount.containsKey(tableName));
+ } else {
+ assertFalse("This foreign table's state should not exist: " +
tableName,
+ tableRegionStatesCount.containsKey(tableName));
+ }
+ } finally {
+ master.getTableDescriptors().remove(tableName);
+ }
+ }
+ }
}