From e71c05707e0717a1f1487b648e830fe7fd90d2eb Mon Sep 17 00:00:00 2001 From: Allan Yang Date: Thu, 25 Oct 2018 13:58:50 +0800 Subject: [PATCH] HBASE-21384 Procedure with holdlock=false should not be restored lock when restarts --- .../hadoop/hbase/procedure2/LockAndQueue.java | 3 ++- .../apache/hadoop/hbase/procedure2/Procedure.java | 8 +++++++- .../hbase/procedure2/ProcedureExecutor.java | 15 ++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/LockAndQueue.java b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/LockAndQueue.java index ae8daa28314..4365a2c1950 100644 --- a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/LockAndQueue.java +++ b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/LockAndQueue.java @@ -73,7 +73,8 @@ public class LockAndQueue implements LockStatus { @Override public boolean hasParentLock(Procedure proc) { - // TODO: need to check all the ancestors + // TODO: need to check all the ancestors. need to passed in the procedures + // to find the ancestors. return proc.hasParent() && (isLockOwner(proc.getParentProcId()) || isLockOwner(proc.getRootProcId())); } 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 472a0d16559..74082bf38fe 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 @@ -992,7 +992,13 @@ public abstract class Procedure implements Comparable { sendProcedureLoadedNotification(p.getProcId()); } // If the procedure holds the lock, put the procedure in front - if (p.isLockedWhenLoading()) { + // If its parent holds the lock, put the procedure in front + // TODO. Is that possible that its ancestor holds the lock? + // For now, the deepest procedure hierarchy is: + // ModifyTableProcedure -> ReopenTableProcedure -> + // MoveTableProcedure -> Unassign/AssignProcedure + // But ModifyTableProcedure and ReopenTableProcedure won't hold the lock + // So, check parent lock is enough(a tricky case is resovled by HBASE-21384). + // If some one change or add new procedures making 'grandpa' procedure + // holds the lock, but parent procedure don't hold the lock, there will + // be a problem here. We have to check one procedure's ancestors. + // And we need to change LockAndQueue.hasParentLock(Procedure proc) method + // to check all ancestors too. + if (p.isLockedWhenLoading() || (p.hasParent() && procedures + .get(p.getParentProcId()).isLockedWhenLoading())) { scheduler.addFront(p, false); } else { // if it was not, it can wait.