You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2018/09/08 01:00:37 UTC

hbase git commit: HBASE-21144 Addendum fix race when testing whether a procedure is finished

Repository: hbase
Updated Branches:
  refs/heads/master 9af7bc620 -> b04b4b0fd


HBASE-21144 Addendum fix race when testing whether a procedure is finished


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/b04b4b0f
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/b04b4b0f
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/b04b4b0f

Branch: refs/heads/master
Commit: b04b4b0fd127db81f8186ff55091fd033cf1b0c4
Parents: 9af7bc6
Author: zhangduo <zh...@apache.org>
Authored: Fri Sep 7 20:58:22 2018 +0800
Committer: zhangduo <zh...@apache.org>
Committed: Sat Sep 8 08:57:56 2018 +0800

----------------------------------------------------------------------
 .../master/procedure/ProcedureSyncWait.java     | 23 ++++++++++++++------
 1 file changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/b04b4b0f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ProcedureSyncWait.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ProcedureSyncWait.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ProcedureSyncWait.java
index 328ac00..f72905b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ProcedureSyncWait.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ProcedureSyncWait.java
@@ -40,6 +40,8 @@ import org.apache.yetus.audience.InterfaceStability;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureState;
+
 /**
  * Helper to synchronously wait on conditions.
  * This will be removed in the future (mainly when the AssignmentManager will be
@@ -135,18 +137,25 @@ public final class ProcedureSyncWait {
   }
 
   public static byte[] waitForProcedureToComplete(
-      final ProcedureExecutor<MasterProcedureEnv> procExec,
-      final Procedure<?> proc, final long timeout)
-      throws IOException {
+      final ProcedureExecutor<MasterProcedureEnv> procExec, final Procedure<?> proc,
+      final long timeout) throws IOException {
     waitFor(procExec.getEnvironment(), "pid=" + proc.getProcId(),
       new ProcedureSyncWait.Predicate<Boolean>() {
         @Override
         public Boolean evaluate() throws IOException {
-          return !procExec.isRunning() || procExec.isFinished(proc.getProcId());
+          if (!procExec.isRunning()) {
+            return true;
+          }
+          ProcedureState state = proc.getState();
+          if (state == ProcedureState.INITIALIZING || state == ProcedureState.RUNNABLE) {
+            // under these states the procedure may have not been added to procExec yet, so do not
+            // use isFinished to test whether it is finished, as this method will just check if the
+            // procedure is in the running procedure list
+            return false;
+          }
+          return procExec.isFinished(proc.getProcId());
         }
-      }
-    );
-
+      });
     if (!procExec.isRunning()) {
       throw new IOException("The Master is Aborting");
     }