Skip to content

Commit

Permalink
CDPD-72877: Backport HBASE-28533 On split procedure rollback revert p…
Browse files Browse the repository at this point in the history
…arent region state back to OPEN (apache#5863) (apache#138)

(cherry picked from commit 8a2f3ef)

Signed-off-by: Duo Zhang <[email protected]>
Co-authored-by: droudnitsky <[email protected]>
Co-authored-by: Daniel Roudnitsky <[email protected]>
  • Loading branch information
3 people authored and GitHub Enterprise committed Aug 14, 2024
1 parent 5cd2e89 commit e51fec8
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 @@ -391,7 +391,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 @@ -570,6 +571,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 @@ -47,6 +47,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 @@ -236,6 +237,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 e51fec8

Please sign in to comment.