Skip to content

Commit 06eff55

Browse files
authored
HBASE-23615 Use a dedicated thread for executing WorkerMonitor in Pro… (#961)
Signed-off-by: stack <stack@apache.org> Signed-off-by: Duo Zhang <zhangduo@apache.org> Signed-off-by: virajjasani <34790606+virajjasani@users.noreply.github.com>
1 parent 923ba77 commit 06eff55

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,15 @@ public interface ProcedureExecutorListener {
217217
*/
218218
private TimeoutExecutorThread<TEnvironment> timeoutExecutor;
219219

220+
/**
221+
* WorkerMonitor check for stuck workers and new worker thread when necessary, for example if
222+
* there is no worker to assign meta, it will new worker thread for it, so it is very important.
223+
* TimeoutExecutor execute many tasks like DeadServerMetricRegionChore RegionInTransitionChore
224+
* and so on, some tasks may execute for a long time so will block other tasks like
225+
* WorkerMonitor, so use a dedicated thread for executing WorkerMonitor.
226+
*/
227+
private TimeoutExecutorThread<TEnvironment> workerMonitorExecutor;
228+
220229
private int corePoolSize;
221230
private int maxPoolSize;
222231

@@ -560,7 +569,8 @@ public void init(int numThreads, boolean abortOnCorruption) throws IOException {
560569
corePoolSize, maxPoolSize);
561570

562571
this.threadGroup = new ThreadGroup("PEWorkerGroup");
563-
this.timeoutExecutor = new TimeoutExecutorThread<>(this, threadGroup);
572+
this.timeoutExecutor = new TimeoutExecutorThread<>(this, threadGroup, "ProcExecTimeout");
573+
this.workerMonitorExecutor = new TimeoutExecutorThread<>(this, threadGroup, "WorkerMonitor");
564574

565575
// Create the workers
566576
workerId.set(0);
@@ -604,12 +614,13 @@ public void startWorkers() throws IOException {
604614
// Start the executors. Here we must have the lastProcId set.
605615
LOG.trace("Start workers {}", workerThreads.size());
606616
timeoutExecutor.start();
617+
workerMonitorExecutor.start();
607618
for (WorkerThread worker: workerThreads) {
608619
worker.start();
609620
}
610621

611622
// Internal chores
612-
timeoutExecutor.add(new WorkerMonitor());
623+
workerMonitorExecutor.add(new WorkerMonitor());
613624

614625
// Add completed cleaner chore
615626
addChore(new CompletedProcedureCleaner<>(conf, store, procExecutionLock, completed,
@@ -624,6 +635,7 @@ public void stop() {
624635
LOG.info("Stopping");
625636
scheduler.stop();
626637
timeoutExecutor.sendStopSignal();
638+
workerMonitorExecutor.sendStopSignal();
627639
}
628640

629641
@VisibleForTesting
@@ -632,6 +644,8 @@ public void join() {
632644

633645
// stop the timeout executor
634646
timeoutExecutor.awaitTermination();
647+
// stop the work monitor executor
648+
workerMonitorExecutor.awaitTermination();
635649

636650
// stop the worker threads
637651
for (WorkerThread worker: workerThreads) {

hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/TimeoutExecutorThread.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ class TimeoutExecutorThread<TEnvironment> extends StoppableThread {
3737

3838
private final DelayQueue<DelayedWithTimeout> queue = new DelayQueue<>();
3939

40-
public TimeoutExecutorThread(ProcedureExecutor<TEnvironment> executor, ThreadGroup group) {
41-
super(group, "ProcExecTimeout");
40+
public TimeoutExecutorThread(ProcedureExecutor<TEnvironment> executor, ThreadGroup group,
41+
String name) {
42+
super(group, name);
4243
setDaemon(true);
4344
this.executor = executor;
4445
}

hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestProcedureAdmin.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public class TestProcedureAdmin {
5757

5858
protected static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
5959

60-
6160
private static void setupConf(Configuration conf) {
6261
conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1);
6362
}

0 commit comments

Comments
 (0)