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 b2a2e5a4a44..c579626a605 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 @@ -124,7 +124,7 @@ public abstract class AbstractProcedureScheduler implements ProcedureScheduler { try { enqueue(procedure, addFront); if (notify) { - schedWaitCond.signal(); + schedWaitCond.signalAll(); } } finally { schedUnlock(); @@ -311,10 +311,6 @@ public abstract class AbstractProcedureScheduler implements ProcedureScheduler { if (waitingCount <= 0) { return; } - if (waitingCount == 1) { - schedWaitCond.signal(); - } else { - schedWaitCond.signalAll(); - } + schedWaitCond.signalAll(); } } 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 a5b66a04752..93c255f3340 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 @@ -211,7 +211,7 @@ public class ProcedureExecutor { /** * Worker thread only for urgent tasks. */ - private List urgentWorkerThreads; + private CopyOnWriteArrayList urgentWorkerThreads; /** * Created in the {@link #init(int, boolean)} method. Terminated in {@link #join()} (FIX! Doing @@ -564,7 +564,7 @@ public class ProcedureExecutor { * is found on replay. otherwise false. */ public void init(int numThreads, boolean abortOnCorruption) throws IOException { - init(numThreads, 1, abortOnCorruption); + init(numThreads, 0, abortOnCorruption); } /** @@ -595,7 +595,7 @@ public class ProcedureExecutor { // Create the workers workerId.set(0); workerThreads = new CopyOnWriteArrayList<>(); - urgentWorkerThreads = new ArrayList<>(); + urgentWorkerThreads = new CopyOnWriteArrayList<>(); for (int i = 0; i < corePoolSize; ++i) { workerThreads.add(new WorkerThread(threadGroup)); } @@ -637,7 +637,7 @@ public class ProcedureExecutor { return; } // Start the executors. Here we must have the lastProcId set. - LOG.debug("Start workers {}, urgent workers", workerThreads.size(), + LOG.debug("Start workers {}, urgent workers {}", workerThreads.size(), urgentWorkerThreads.size()); timeoutExecutor.start(); for (WorkerThread worker: workerThreads) { @@ -2023,7 +2023,8 @@ public class ProcedureExecutor { long lastUpdate = EnvironmentEdgeManager.currentTime(); try { while (isRunning() && keepAlive(lastUpdate)) { - Procedure proc = scheduler.poll(keepAliveTime, TimeUnit.MILLISECONDS); + Procedure proc = scheduler + .poll(onlyPollUrgent, keepAliveTime, TimeUnit.MILLISECONDS); if (proc == null) { continue; } 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 1709f63a0be..220e062afac 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 @@ -87,7 +87,7 @@ public class ProcedureTestingUtility { public static void initAndStartWorkers(ProcedureExecutor procExecutor, int numThreads, boolean abortOnCorruption, boolean startWorkers) throws IOException { - initAndStartWorkers(procExecutor, numThreads, 1, abortOnCorruption, startWorkers); + initAndStartWorkers(procExecutor, numThreads, 0, abortOnCorruption, startWorkers); } public static void initAndStartWorkers(ProcedureExecutor procExecutor, int numThreads, diff --git a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestYieldProcedures.java b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestYieldProcedures.java index 1f840cde026..a753816822c 100644 --- a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestYieldProcedures.java +++ b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestYieldProcedures.java @@ -380,7 +380,6 @@ public class TestYieldProcedures { @Override public Procedure poll() { - LOG.error("polled()"); pollCalls++; return super.poll(); } @@ -388,10 +387,15 @@ public class TestYieldProcedures { @Override public Procedure poll(long timeout, TimeUnit unit) { pollCalls++; - LOG.error("polled(long timeout, TimeUnit unit)"); return super.poll(timeout, unit); } + @Override + public Procedure poll(boolean onlyUrgent, long timeout, TimeUnit unit) { + pollCalls++; + return super.poll(onlyUrgent, timeout, unit); + } + @Override public void completionCleanup(Procedure proc) { completionCalls++; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentOnRSCrash.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentOnRSCrash.java index c4055fe2a41..0bbdb819884 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentOnRSCrash.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestAssignmentOnRSCrash.java @@ -62,6 +62,7 @@ public class TestAssignmentOnRSCrash { private static void setupConf(Configuration conf) { conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1); + conf.setInt(MasterProcedureConstants.MASTER_URGENT_PROCEDURE_THREADS, 0); conf.set("hbase.balancer.tablesOnMaster", "none"); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestMergeTableRegionsProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestMergeTableRegionsProcedure.java index 76011f6c71c..e1774cb4ea8 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestMergeTableRegionsProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestMergeTableRegionsProcedure.java @@ -86,6 +86,7 @@ public class TestMergeTableRegionsProcedure { conf.setInt("hbase.master.maximum.ping.server.attempts", 3); conf.setInt("hbase.master.ping.server.retry.sleep.interval", 1); conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1); + conf.setInt(MasterProcedureConstants.MASTER_URGENT_PROCEDURE_THREADS, 0); } @BeforeClass diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRogueRSAssignment.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRogueRSAssignment.java index c88e5837842..bb048257585 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRogueRSAssignment.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRogueRSAssignment.java @@ -94,6 +94,7 @@ public class TestRogueRSAssignment { conf.setInt("hbase.master.maximum.ping.server.attempts", 3); conf.setInt("hbase.master.ping.server.retry.sleep.interval", 1); conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1); + conf.setInt(MasterProcedureConstants.MASTER_URGENT_PROCEDURE_THREADS, 0); } @BeforeClass diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/locking/TestLockManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/locking/TestLockManager.java index 9f964c6f46c..83bec7076f2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/locking/TestLockManager.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/locking/TestLockManager.java @@ -70,6 +70,7 @@ public class TestLockManager { private static void setupConf(Configuration conf) { conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1); + conf.setInt(MasterProcedureConstants.MASTER_URGENT_PROCEDURE_THREADS, 0); conf.setBoolean("hbase.procedure.check.owner.set", false); // since rpc user will be null conf.setInt(LockProcedure.LOCAL_MASTER_LOCKS_TIMEOUT_MS_CONF, LOCAL_LOCKS_TIMEOUT); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/locking/TestLockProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/locking/TestLockProcedure.java index 8fa7747c1e4..b85b84391b3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/locking/TestLockProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/locking/TestLockProcedure.java @@ -98,6 +98,7 @@ public class TestLockProcedure { private static void setupConf(Configuration conf) { conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1); + conf.setInt(MasterProcedureConstants.MASTER_URGENT_PROCEDURE_THREADS, 0); conf.setBoolean("hbase.procedure.check.owner.set", false); // since rpc user will be null conf.setInt(LockProcedure.REMOTE_LOCKS_TIMEOUT_MS_CONF, HEARTBEAT_TIMEOUT); conf.setInt(LockProcedure.LOCAL_MASTER_LOCKS_TIMEOUT_MS_CONF, LOCAL_LOCKS_TIMEOUT); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateNamespaceProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateNamespaceProcedure.java index eb904b48a47..3c0304e0fd8 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateNamespaceProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateNamespaceProcedure.java @@ -57,6 +57,7 @@ public class TestCreateNamespaceProcedure { private static void setupConf(Configuration conf) { conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1); + conf.setInt(MasterProcedureConstants.MASTER_URGENT_PROCEDURE_THREADS, 0); } @BeforeClass diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteNamespaceProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteNamespaceProcedure.java index 2f1a984a657..e0319ae5da1 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteNamespaceProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteNamespaceProcedure.java @@ -63,6 +63,7 @@ public class TestDeleteNamespaceProcedure { private static void setupConf(Configuration conf) { conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1); + conf.setInt(MasterProcedureConstants.MASTER_URGENT_PROCEDURE_THREADS, 0); } @BeforeClass diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterFailoverWithProcedures.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterFailoverWithProcedures.java index 48a3237f2a5..a51445af160 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterFailoverWithProcedures.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterFailoverWithProcedures.java @@ -67,6 +67,7 @@ public class TestMasterFailoverWithProcedures { conf.setInt(WALProcedureStore.ROLL_RETRIES_CONF_KEY, 1); conf.setInt(WALProcedureStore.MAX_SYNC_FAILURE_ROLL_CONF_KEY, 1); conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1); + conf.setInt(MasterProcedureConstants.MASTER_URGENT_PROCEDURE_THREADS, 0); } @Before diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterObserverPostCalls.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterObserverPostCalls.java index e6357103a86..8ad7aa00469 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterObserverPostCalls.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterObserverPostCalls.java @@ -72,6 +72,7 @@ public class TestMasterObserverPostCalls { private static void setupConf(Configuration conf) { conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1); + conf.setInt(MasterProcedureConstants.MASTER_URGENT_PROCEDURE_THREADS, 0); conf.set(MasterCoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, MasterObserverForTest.class.getName()); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterProcedureEvents.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterProcedureEvents.java index a56e842adb0..ea712c22cd0 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterProcedureEvents.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterProcedureEvents.java @@ -63,6 +63,7 @@ public class TestMasterProcedureEvents { private static void setupConf(Configuration conf) { conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1); + conf.setInt(MasterProcedureConstants.MASTER_URGENT_PROCEDURE_THREADS, 0); conf.setBoolean(WALProcedureStore.USE_HSYNC_CONF_KEY, false); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestModifyNamespaceProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestModifyNamespaceProcedure.java index e76aacd247c..783d4e3512b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestModifyNamespaceProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestModifyNamespaceProcedure.java @@ -56,6 +56,7 @@ public class TestModifyNamespaceProcedure { private static void setupConf(Configuration conf) { conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1); + conf.setInt(MasterProcedureConstants.MASTER_URGENT_PROCEDURE_THREADS, 0); } @BeforeClass diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestProcedureAdmin.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestProcedureAdmin.java index 02f0257a2f0..29645c2e397 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestProcedureAdmin.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestProcedureAdmin.java @@ -60,6 +60,7 @@ public class TestProcedureAdmin { private static void setupConf(Configuration conf) { conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1); + conf.setInt(MasterProcedureConstants.MASTER_URGENT_PROCEDURE_THREADS, 0); } @BeforeClass diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestSafemodeBringsDownMaster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestSafemodeBringsDownMaster.java index 44c55103b6b..ec2efdaaa79 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestSafemodeBringsDownMaster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestSafemodeBringsDownMaster.java @@ -58,6 +58,7 @@ public class TestSafemodeBringsDownMaster { private static void setupConf(Configuration conf) { conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1); + conf.setInt(MasterProcedureConstants.MASTER_URGENT_PROCEDURE_THREADS, 0); conf.set(BaseLoadBalancer.TABLES_ON_MASTER, "none"); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure/TestUrgentProcedureWorker.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure/TestUrgentProcedureWorker.java index c7801e433f6..17352258d3a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure/TestUrgentProcedureWorker.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure/TestUrgentProcedureWorker.java @@ -169,7 +169,7 @@ public class TestUrgentProcedureWorker { MasterProcedureScheduler scheduler = new MasterProcedureScheduler(pid -> null); procExec = new ProcedureExecutor<>(UTIL.getConfiguration(), new TestEnv(scheduler), procStore, scheduler); - procExec.init(1, false); + procExec.init(1, 1, false); procExec.startWorkers(); }