SaadASTheDev opened a new pull request, #8498:
URL: https://github.com/apache/hbase/pull/8498

   ## Summary
   
   `SimpleRegionNormalizer` incorrectly includes secondary replica regions when
   computing normalization plans. Since `getRegionsOfTable` returns all replicas
   alongside their primaries, and `RegionInfo.COMPARATOR` sorts replicas
   immediately after their primary (same start/end key, higher replica ID), the
   merge planning loop treats primaries and replicas as contiguous candidates 
and
   groups them together into a single `MergeNormalizationPlan`.
   
   These plans are rejected at the `MergeTableRegionsProcedure` level with:
   
     MergeRegionException: Can't merge non-default replicas
   
   This causes repeated failed plan submissions, wasted work, and can prevent
   normalization from making progress when region replication is enabled.
   
   ## Root Cause
   
   `NormalizeContext` builds its region list from `getRegionsOfTable`, which
   returns all replicas. The normalizer has no concept of replica IDs and treats
   every entry as a candidate for merge or split.
   
   ## Fix
   
   Filter non-default replicas out of `tableRegions` in `NormalizeContext`
   immediately after fetching, before sorting and before computing the average
   region size. Only primary regions (replicaId == DEFAULT_REPLICA_ID == 0)
   are valid normalization targets. When a primary is merged or split,
   `MergeTableRegionsProcedure` and `SplitTableRegionProcedure` automatically
   handle all associated replicas by reading the table's region replication
   factor and expanding the operation to cover every replica ID.
   
   ## Tests
   
   Added `itIgnoresSecondaryReplicasForMergeAndSplitPlanning` to
   `TestSimpleRegionNormalizer`, which exercises the normalizer with a mixed
   list of primary and replica regions and asserts that only primary regions
   appear in the resulting normalization plans.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to