zrlw edited a comment on pull request #8872:
URL: https://github.com/apache/dubbo/pull/8872#issuecomment-925517506


   1. 
无论客户端app里面有多少invoker,dubbo客户端与每个服务端之间只维持1条长连接,比如你有10个服务端在注册中心登记,那么每台引用这些服务的客户端与各服务端之间的总连接数就是10(前提:客户端和各个服务端之间的网络都是通的),无论是否发生invoker调用,这些连接会一直保持直到客户端结束运行或者服务端退出,所以你的连接数非常多甚至出现oom应该是其他原因引起的;
   2. 
你改了HeaderExchangeChannel.java的close方法,将当前LazyConnectExchangeClient的closed状态设为true,后面执行replaceWithLazyClient替换ReferenceCountExchangeClient内的ExchangeClient操作时,就会因为client.isClosed()条件为真而重新去创建一个LazyConnectExchangeClient,新建LazyConnectExchangeClient内的ExchangeClient为null,这样当测试方法执行断言helloServiceInvoker.isAvailable()为假时就会失败:原因在于此处isAvailable是DubboInvoker的isAvailable,调用LazyConnectExchangeClient的isConnected()因为ExchangeClient为null,所以返回LazyConnectExchangeClient的initialState,而这个initialState未做配置时默认是true,所以helloServiceInvoker.isAvailable()返回true。
   你修改的代码暴露了两处bug:
   
第1处是HeaderExchangeChannel.java的close()方法应该将closed状态设置为true,因为跟踪发现关闭LazyConnectExchangeClient并不走close(timeout)方法,而是直接走close()方法,close()把channel连接关闭之后,应该将关闭状态设置为true;
   
第2处是LazyConnectExchangeClient.close方法没有将内部的ExchangeClient对象置为null,下次再使用已经close的LazyConnectExchangeClient时,就会复用已关闭channel的ExchangeClient导致invoker操作异常。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to