Caused by: java.util.concurrent.RejectedExecutionException: Thread pool is EXHAUSTED! Thread Name:

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhaoxb006/article/details/79146235

异常引发的问题:

2018-01-23 00:00:00,060 [New I/O worker #3] WARN  alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport (AbortPolicyWithReport.java:52) -  [DUBBO] Thread pool is EXHAUSTED! Thread Name: DubboServerHandler-172.16.1.22:20013, Pool Size: 200 (active: 200, core: 200, max: 200, largest: 200), Task: 418456 (completed: 418256), Executor status:(isShutdown:false, isTerminated:false, isTerminating:false), in dubbo://172.16.1.22:20013!, dubbo version: 2.5.3, current host: 127.0.0.1
2018-01-23 00:00:00,062 [New I/O worker #3] WARN  alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport (AbortPolicyWithReport.java:52) -  [DUBBO] Thread pool is EXHAUSTED! Thread Name: DubboServerHandler-172.16.1.22:20013, Pool Size: 200 (active: 200, core: 200, max: 200, largest: 200), Task: 418456 (completed: 418256), Executor status:(isShutdown:false, isTerminated:false, isTerminating:false), in dubbo://172.16.1.22:20013!, dubbo version: 2.5.3, current host: 127.0.0.1
2018-01-23 00:00:00,062 [New I/O worker #3] WARN  alibaba.dubbo.remoting.transport.netty.NettyHelper$DubboLogger (NettyHelper.java:90) -  [DUBBO] An exception was thrown by a user handler while handling an exception event ([id: 0x4bd2a965, /172.16.1.22:51148 => /172.16.1.22:20013] EXCEPTION: com.alibaba.dubbo.remoting.ExecutionException: class com.alibaba.dubbo.remoting.transport.dispatcher.all.AllChannelHandler error when process received event .), dubbo version: 2.5.3, current host: 127.0.0.1
com.alibaba.dubbo.remoting.ExecutionException: class com.alibaba.dubbo.remoting.transport.dispatcher.all.AllChannelHandler error when process caught event .
	at com.alibaba.dubbo.remoting.transport.dispatcher.all.AllChannelHandler.caught(AllChannelHandler.java:67)
	at com.alibaba.dubbo.remoting.transport.AbstractChannelHandlerDelegate.caught(AbstractChannelHandlerDelegate.java:44)
	at com.alibaba.dubbo.remoting.transport.AbstractChannelHandlerDelegate.caught(AbstractChannelHandlerDelegate.java:44)
	at com.alibaba.dubbo.remoting.transport.AbstractPeer.caught(AbstractPeer.java:127)
	at com.alibaba.dubbo.remoting.transport.netty.NettyHandler.exceptionCaught(NettyHandler.java:112)
	at com.alibaba.dubbo.remoting.transport.netty.NettyCodecAdapter$InternalDecoder.exceptionCaught(NettyCodecAdapter.java:165)
	at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:525)
	at org.jboss.netty.channel.AbstractChannelSink.exceptionCaught(AbstractChannelSink.java:48)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
	at com.alibaba.dubbo.remoting.transport.netty.NettyCodecAdapter$InternalDecoder.messageReceived(NettyCodecAdapter.java:148)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
	at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
	at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:109)
	at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:312)
	at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:90)
	at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.RejectedExecutionException: Thread pool is EXHAUSTED! Thread Name: DubboServerHandler-172.16.1.22:20013, Pool Size: 200 (active: 200, core: 200, max: 200, largest: 200), Task: 418456 (completed: 418256), Executor status:(isShutdown:false, isTerminated:false, isTerminating:false), in dubbo://172.16.1.22:20013!
	at com.alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport.rejectedExecution(AbortPolicyWithReport.java:53)
	at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:821)
	at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1372)
	at com.alibaba.dubbo.remoting.transport.dispatcher.all.AllChannelHandler.caught(AllChannelHandler.java:65)
	... 19 more


线程模型

  如果事件处理的逻辑能迅速完成,并且不会发起新的 IO 请求,⽐如只是在内存中记个标识,则直接在 IO 线程上处理更快,因为减少了线程池调度。
  但如果事件处理逻辑较慢,或者需要发起新的 IO 请求,⽐如需要查询数据库,则必须派发到线程池,否则 IO 线程阻塞,将导致不能接收其它请求。
  如果⽤ IO 线程处理事件,⼜在事件处理过程中发起新的 IO 请求,⽐如在连接事件中发起登录请求,会报“可能引发死锁”异常,但不会真死锁。

 

因此,需要通过不同的派发策略和不同的线程池配置的组合来应对不同的场景:


<dubbo:protocol name="dubbo" dispatcher="all" threadpool="fixed" threads="100" />

Dispatcher
  all  所有消息都派发到线程池,包括请求,响应,连接事件,断开事件,⼼跳等。
  direct 所有消息都不派发到线程池,全部在 IO 线程上直接执⾏。
  message 只有请求响应消息派发到线程池,其它连接断开事件,⼼跳等消息,直接在 IO 线程上执⾏。
  execution 只请求消息派发到线程池,不含响应,响应和其它连接断开事件,⼼跳等消息,直接在 IO 线程上执⾏。
  connection 在 IO 线程上,将连接断开事件放⼊队列,有序逐个执⾏,其它消息派发到线程池。
ThreadPool (dubbo通过配置threadpool来配置线程池的类型:)
  fixed 固定⼤⼩线程池,启动时建⽴线程,不关闭,⼀直持有。(缺省)
  cached 缓存线程池,空闲⼀分钟⾃动删除,需要时重建。
  limited 可伸缩线程池,但池中的线程数只会增⻓不会收缩。只增⻓不收缩的⽬的是为了避免收缩时突然来了⼤流量引起的性能问题。

timeout="5000":设置远程调用服务的超时时间为5000毫秒
threadpool="fixed":线程模型为固定大小的线程池,启动时建立线程,不关闭,一直持有
threads="500":线程数为500
accepts="1000":限制服务器端的接受的连接的最大值为1000



http://www.acgist.com/article/348.html

http://www.osbaike.net/article-show-id-312932.html

http://blog.csdn.net/lsm135/article/details/77712130

猜你喜欢

转载自blog.csdn.net/zhaoxb006/article/details/79146235
今日推荐