zrlw edited a comment on issue #8805:
URL: https://github.com/apache/dubbo/issues/8805#issuecomment-919741212
前面还有
```
2021-09-15T03:06:39.5666317Z [15/09/21 03:06:36:036 UTC] DubboShutdownHook
WARN dubbo.ReferenceCountExchangeClient: [DUBBO] 192.168.16.2:20880
org.apache.dubbo.samples.annotation.api.HelloService:1.0.0_annotation safe
guard client , should not be called ,must have a bug., dubbo version:
3.0.3-SNAPSHOT, current host: 192.168.16.3
```
搜了一下safe guard client , should not be called ,must have a
bug的代码有两处,一处是LazyConnectExchangeClient的warning
私有方法,由LazyConnectExchangeClient的request方法调起(感觉不应该是这里):
warning方法注解说warn once every 5000 invocations,但是第一次调用就会warning,因为0模多少都还是0:
```
if (warningcount.get() % warning_period == 0) {
logger.warn(url.getAddress() + " " + url.getServiceKey() + "
safe guard client , should not be called ,must have a bug.");
}
warningcount.incrementAndGet();
```
另一处是ReferenceCountExchangeClient的replaceWithLazyClient,这个代码由close方法触发,这一处可能是日志告警的位置。
```
if (disconnectCount.getAndIncrement() % maxDisconnectCount == 0) {
logger.warn(url.getAddress() + " " + url.getServiceKey() + "
safe guard client , should not be called ,must have a bug.");
}
```
此处和LazyConnectExchangeClient的warning方法一样,也存在第一次就warning的问题;此外replaceWithLazyClient方法的lazyUrl赋值语句靠前了,挪到后面可能合适一点:
```
if (!(client instanceof LazyConnectExchangeClient) ||
client.isClosed()) {
URL lazyUrl = url.addParameter(...); <=== 搁到这里就好
client = new LazyConnectExchangeClient(lazyUrl,
client.getExchangeHandler());
}
```
--
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]