#124 ownJobThread may made all threads in threadPool are busy

This commit is contained in:
yanhuqing666
2017-05-05 14:58:36 +08:00
parent 7113e2c168
commit 527dd5ad0d
3 changed files with 9 additions and 18 deletions
+7 -2
View File
@@ -155,6 +155,7 @@ public class MycatServer {
private NIOProcessor[] processors;
private SocketConnector connector;
private NameableExecutor businessExecutor;
private NameableExecutor ownJobExecutor;
private NameableExecutor timerExecutor;
private ListeningExecutorService listeningExecutorService;
private InterProcessMutex dnindexLock;
@@ -219,6 +220,10 @@ public class MycatServer {
return catletClassLoader;
}
public NameableExecutor getOwnJobExecutor() {
return ownJobExecutor;
}
public String genXATXID() {
long seq = this.xaIDInc.incrementAndGet();
if (seq < 0) {
@@ -345,8 +350,8 @@ public class MycatServer {
LOGGER.error("Error",e);
}
}
businessExecutor = ExecutorUtil.createFixed("BusinessExecutor",
threadPoolSize);
businessExecutor = ExecutorUtil.createFixed("BusinessExecutor", threadPoolSize);
ownJobExecutor = ExecutorUtil.createCached("ownJobExecutor", 1);
timerExecutor = ExecutorUtil.createFixed("Timer", 1);
listeningExecutorService = MoreExecutors.listeningDecorator(businessExecutor);
@@ -2,6 +2,7 @@ package io.mycat.backend.mysql.nio.handler.query;
import java.util.concurrent.atomic.AtomicBoolean;
import io.mycat.MycatServer;
import io.mycat.server.NonBlockingSession;
/**
@@ -41,7 +42,7 @@ public abstract class OwnThreadDMLHandler extends BaseDMLHandler {
* 有可能会用到的参数
*/
protected final void startOwnThread(final Object... objects) {
session.getSource().getProcessor().getExecutor().execute(new Runnable() {
MycatServer.getInstance().getOwnJobExecutor().execute(new Runnable() {
@Override
public void run() {
if (terminate.get())
@@ -327,21 +327,6 @@ public class ServerConnection extends FrontendConnection {
}
/**
* 撤销执行中的语句
*
* @param sponsor
* 发起者为null表示是自己
*/
public void cancel(final FrontendConnection sponsor) {
processor.getExecutor().execute(new Runnable() {
@Override
public void run() {
session.cancel(sponsor);
}
});
}
@Override
public void close(String reason) {