This is an automated email from the ASF dual-hosted git repository. elserj pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hbase-operator-tools.git
The following commit(s) were added to refs/heads/master by this push: new b7d9fc8 HBASE-26687 Avoid the newBuilder(RegionInfo) constructor in RegionInf… (#103) b7d9fc8 is described below commit b7d9fc8a5f96517f2c6ebe733afa52155d7e3cba Author: Josh Elser <els...@apache.org> AuthorDate: Wed Jan 19 19:55:07 2022 -0500 HBASE-26687 Avoid the newBuilder(RegionInfo) constructor in RegionInf… (#103) A previously-fixed bug in HBase might break this tool in that the new RegionInfo built by the Tool is still incorrect because the region name and region encoded name are not recomputed. Thankfully, the sanity check on the tool prevented any damage from being done to hbase:meta. Signed-off-by: Peter Somogyi <psomo...@apache.org> --- .../src/main/java/org/apache/hbase/RegionInfoMismatchTool.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 bc37423..494191e 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 @@ public class RegionInfoMismatchTool { } // 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);