From 878743c9095a80ea0caf0969c5367cf0b00ae1d2 Mon Sep 17 00:00:00 2001 From: chaijunjie0101 <1340011734@qq.com> Date: Sat, 14 Mar 2026 20:42:22 +0800 Subject: [PATCH] HBASE-29991 [HBCK2] offlineReferenceFileRepair need execute 2 times to sideline all reference file --- .../org/apache/hbase/hbck1/HBaseFsck.java | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java index 601e913636..f5f41ce053 100644 --- a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java +++ b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java @@ -1208,11 +1208,11 @@ private void offlineReferenceFileRepair() throws IOException, InterruptedExcepti } /** - * Runs through the HBase rootdir and creates a reverse lookup map for table StoreFile names to - * the full Path.
+ * Runs through the HBase rootdir and creates a reverse lookup map for table + * regionName_columnFamilyName_storeFileName to the full Path.
* Example...
- * Key = 3944417774205889744
- * Value = hdfs://localhost:51169/user/userid/-ROOT-/70236052/info/3944417774205889744 + * Key = regionName_columnFamilyName_storeFileName
+ * Value = /hbase/data/namespaceName/tableName/regionName/columnFamilyName/storeFileName
* @param fs The file system to use. * @param hbaseRootDir The root directory to scan. * @param sfFilter optional path filter to apply to store files @@ -1242,14 +1242,14 @@ private Map getTableStoreFilePathMap(final FileSystem fs, final Pa } /** - * Runs through the HBase rootdir/tablename and creates a reverse lookup map for table StoreFile - * names to the full Path. Note that because this method can be called on a 'live' HBase system - * that we will skip files that no longer exist by the time we traverse them and similarly the - * user of the result needs to consider that some entries in this map may not exist by the time - * this call completes.
+ * Runs through the HBase rootdir/tablename and creates a reverse lookup map for table + * regionName_columnFamilyName_storeFileName to the full Path. Note that because this method can + * be called on a 'live' HBase system that we will skip files that no longer exist by the time we + * traverse them and similarly the user of the result needs to consider that some entries in this + * map may not exist by the time this call completes.
* Example...
- * Key = 3944417774205889744
- * Value = hdfs://localhost:51169/user/userid/-ROOT-/70236052/info/3944417774205889744 + * Key = regionName_columnFamilyName_storeFileName
+ * Value = /hbase/data/namespaceName/tableName/regionName/columnFamilyName/storeFileName
* @param resultMap map to add values. If null, method will create and populate one to return * @param fs The file system to use. * @param hbaseRootDir The root directory to scan. @@ -1290,6 +1290,7 @@ private static Map getTableStoreFilePathMap(Map resu for (FileStatus regionDir : regionDirs) { final Path dd = regionDir.getPath(); + String regionName = dd.getName(); if (!exceptions.isEmpty()) { break; @@ -1312,7 +1313,8 @@ public void run() { } for (FileStatus familyDir : familyDirs) { Path family = familyDir.getPath(); - if (family.getName().equals(HConstants.RECOVERED_EDITS_DIR)) { + String familyName = family.getName(); + if (familyName.equals(HConstants.RECOVERED_EDITS_DIR)) { continue; } // now in family, iterate over the StoreFiles and @@ -1321,7 +1323,13 @@ public void run() { for (FileStatus sfStatus : familyStatus) { Path sf = sfStatus.getPath(); if (sfFilter == null || sfFilter.accept(sf)) { - regionStoreFileMap.put(sf.getName(), sf); + // Only using the values in the map in offlineReferenceFileRepair and + // offlineHLinkFileRepair, so the outside logic is same. + // If the file in parent region lost, but the two daughters region both have + // reference to the file, need sideline both daughter region's reference file + // (the two file has same file name, see the logic + // in org.apache.hadoop.hbase.regionserver.HRegionFileSystem.splitStoreFile). + regionStoreFileMap.put(regionName + "_" + familyName + "_" + sf.getName(), sf); } } }