virajjasani commented on code in PR #5799:
URL: https://github.com/apache/hbase/pull/5799#discussion_r1555019484


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/MergeTableRegionsProcedure.java:
##########
@@ -639,8 +639,22 @@ private void cleanupMergedRegion(final MasterProcedureEnv 
env) throws IOExceptio
    * Rollback close regions
    **/
   private void rollbackCloseRegionsForMerge(MasterProcedureEnv env) throws 
IOException {
-    AssignmentManagerUtil.reopenRegionsForRollback(env, 
Arrays.asList(regionsToMerge),
-      getRegionReplication(env), getServerName(env));
+    // At this point we should check if region was actually closed. If it was 
not closed then we
+    // don't need to repoen the region and we can just change the regionNode 
state to OPEN.
+    // if it is alredy closed then we need to do a reopen of region
+    List<RegionInfo> toAssign = new ArrayList<>();
+    for (RegionInfo rinfo : regionsToMerge) {
+      RegionStateNode regionStateNode =
+        env.getAssignmentManager().getRegionStates().getRegionStateNode(rinfo);
+      if (regionStateNode.getState() == State.MERGING) {
+        regionStateNode.setState(State.OPEN);
+      } else {
+        // same as before HBASE-28405
+        toAssign.add(rinfo);
+      }
+    }
+    AssignmentManagerUtil.reopenRegionsForRollback(env, toAssign, 
getRegionReplication(env),

Review Comment:
   Looks good overall, maybe as an extra short-circuit, we can wrap this with 
"if the list is not empty"



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to