hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From allan...@apache.org
Subject hbase git commit: HBASE-21364 Procedure holds the lock should put to front of the queue after restart
Date Thu, 25 Oct 2018 04:05:44 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 5dde5b787 -> 614612a9d


HBASE-21364 Procedure holds the lock should put to front of the queue after restart


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

Branch: refs/heads/master
Commit: 614612a9d8b38ea1b8b960ee9ff55e90c09e45e1
Parents: 5dde5b7
Author: Allan Yang <allan163@apache.org>
Authored: Thu Oct 25 12:05:28 2018 +0800
Committer: Allan Yang <allan163@apache.org>
Committed: Thu Oct 25 12:05:28 2018 +0800

----------------------------------------------------------------------
 .../hbase/procedure2/AbstractProcedureScheduler.java  | 10 ++++++++++
 .../org/apache/hadoop/hbase/procedure2/Procedure.java |  4 ++++
 .../hadoop/hbase/procedure2/ProcedureExecutor.java    | 11 ++++++++++-
 .../hadoop/hbase/procedure2/ProcedureScheduler.java   | 14 ++++++++++++++
 4 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/614612a9/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/AbstractProcedureScheduler.java
----------------------------------------------------------------------
diff --git a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/AbstractProcedureScheduler.java
b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/AbstractProcedureScheduler.java
index 5645f89..7ab1329 100644
--- a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/AbstractProcedureScheduler.java
+++ b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/AbstractProcedureScheduler.java
@@ -86,6 +86,11 @@ public abstract class AbstractProcedureScheduler implements ProcedureScheduler
{
   }
 
   @Override
+  public void addFront(final Procedure procedure, boolean notify) {
+    push(procedure, true, notify);
+  }
+
+  @Override
   public void addFront(Iterator<Procedure> procedureIterator) {
     schedLock();
     try {
@@ -109,6 +114,11 @@ public abstract class AbstractProcedureScheduler implements ProcedureScheduler
{
     push(procedure, false, true);
   }
 
+  @Override
+  public void addBack(final Procedure procedure, boolean notify) {
+    push(procedure, false, notify);
+  }
+
   protected void push(final Procedure procedure, final boolean addFront, final boolean notify)
{
     schedLock();
     try {

http://git-wip-us.apache.org/repos/asf/hbase/blob/614612a9/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/Procedure.java
----------------------------------------------------------------------
diff --git a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/Procedure.java
b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/Procedure.java
index d4d945d..81073e1 100644
--- a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/Procedure.java
+++ b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/Procedure.java
@@ -717,6 +717,10 @@ public abstract class Procedure<TEnvironment> implements Comparable<Procedure<TE
     this.lockedWhenLoading = true;
   }
 
+  public boolean isLockedWhenLoading() {
+    return lockedWhenLoading;
+  }
+
   // ==============================================================================================
   //  Runtime state, updated every operation by the ProcedureExecutor
   //

http://git-wip-us.apache.org/repos/asf/hbase/blob/614612a9/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java
----------------------------------------------------------------------
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 438b495..bd75827 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
@@ -652,8 +652,17 @@ public class ProcedureExecutor<TEnvironment> {
       if (!p.hasParent()) {
         sendProcedureLoadedNotification(p.getProcId());
       }
-      scheduler.addBack(p);
+      // If the procedure holds the lock, put the procedure in front
+      if (p.isLockedWhenLoading()) {
+        scheduler.addFront(p, false);
+      } else {
+        // if it was not, it can wait.
+        scheduler.addBack(p, false);
+      }
     });
+    // After all procedures put into the queue, signal the worker threads.
+    // Otherwise, there is a race condition. See HBASE-21364.
+    scheduler.signalAll();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/614612a9/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureScheduler.java
----------------------------------------------------------------------
diff --git a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureScheduler.java
b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureScheduler.java
index e7e1cdb..9489f52 100644
--- a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureScheduler.java
+++ b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureScheduler.java
@@ -53,6 +53,13 @@ public interface ProcedureScheduler {
   void addFront(Procedure proc);
 
   /**
+   * Inserts the specified element at the front of this queue.
+   * @param proc the Procedure to add
+   * @param notify whether need to notify worker
+   */
+  void addFront(Procedure proc, boolean notify);
+
+  /**
    * Inserts all elements in the iterator at the front of this queue.
    */
   void addFront(Iterator<Procedure> procedureIterator);
@@ -64,6 +71,13 @@ public interface ProcedureScheduler {
   void addBack(Procedure proc);
 
   /**
+   * Inserts the specified element at the end of this queue.
+   * @param proc the Procedure to add
+   * @param notify whether need to notify worker
+   */
+  void addBack(Procedure proc, boolean notify);
+
+  /**
    * The procedure can't run at the moment.
    * add it back to the queue, giving priority to someone else.
    * @param proc the Procedure to add back to the list


Mime
View raw message