HBASE-21422 NPE in TestMergeTableRegionsProcedure.testMergeWithoutPONR
This commit is contained in:
parent
ee55b558c0
commit
e7f6c2972d
|
@ -92,29 +92,29 @@ public class ProcedureExecutor<TEnvironment> {
|
|||
* break PE having it fail at various junctures. When non-null, testing is set to an instance of
|
||||
* the below internal {@link Testing} class with flags set for the particular test.
|
||||
*/
|
||||
Testing testing = null;
|
||||
volatile Testing testing = null;
|
||||
|
||||
/**
|
||||
* Class with parameters describing how to fail/die when in testing-context.
|
||||
*/
|
||||
public static class Testing {
|
||||
protected boolean killIfHasParent = true;
|
||||
protected boolean killIfSuspended = false;
|
||||
protected volatile boolean killIfHasParent = true;
|
||||
protected volatile boolean killIfSuspended = false;
|
||||
|
||||
/**
|
||||
* Kill the PE BEFORE we store state to the WAL. Good for figuring out if a Procedure is
|
||||
* persisting all the state it needs to recover after a crash.
|
||||
*/
|
||||
protected boolean killBeforeStoreUpdate = false;
|
||||
protected boolean toggleKillBeforeStoreUpdate = false;
|
||||
protected volatile boolean killBeforeStoreUpdate = false;
|
||||
protected volatile boolean toggleKillBeforeStoreUpdate = false;
|
||||
|
||||
/**
|
||||
* Set when we want to fail AFTER state has been stored into the WAL. Rarely used. HBASE-20978
|
||||
* is about a case where memory-state was being set after store to WAL where a crash could
|
||||
* cause us to get stuck. This flag allows killing at what was a vulnerable time.
|
||||
*/
|
||||
protected boolean killAfterStoreUpdate = false;
|
||||
protected boolean toggleKillAfterStoreUpdate = false;
|
||||
protected volatile boolean killAfterStoreUpdate = false;
|
||||
protected volatile boolean toggleKillAfterStoreUpdate = false;
|
||||
|
||||
protected boolean shouldKillBeforeStoreUpdate() {
|
||||
final boolean kill = this.killBeforeStoreUpdate;
|
||||
|
|
|
@ -133,16 +133,15 @@ public class ProcedureTestingUtility {
|
|||
if (actionBeforeStartWorker != null) {
|
||||
actionBeforeStartWorker.call();
|
||||
}
|
||||
if (avoidTestKillDuringRestart) {
|
||||
procExecutor.testing = testing;
|
||||
}
|
||||
if (startWorkers) {
|
||||
procExecutor.startWorkers();
|
||||
}
|
||||
if (startAction != null) {
|
||||
startAction.call();
|
||||
}
|
||||
|
||||
if (avoidTestKillDuringRestart) {
|
||||
procExecutor.testing = testing;
|
||||
}
|
||||
}
|
||||
|
||||
public static void storeRestart(ProcedureStore procStore, ProcedureStore.ProcedureLoader loader)
|
||||
|
|
|
@ -275,36 +275,31 @@ public class TestMergeTableRegionsProcedure {
|
|||
|
||||
@Test
|
||||
public void testMergeWithoutPONR() throws Exception {
|
||||
try {
|
||||
final TableName tableName = TableName.valueOf("testMergeWithoutPONR");
|
||||
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
|
||||
final TableName tableName = TableName.valueOf("testMergeWithoutPONR");
|
||||
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
|
||||
|
||||
List<RegionInfo> tableRegions = createTable(tableName);
|
||||
List<RegionInfo> tableRegions = createTable(tableName);
|
||||
|
||||
ProcedureTestingUtility.waitNoProcedureRunning(procExec);
|
||||
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);
|
||||
ProcedureTestingUtility.waitNoProcedureRunning(procExec);
|
||||
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);
|
||||
|
||||
RegionInfo[] regionsToMerge = new RegionInfo[2];
|
||||
regionsToMerge[0] = tableRegions.get(0);
|
||||
regionsToMerge[1] = tableRegions.get(1);
|
||||
RegionInfo[] regionsToMerge = new RegionInfo[2];
|
||||
regionsToMerge[0] = tableRegions.get(0);
|
||||
regionsToMerge[1] = tableRegions.get(1);
|
||||
|
||||
long procId = procExec.submitProcedure(
|
||||
new MergeTableRegionsProcedure(procExec.getEnvironment(), regionsToMerge, true));
|
||||
long procId = procExec.submitProcedure(
|
||||
new MergeTableRegionsProcedure(procExec.getEnvironment(), regionsToMerge, true));
|
||||
|
||||
// Execute until step 9 of split procedure
|
||||
// NOTE: step 9 is after step MERGE_TABLE_REGIONS_UPDATE_META
|
||||
MasterProcedureTestingUtility.testRecoveryAndDoubleExecution(procExec, procId, 9, false);
|
||||
// Execute until step 9 of split procedure
|
||||
// NOTE: step 9 is after step MERGE_TABLE_REGIONS_UPDATE_META
|
||||
MasterProcedureTestingUtility.testRecoveryAndDoubleExecution(procExec, procId, 9, false);
|
||||
|
||||
// Unset Toggle Kill and make ProcExec work correctly
|
||||
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false);
|
||||
MasterProcedureTestingUtility.restartMasterProcedureExecutor(procExec);
|
||||
ProcedureTestingUtility.waitProcedure(procExec, procId);
|
||||
// Unset Toggle Kill and make ProcExec work correctly
|
||||
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false);
|
||||
MasterProcedureTestingUtility.restartMasterProcedureExecutor(procExec);
|
||||
ProcedureTestingUtility.waitProcedure(procExec, procId);
|
||||
|
||||
assertRegionCount(tableName, initialRegionCount - 1);
|
||||
} catch (Throwable t) {
|
||||
LOG.error("error!", t);
|
||||
throw t;
|
||||
}
|
||||
assertRegionCount(tableName, initialRegionCount - 1);
|
||||
}
|
||||
|
||||
private List<RegionInfo> createTable(final TableName tableName) throws Exception {
|
||||
|
|
|
@ -110,8 +110,12 @@ public class MasterProcedureTestingUtility {
|
|||
@Override
|
||||
public Void call() throws Exception {
|
||||
AssignmentManager am = env.getAssignmentManager();
|
||||
am.joinCluster();
|
||||
master.setInitialized(true);
|
||||
try {
|
||||
am.joinCluster();
|
||||
master.setInitialized(true);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Failed to load meta", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.io.IOException;
|
|||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.MiniHBaseCluster;
|
||||
import org.apache.hadoop.hbase.ServerName;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
|
@ -63,7 +64,8 @@ public class TestServerCrashProcedure {
|
|||
private void setupConf(Configuration conf) {
|
||||
conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1);
|
||||
conf.set("hbase.balancer.tablesOnMaster", "none");
|
||||
conf.setInt("hbase.client.retries.number", 3);
|
||||
conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 3);
|
||||
conf.setInt(HConstants.HBASE_CLIENT_SERVERSIDE_RETRIES_MULTIPLIER, 3);
|
||||
}
|
||||
|
||||
@Before
|
||||
|
|
Loading…
Reference in New Issue