From 82e042fcf3fdbfae23a22adc9f43ae00cc9bcb9b Mon Sep 17 00:00:00 2001 From: zhangduo Date: Thu, 1 Nov 2018 21:09:30 +0800 Subject: [PATCH] HBASE-21422 NPE in TestMergeTableRegionsProcedure.testMergeWithoutPONR --- .../hadoop/hbase/procedure2/ProcedureExecutor.java | 14 +++++++------- .../hbase/procedure2/ProcedureTestingUtility.java | 7 +++---- .../apache/hadoop/hbase/HBaseTestingUtility.java | 1 + 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java index 9515a7a2ac..f0affd2b8a 100644 --- a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java +++ b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java @@ -92,29 +92,29 @@ public class ProcedureExecutor { * 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; diff --git a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/ProcedureTestingUtility.java b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/ProcedureTestingUtility.java index 5a7a664c00..452e08bc9c 100644 --- a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/ProcedureTestingUtility.java +++ b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/ProcedureTestingUtility.java @@ -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) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index 7f5e11a11a..1cd4f9e4ba 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -171,6 +171,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; * avoiding port contention if another local HBase instance is already running). *

To preserve test data directories, pass the system property "hbase.testing.preserve.testdir" * setting it to true. + * Trigger UTs. */ @InterfaceAudience.Public @SuppressWarnings("deprecation") -- 2.17.1