From 7cf4da69a4b336199dbc5bd4bf9ac9300efad4e7 Mon Sep 17 00:00:00 2001 From: droudnitsky <168442446+droudnitsky@users.noreply.github.com> Date: Tue, 30 Apr 2024 09:55:40 -0400 Subject: [PATCH] HBASE-28533 On split procedure rollback revert parent region state back to OPEN (#5863) Co-authored-by: Daniel Roudnitsky Signed-off-by: Duo Zhang --- .../assignment/SplitTableRegionProcedure.java | 15 ++++++++++++++- .../assignment/TestSplitTableRegionProcedure.java | 6 ++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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 6ec36e75bea2..99092712ec72 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