@@ -61,14 +61,16 @@ public class HbckChore extends ScheduledChore {
6161 */
6262 private final Map <String , HbckRegionInfo > regionInfoMap = new HashMap <>();
6363
64+ private final Set <String > disabledTableRegions = new HashSet <>();
65+
6466 /**
6567 * The regions only opened on RegionServers, but no region info in meta.
6668 */
6769 private final Map <String , ServerName > orphanRegionsOnRS = new HashMap <>();
6870 /**
6971 * The regions have directory on FileSystem, but no region info in meta.
7072 */
71- private final Set <String > orphanRegionsOnFS = new HashSet <>();
73+ private final Map <String , Path > orphanRegionsOnFS = new HashMap <>();
7274 /**
7375 * The inconsistent regions. There are three case:
7476 * case 1. Master thought this region opened, but no regionserver reported it.
@@ -82,7 +84,7 @@ public class HbckChore extends ScheduledChore {
8284 * The "snapshot" is used to save the last round's HBCK checking report.
8385 */
8486 private final Map <String , ServerName > orphanRegionsOnRSSnapshot = new HashMap <>();
85- private final Set <String > orphanRegionsOnFSSnapshot = new HashSet <>();
87+ private final Map <String , Path > orphanRegionsOnFSSnapshot = new HashMap <>();
8688 private final Map <String , Pair <ServerName , List <ServerName >>> inconsistentRegionsSnapshot =
8789 new HashMap <>();
8890
@@ -109,6 +111,7 @@ public HbckChore(MasterServices master) {
109111 protected synchronized void chore () {
110112 running = true ;
111113 regionInfoMap .clear ();
114+ disabledTableRegions .clear ();
112115 orphanRegionsOnRS .clear ();
113116 orphanRegionsOnFS .clear ();
114117 inconsistentRegions .clear ();
@@ -132,7 +135,8 @@ private void saveCheckResultToSnapshot() {
132135 orphanRegionsOnRS .entrySet ()
133136 .forEach (e -> orphanRegionsOnRSSnapshot .put (e .getKey (), e .getValue ()));
134137 orphanRegionsOnFSSnapshot .clear ();
135- orphanRegionsOnFSSnapshot .addAll (orphanRegionsOnFS );
138+ orphanRegionsOnFS .entrySet ()
139+ .forEach (e -> orphanRegionsOnFSSnapshot .put (e .getKey (), e .getValue ()));
136140 inconsistentRegionsSnapshot .clear ();
137141 inconsistentRegions .entrySet ()
138142 .forEach (e -> inconsistentRegionsSnapshot .put (e .getKey (), e .getValue ()));
@@ -147,11 +151,9 @@ private void loadRegionsFromInMemoryState() {
147151 master .getAssignmentManager ().getRegionStates ().getRegionStates ();
148152 for (RegionState regionState : regionStates ) {
149153 RegionInfo regionInfo = regionState .getRegion ();
150- // Because the inconsistent regions are not absolutely right, only skip the offline regions
151- // which belong to disabled table.
152154 if (master .getTableStateManager ()
153155 .isTableState (regionInfo .getTable (), TableState .State .DISABLED )) {
154- continue ;
156+ disabledTableRegions . add ( regionInfo . getEncodedName ()) ;
155157 }
156158 HbckRegionInfo .MetaEntry metaEntry =
157159 new HbckRegionInfo .MetaEntry (regionInfo , regionState .getServerName (),
@@ -185,6 +187,11 @@ private void loadRegionsFromRSReport() {
185187 HbckRegionInfo hri = entry .getValue ();
186188 ServerName locationInMeta = hri .getMetaEntry ().getRegionServer ();
187189 if (hri .getDeployedOn ().size () == 0 ) {
190+ // Because the inconsistent regions are not absolutely right, only skip the offline regions
191+ // which belong to disabled table.
192+ if (disabledTableRegions .contains (encodedRegionName )) {
193+ continue ;
194+ }
188195 // Master thought this region opened, but no regionserver reported it.
189196 inconsistentRegions .put (encodedRegionName , new Pair <>(locationInMeta , new LinkedList <>()));
190197 } else if (hri .getDeployedOn ().size () > 1 ) {
@@ -209,7 +216,7 @@ private void loadRegionsFromFS() throws IOException {
209216 String encodedRegionName = regionDir .getName ();
210217 HbckRegionInfo hri = regionInfoMap .get (encodedRegionName );
211218 if (hri == null ) {
212- orphanRegionsOnFS .add (encodedRegionName );
219+ orphanRegionsOnFS .put (encodedRegionName , regionDir );
213220 continue ;
214221 }
215222 HbckRegionInfo .HdfsEntry hdfsEntry = new HbckRegionInfo .HdfsEntry (regionDir );
@@ -244,7 +251,7 @@ public Map<String, ServerName> getOrphanRegionsOnRS() {
244251 /**
245252 * @return the regions have directory on FileSystem, but no region info in meta.
246253 */
247- public Set <String > getOrphanRegionsOnFS () {
254+ public Map <String , Path > getOrphanRegionsOnFS () {
248255 // Need synchronized here, as this "snapshot" may be changed after checking.
249256 rwLock .readLock ().lock ();
250257 try {
0 commit comments