Skip to content

Commit

Permalink
HBASE-28533 On split procedure rollback revert parent region state ba…
Browse files Browse the repository at this point in the history
…ck to OPEN (#5863)

Co-authored-by: Daniel Roudnitsky <[email protected]>
Signed-off-by: Duo Zhang <[email protected]>
(cherry picked from commit 8a2f3ef)
  • Loading branch information
droudnitsky authored and Apache9 committed Apr 30, 2024
1 parent 344cc0d commit 211d5fc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 211d5fc

Please sign in to comment.