saintstack commented on a change in pull request #917: HBASE-23383 [hbck2] 
`fixHoles` should queue assignment procedures for any regions its fixing
URL: https://github.com/apache/hbase/pull/917#discussion_r357869010
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetaFixer.java
 ##########
 @@ -83,77 +85,193 @@ void fix() throws IOException {
   }
 
   /**
-   * If hole, it papers it over by adding a region in the filesystem and to 
hbase:meta.
-   * Does not assign.
+   * For each hole identified in {@code report}, generates a corresponding 
region, adds it to the
+   * filesystem, adds it to hbase:meta, and requests assignment. All actions 
are best-effort.
    */
-  void fixHoles(CatalogJanitor.Report report) throws IOException {
-    List<Pair<RegionInfo, RegionInfo>> holes = report.getHoles();
+  TransitRegionStateProcedure[] fixHoles(CatalogJanitor.Report report) {
+    final List<Pair<RegionInfo, RegionInfo>> holes = report.getHoles();
     if (holes.isEmpty()) {
-      LOG.debug("No holes.");
-      return;
+      LOG.info("CatalogJanitor Report contains no holes to fix. Skipping.");
+      return new TransitRegionStateProcedure[0];
     }
-    for (Pair<RegionInfo, RegionInfo> p: holes) {
-      RegionInfo ri = getHoleCover(p);
-      if (ri == null) {
-        continue;
-      }
-      Configuration configuration = this.masterServices.getConfiguration();
-      HRegion.createRegionDir(configuration, ri, 
FSUtils.getRootDir(configuration));
-      // If an error here, then we'll have a region in the filesystem but not
-      // in hbase:meta (if the below fails). Should be able to rerun the fix.
-      // Add to hbase:meta and then update in-memory state so it knows of new
-      // Region; addRegionToMeta adds region and adds a state column set to 
CLOSED.
-      MetaTableAccessor.addRegionToMeta(this.masterServices.getConnection(), 
ri);
-      this.masterServices.getAssignmentManager().getRegionStates().
-          updateRegionState(ri, RegionState.State.CLOSED);
-      LOG.info("Fixed hole by adding {} in CLOSED state; region NOT assigned 
(assign to ONLINE).",
-          ri);
+
+    LOG.info("Identified {} region holes to fix.", holes.size());
+
+    final List<RegionInfo> newRegionInfos = mapHolesToRegionInfos(holes);
+    final List<RegionInfo> newRegionDirectories =
+      createRegionDirectories(masterServices, newRegionInfos);
+    final List<RegionInfo> newMetaEntries = createMetaEntries(masterServices, 
newRegionDirectories);
+
+    // this call uses the bulk method `createAssignProcedures` instead of 
one-at-a-time method
+    // `assign`. The bulk method makes no assertions on existing region state, 
while `assign` does.
+    // Probably we would like to assertions to be run, but since we're just 
creating these regions,
+    // we assume those preconditions to be satisfied (regionState = 
State.CLOSED).
+    final TransitRegionStateProcedure[] scheduledProcedures =
+      
masterServices.getAssignmentManager().createAssignProcedures(newMetaEntries);
+    
masterServices.getMasterProcedureExecutor().submitProcedures(scheduledProcedures);
+    LOG.info(
+      "Submitted {}/{} new regions for assignment.", 
scheduledProcedures.length, holes.size());
+    if (LOG.isDebugEnabled()) {
 
 Review comment:
   nit: either INFO or the DEBUG but not both.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to