-
Notifications
You must be signed in to change notification settings - Fork 26.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Dubbo-6567] fix consumer warning "safe guard client , should not be called ,must have a bug." #6959
[Dubbo-6567] fix consumer warning "safe guard client , should not be called ,must have a bug." #6959
Conversation
…must have a bug."
…tion should always be true
你好,请问我在不升级dubbo的情况下,有没有好的方式解决这个问题 |
好的方式只有改代码发一遍替换jar包 |
@wikiwikiwiki Hi, thanks for your contribution. Please merge the latest master branch to resolve confilcts. |
# Conflicts: # dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java # dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java
already resolved |
relation to #7737. |
Related with @7737 Please feel free to reopen if you have any question. |
@AlbumenJ 什么时候放出FIX这个BUG的新版本? |
另外顺便问一下,现在阿里官方是不是没有人维护DUBBO了,感觉解决问题的都是热心网友,官方不再参与了,是一个弃儿。 |
本月会发 2.7.12 版本 |
2.7.12版本已经发布,但是release log上并无该问题的修复说明。请问该问题已经修复了吗? |
|
这个英文有点水平... |
private volatile ExchangeClient client; | ||
private AtomicLong warningcount = new AtomicLong(0); | ||
|
||
public LazyConnectExchangeClient(URL url, ExchangeHandler requestHandler) { | ||
// lazy connect, need set send.reconnect = true, to avoid channel bad status. | ||
this.url = url.addParameter(SEND_RECONNECT_KEY, Boolean.TRUE.toString()); | ||
this.requestHandler = requestHandler; | ||
this.initialState = url.getParameter(LAZY_CONNECT_INITIAL_STATE_KEY, DEFAULT_LAZY_CONNECT_INITIAL_STATE); | ||
this.initialConnectState = url.getParameter(LAZY_CONNECT_INITIAL_STATE_KEY, DEFAULT_LAZY_CONNECT_INITIAL_STATE); | ||
if (url.hasParameter(LAZY_CLOSE_STATE_KEY)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.closeState = null; if (url.hasParameter(LAZY_CLOSE_STATE_KEY)) { this.closeState = Boolean.parseBoolean(url.getParameter(LAZY_CLOSE_STATE_KEY)); }
return closeState; | ||
} | ||
|
||
if (client == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return client == null ? false : client.isClosed();
是不是在3.0.*版本中依旧存在这个问题的?3.0.*中没有找到这次修复提交的代码T_T |
今天在
|
Try it with the latest version. |
2.7.8 DubboX中复现。。。想知道2.7.8dubboX直接升到2.7.18有什么改动和不兼容吗 |
dubbox 版本是基于 apache/dubbo 2.5.x 的版本,从 dubbox 升级到 dubbo 2.7 参考 dubbo 2.7 升级的文档 |
mark |
一定有bug |
issue #6567 里面提到了这个问题,刚好也碰到了,修复一下。
具体触发条件为:
这个问题的根源是LazyConnectExchangeClient在两种情况下被使用,这两种情况需要表现的行为不一样,但是代码一样导致。
这两种情况一个是consumer主动设置为延迟连接,一个是consumer和provider断开连接时进行防御式编程,如果在连接关闭后还有请求过来就用这个延迟初始化的client处理一下。
具体到上面的这个例子:
第一步consumer正常调用时,DubboProtocol里面referenceClientMap字段保存了consumer连接provider的ReferenceCountExchangeClient。
第二步关闭provider进程一直到provider注册url消失时,referenceClientMap字段里面的引用还在,但是ReferenceCountExchangeClient的replaceWithLazyClient方法被调用,内部的ExchangeClient换成了LazyConnectExchangeClient。
第三步provider进程重启,consumer再次调用时,会重新获取到这个已经关闭的ReferenceCountExchangeClient。判断代码为
而referenceCountExchangeClient.isClosed()会调用到LazyConnectExchangeClient的isClosed方法
此时还没有延迟初始化,会直接返回false,导致后续的调用都会使用这个client,每5000报告一次warning。
这个bug应该是在 #5532 这个pr被合并后触发,原本LazyConnectExchangeClient在没有client时isClosed()方法会返回true,会在上面例子第三步时给清理掉。而在没有client时,isClosed()方法返回false,应该是针对consumer主动设置为延迟连接的情况;而consumer和provider断开连接时建立的那个LazyConnectExchangeClient的isClosed()方法应该始终返回true。
具体修复方式为模仿replaceWithLazyClient方法里的方式,在场景不同时添加参数。
通过增加一个LAZY_CLOSE_STATE_KEY,强制设置isClosed方法修改的返回值,isClosed()方法内容改为