From 26828b1860bb8f0dfedccf9f179b56fdf3c70663 Mon Sep 17 00:00:00 2001 From: Allan Yang Date: Mon, 13 Aug 2018 20:12:57 +0800 Subject: [PATCH] HBASE-20975 Lock may not be taken or released while rolling back procedure --- .../hbase/procedure2/ProcedureExecutor.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 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 2ee80d7c85c..464eaeb5002 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 @@ -1363,29 +1363,21 @@ public class ProcedureExecutor { assert subprocStack != null : "Called rollback with no steps executed rootProc=" + rootProc; int stackTail = subprocStack.size(); - boolean reuseLock = false; - while (stackTail --> 0) { + while (stackTail-- > 0) { Procedure proc = subprocStack.get(stackTail); - LockState lockState; - if (!reuseLock && (lockState = acquireLock(proc)) != LockState.LOCK_ACQUIRED) { + LockState lockState = acquireLock(proc); + if (lockState != LockState.LOCK_ACQUIRED) { // can't take a lock on the procedure, add the root-proc back on the // queue waiting for the lock availability return lockState; } lockState = executeRollback(proc); + releaseLock(proc, false); boolean abortRollback = lockState != LockState.LOCK_ACQUIRED; abortRollback |= !isRunning() || !store.isRunning(); - // If the next procedure is the same to this one - // (e.g. StateMachineProcedure reuse the same instance) - // we can avoid to lock/unlock each step - reuseLock = stackTail > 0 && (subprocStack.get(stackTail - 1) == proc) && !abortRollback; - if (!reuseLock && proc.hasLock()) { - releaseLock(proc, false); - } - // allows to kill the executor before something is stored to the wal. // useful to test the procedure recovery. if (abortRollback) {