RocketMQ4.3.X关于设置useEpollNativeSelector = true报错问题
程序员文章站
2022-05-17 16:09:23
前一阵子刚整理完RocketMQ4.3.x版本的相关配置的工作,接下来就来测试一下改变参数会带来什么好的结果 首先我就选中了useEpollNativeSelector 这个参数 默认这个参数是 false 这个参数的意思就是是否启用Epoll IO模型。Linux环境建议开启 然后我就打开了这个参 ......
前一阵子刚整理完rocketmq4.3.x版本的相关配置的工作,接下来就来测试一下改变参数会带来什么好的结果
首先我就选中了useepollnativeselector 这个参数
默认这个参数是 false
这个参数的意思就是是否启用epoll io模型。linux环境建议开启
然后我就打开了这个参数试试看看会不会生效
首先是namesrv 弄了一个配置文件指向启动
然后启动namesrv
sh bin/mqnamesrv -c conf/namesrv.conf
很不幸抛出了一个异常
java.lang.illegalstateexception: incompatible event loop type: io.netty.channel.nio.nioeventloop
at io.netty.channel.abstractchannel$abstractunsafe.register(abstractchannel.java:411)
at io.netty.channel.singlethreadeventloop.register(singlethreadeventloop.java:72)
at io.netty.channel.singlethreadeventloop.register(singlethreadeventloop.java:60)
at io.netty.channel.multithreadeventloopgroup.register(multithreadeventloopgroup.java:64)
at io.netty.bootstrap.abstractbootstrap.initandregister(abstractbootstrap.java:320)
at io.netty.bootstrap.abstractbootstrap.dobind(abstractbootstrap.java:271)
at io.netty.bootstrap.abstractbootstrap.bind(abstractbootstrap.java:235)
at org.apache.rocketmq.remoting.netty.nettyremotingserver.start(nettyremotingserver.java:212)
at org.apache.rocketmq.namesrv.namesrvcontroller.start(namesrvcontroller.java:156)
at org.apache.rocketmq.namesrv.namesrvstartup.start(namesrvstartup.java:154)
at org.apache.rocketmq.namesrv.namesrvstartup.main0(namesrvstartup.java:58)
at org.apache.rocketmq.namesrv.namesrvstartup.main(namesrvstartup.java:51)
通过抛出的异常追查一下源码
发现在执行构造函数的时候初始化的是下面代码 90-143行
public nettyremotingserver(final nettyserverconfig nettyserverconfig, final channeleventlistener channeleventlistener) { super(nettyserverconfig.getserveronewaysemaphorevalue(), nettyserverconfig.getserverasyncsemaphorevalue()); this.serverbootstrap = new serverbootstrap(); this.nettyserverconfig = nettyserverconfig; this.channeleventlistener = channeleventlistener; int publicthreadnums = nettyserverconfig.getservercallbackexecutorthreads(); if (publicthreadnums <= 0) { publicthreadnums = 4; } this.publicexecutor = executors.newfixedthreadpool(publicthreadnums, new threadfactory() { private atomicinteger threadindex = new atomicinteger(0); @override public thread newthread(runnable r) { return new thread(r, "nettyserverpublicexecutor_" + this.threadindex.incrementandget()); } }); this.eventloopgroupboss = new nioeventloopgroup(1, new threadfactory() { private atomicinteger threadindex = new atomicinteger(0); @override public thread newthread(runnable r) { return new thread(r, string.format("nettyboss_%d", this.threadindex.incrementandget())); } }); if (useepoll()) { this.eventloopgroupselector = new epolleventloopgroup(nettyserverconfig.getserverselectorthreads(), new threadfactory() { private atomicinteger threadindex = new atomicinteger(0); private int threadtotal = nettyserverconfig.getserverselectorthreads(); @override public thread newthread(runnable r) { return new thread(r, string.format("nettyserverepollselector_%d_%d", threadtotal, this.threadindex.incrementandget())); } }); } else { this.eventloopgroupselector = new nioeventloopgroup(nettyserverconfig.getserverselectorthreads(), new threadfactory() { private atomicinteger threadindex = new atomicinteger(0); private int threadtotal = nettyserverconfig.getserverselectorthreads(); @override public thread newthread(runnable r) { return new thread(r, string.format("nettyservernioselector_%d_%d", threadtotal, this.threadindex.incrementandget())); } }); } loadsslcontext(); }
也就是说这里接收链接的线程池 eventloopgroupboss 永远都是 nioeventloopgroup 如果设置了useepollnativeselector=true就会初始化epolleventloopgroup这个类处理请求
这样就会造成两种线程模型的不兼容状态
导致出现异常 java.lang.illegalstateexception: incompatible event loop type: io.netty.channel.nio.nioeventloop
按常理说阿里的人不会出现这样的低级错误啊
回头又看了看github的bug列表果然有人提这个问题bug还是开启状态
????为什么?
难道是我使用配置有问题吗?还是哪里理解有误那?知道的网友可以告诉我啊!!!!
上一篇: [20190130]删除tab$记录的恢复2.txt
下一篇: 一举两得