diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/SplitTableRegionProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/SplitTableRegionProcedure.java index 2e2182b25d29..afa0f5e42b07 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/SplitTableRegionProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/SplitTableRegionProcedure.java @@ -392,7 +392,8 @@ protected void rollbackState(final MasterProcedureEnv env, final SplitTableRegio postRollBackSplitRegion(env); break; case SPLIT_TABLE_REGION_PREPARE: - break; // nothing to do + rollbackPrepareSplit(env); + break; default: throw new UnsupportedOperationException(this + " unhandled state=" + state); } @@ -572,6 +573,18 @@ public boolean prepareSplitRegion(final MasterProcedureEnv env) throws IOExcepti return true; } + /** + * Rollback prepare split region + * @param env MasterProcedureEnv + */ + private void rollbackPrepareSplit(final MasterProcedureEnv env) { + RegionStateNode parentRegionStateNode = + env.getAssignmentManager().getRegionStates().getRegionStateNode(getParentRegion()); + if (parentRegionStateNode.getState() == State.SPLITTING) { + parentRegionStateNode.setState(State.OPEN); + } + } + /** * Action before splitting region in a table. * @param env MasterProcedureEnv diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestSplitTableRegionProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestSplitTableRegionProcedure.java index 424dd32e1d50..92a67596b25e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestSplitTableRegionProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestSplitTableRegionProcedure.java @@ -49,6 +49,7 @@ import org.apache.hadoop.hbase.coprocessor.RegionCoprocessor; import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; import org.apache.hadoop.hbase.coprocessor.RegionObserver; +import org.apache.hadoop.hbase.master.RegionState; import org.apache.hadoop.hbase.master.procedure.MasterProcedureConstants; import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv; import org.apache.hadoop.hbase.master.procedure.MasterProcedureTestingUtility; @@ -242,6 +243,11 @@ public void testRollbackForSplitTableRegionWithReplica() throws Exception { // There should not be any active OpenRegionProcedure procExec.getActiveProceduresNoCopy() .forEach(p -> assertFalse(p instanceof OpenRegionProcedure)); + + // Check that procedure rollback reverted parent region state to OPEN + AssignmentManager am = UTIL.getHBaseCluster().getMaster().getAssignmentManager(); + RegionStateNode regionStateNode = am.getRegionStates().getRegionStateNode(regions[0]); + assertEquals(RegionState.State.OPEN, regionStateNode.getState()); } @Test