You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by wc...@apache.org on 2026/07/28 12:25:48 UTC

(hbase) branch master updated: HBASE-30299 SimpleRegionNormalizer should not attempt to merge primary and secondary replicas (#8498)

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

wchevreuil 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 bf473e55cf3 HBASE-30299 SimpleRegionNormalizer should not attempt to merge primary and secondary replicas (#8498)
bf473e55cf3 is described below

commit bf473e55cf31e0d2e164e11d5a732a5ca0cfd5d3
Author: Saad Ahmad Sabri <10...@users.noreply.github.com>
AuthorDate: Tue Jul 28 07:25:42 2026 -0500

    HBASE-30299 SimpleRegionNormalizer should not attempt to merge primary and secondary replicas (#8498)
    
    Signed-off-by: Charles Connell <cc...@apache.org>
    Signed-off-by: Wellington Chevreuil <wc...@apache.org>
---
 .../master/normalizer/SimpleRegionNormalizer.java  |  2 ++
 .../normalizer/TestSimpleRegionNormalizer.java     | 23 ++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java
index 934b8de1b94..c9bd4939223 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java
@@ -649,6 +649,8 @@ class SimpleRegionNormalizer implements RegionNormalizer, ConfigurationObserver
       regionStates =
         SimpleRegionNormalizer.this.masterServices.getAssignmentManager().getRegionStates();
       tableRegions = regionStates.getRegionsOfTable(tableName);
+
+      tableRegions.removeIf(r -> r.getReplicaId() != RegionInfo.DEFAULT_REPLICA_ID);
       // The list of regionInfo from getRegionsOfTable() is ordered by regionName.
       // regionName does not necessary guarantee the order by STARTKEY (let's say 'aa1', 'aa1!',
       // in order by regionName, it will be 'aa1!' followed by 'aa1').
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/normalizer/TestSimpleRegionNormalizer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/normalizer/TestSimpleRegionNormalizer.java
index f474d795aa8..71c286a416a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/normalizer/TestSimpleRegionNormalizer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/normalizer/TestSimpleRegionNormalizer.java
@@ -750,4 +750,27 @@ public class TestSimpleRegionNormalizer {
     }
     return ret;
   }
+
+  @Test
+  public void testIgnoresSecondaryReplicasForMergeAndSplitPlanning() {
+    conf.setBoolean(SPLIT_ENABLED_KEY, true);
+    conf.setBoolean(MERGE_ENABLED_KEY, true);
+    conf.setInt(MERGE_MIN_REGION_COUNT_KEY, 1);
+    conf.setInt(MERGE_MIN_REGION_SIZE_MB_KEY, 0);
+
+    final List<RegionInfo> primaryRegions = createRegionInfos(tableName, 5);
+    final List<RegionInfo> allRegions = new ArrayList<>(primaryRegions);
+    for (RegionInfo primary : primaryRegions) {
+      allRegions.add(RegionInfoBuilder.newBuilder(tableName).setStartKey(primary.getStartKey())
+        .setEndKey(primary.getEndKey()).setRegionId(primary.getRegionId()).setReplicaId(1).build());
+    }
+
+    final Map<byte[], Integer> regionSizes = createRegionSizesMap(primaryRegions, 15, 5, 5, 15, 16);
+    setupMocksForNormalizer(regionSizes, allRegions);
+
+    final List<NormalizationPlan> plans = normalizer.computePlansForTable(tableDescriptor);
+    assertThat(plans, hasSize(1));
+    assertThat(plans, contains(new MergeNormalizationPlan.Builder()
+      .addTarget(primaryRegions.get(1), 5).addTarget(primaryRegions.get(2), 5).build()));
+  }
 }