diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/RegionInfoMismatchTool.java b/hbase-hbck2/src/main/java/org/apache/hbase/RegionInfoMismatchTool.java index bc37423bb9..494191ecf1 100644 --- a/hbase-hbck2/src/main/java/org/apache/hbase/RegionInfoMismatchTool.java +++ b/hbase-hbck2/src/main/java/org/apache/hbase/RegionInfoMismatchTool.java @@ -148,9 +148,17 @@ void run(PrintStream out, boolean fix) throws IOException, DeserializationExcept } // Third component of a region name is just a literal numeric (not a binary-encoded long) long regionId = Long.parseLong(Bytes.toString(regionNameParts[2])); - RegionInfo correctedRegionInfo = RegionInfoBuilder.newBuilder(wrongRegionInfo) + // HBASE-24500: We cannot use newBuilder(RegionInfo) because it will copy the NAME and + // encodedName from the original RegionInfo instead of re-computing it. Copy all of the + // fields by hand which will force the new RegionInfo to recompute the NAME/encodedName + // fields. + RegionInfo correctedRegionInfo = RegionInfoBuilder.newBuilder(wrongRegionInfo.getTable()) .setRegionId(regionId) + .setStartKey(wrongRegionInfo.getStartKey()) + .setEndKey(wrongRegionInfo.getEndKey()) .setReplicaId(0) + .setOffline(wrongRegionInfo.isOffline()) + .setSplit(wrongRegionInfo.isSplit()) .build(); String rowkeyEncodedRegionName = HBCKRegionInfo.encodeRegionName(regionName);