HBASE-21422 NPE in TestMergeTableRegionsProcedure.testMergeWithoutPONR

This commit is contained in:
zhangduo 2018-11-02 20:54:00 +08:00
parent b7efc8d4e7
commit 943f65f3b5
5 changed files with 20 additions and 15 deletions

View File

@ -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 * 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. * 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. * Class with parameters describing how to fail/die when in testing-context.
*/ */
public static class Testing { public static class Testing {
protected boolean killIfHasParent = true; protected volatile boolean killIfHasParent = true;
protected boolean killIfSuspended = false; protected volatile boolean killIfSuspended = false;
/** /**
* Kill the PE BEFORE we store state to the WAL. Good for figuring out if a Procedure is * 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. * persisting all the state it needs to recover after a crash.
*/ */
protected boolean killBeforeStoreUpdate = false; protected volatile boolean killBeforeStoreUpdate = false;
protected boolean toggleKillBeforeStoreUpdate = false; protected volatile boolean toggleKillBeforeStoreUpdate = false;
/** /**
* Set when we want to fail AFTER state has been stored into the WAL. Rarely used. HBASE-20978 * 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 * 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. * cause us to get stuck. This flag allows killing at what was a vulnerable time.
*/ */
protected boolean killAfterStoreUpdate = false; protected volatile boolean killAfterStoreUpdate = false;
protected boolean toggleKillAfterStoreUpdate = false; protected volatile boolean toggleKillAfterStoreUpdate = false;
protected boolean shouldKillBeforeStoreUpdate() { protected boolean shouldKillBeforeStoreUpdate() {
final boolean kill = this.killBeforeStoreUpdate; final boolean kill = this.killBeforeStoreUpdate;

View File

@ -133,16 +133,15 @@ public class ProcedureTestingUtility {
if (actionBeforeStartWorker != null) { if (actionBeforeStartWorker != null) {
actionBeforeStartWorker.call(); actionBeforeStartWorker.call();
} }
if (avoidTestKillDuringRestart) {
procExecutor.testing = testing;
}
if (startWorkers) { if (startWorkers) {
procExecutor.startWorkers(); procExecutor.startWorkers();
} }
if (startAction != null) { if (startAction != null) {
startAction.call(); startAction.call();
} }
if (avoidTestKillDuringRestart) {
procExecutor.testing = testing;
}
} }
public static void storeRestart(ProcedureStore procStore, ProcedureStore.ProcedureLoader loader) public static void storeRestart(ProcedureStore procStore, ProcedureStore.ProcedureLoader loader)

View File

@ -288,7 +288,7 @@ public class TestMergeTableRegionsProcedure {
regionsToMerge[1] = tableRegions.get(1); regionsToMerge[1] = tableRegions.get(1);
long procId = procExec.submitProcedure( long procId = procExec.submitProcedure(
new MergeTableRegionsProcedure(procExec.getEnvironment(), regionsToMerge, true)); new MergeTableRegionsProcedure(procExec.getEnvironment(), regionsToMerge, true));
// Execute until step 9 of split procedure // Execute until step 9 of split procedure
// NOTE: step 9 is after step MERGE_TABLE_REGIONS_UPDATE_META // NOTE: step 9 is after step MERGE_TABLE_REGIONS_UPDATE_META

View File

@ -110,8 +110,12 @@ public class MasterProcedureTestingUtility {
@Override @Override
public Void call() throws Exception { public Void call() throws Exception {
AssignmentManager am = env.getAssignmentManager(); AssignmentManager am = env.getAssignmentManager();
am.joinCluster(); try {
master.setInitialized(true); am.joinCluster();
master.setInitialized(true);
} catch (Exception e) {
LOG.warn("Failed to load meta", e);
}
return null; return null;
} }
}); });

View File

@ -25,6 +25,7 @@ import java.io.IOException;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MiniHBaseCluster; import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
@ -63,7 +64,8 @@ public class TestServerCrashProcedure {
private void setupConf(Configuration conf) { private void setupConf(Configuration conf) {
conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1); conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1);
conf.set("hbase.balancer.tablesOnMaster", "none"); 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 @Before