Skip to content

Commit 72c1a84

Browse files
authored
HBASE-27332 Remove RejectedExecutionHandler for long/short compaction thread pools (#4731)
Signed-off-by: Duo Zhang <[email protected]>
1 parent 3d39482 commit 72c1a84

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplit.java

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.util.concurrent.ConcurrentHashMap;
3232
import java.util.concurrent.Executors;
3333
import java.util.concurrent.RejectedExecutionException;
34-
import java.util.concurrent.RejectedExecutionHandler;
3534
import java.util.concurrent.ThreadPoolExecutor;
3635
import java.util.concurrent.TimeUnit;
3736
import java.util.concurrent.atomic.AtomicInteger;
@@ -145,15 +144,18 @@ private void createCompactionExecutors() {
145144
final String n = Thread.currentThread().getName();
146145

147146
StealJobQueue<Runnable> stealJobQueue = new StealJobQueue<Runnable>(COMPARATOR);
147+
// Since the StealJobQueue inner uses the PriorityBlockingQueue,
148+
// which is an unbounded blocking queue, we remove the RejectedExecutionHandler for
149+
// the long and short compaction thread pool executors since HBASE-27332.
150+
// If anyone who what to change the StealJobQueue to a bounded queue,
151+
// please add the rejection handler back.
148152
this.longCompactions = new ThreadPoolExecutor(largeThreads, largeThreads, 60, TimeUnit.SECONDS,
149153
stealJobQueue,
150154
new ThreadFactoryBuilder().setNameFormat(n + "-longCompactions-%d").setDaemon(true).build());
151-
this.longCompactions.setRejectedExecutionHandler(new Rejection());
152155
this.longCompactions.prestartAllCoreThreads();
153156
this.shortCompactions = new ThreadPoolExecutor(smallThreads, smallThreads, 60, TimeUnit.SECONDS,
154157
stealJobQueue.getStealFromQueue(),
155158
new ThreadFactoryBuilder().setNameFormat(n + "-shortCompactions-%d").setDaemon(true).build());
156-
this.shortCompactions.setRejectedExecutionHandler(new Rejection());
157159
}
158160

159161
@Override
@@ -724,22 +726,6 @@ private String formatStackTrace(Exception ex) {
724726
}
725727
}
726728

727-
/**
728-
* Cleanup class to use when rejecting a compaction request from the queue.
729-
*/
730-
private static class Rejection implements RejectedExecutionHandler {
731-
@Override
732-
public void rejectedExecution(Runnable runnable, ThreadPoolExecutor pool) {
733-
if (runnable instanceof CompactionRunner) {
734-
CompactionRunner runner = (CompactionRunner) runnable;
735-
LOG.debug("Compaction Rejected: " + runner);
736-
if (runner.compaction != null) {
737-
runner.store.cancelRequestedCompaction(runner.compaction);
738-
}
739-
}
740-
}
741-
}
742-
743729
/**
744730
* {@inheritDoc}
745731
*/

0 commit comments

Comments
 (0)