spring-cloud-alibaba When I test the Dubbo call,java.lang.IllegalStateException: safe guard client , should not be called ,must have a bug.

bq3bfh9z  于 4个月前  发布在  Spring
关注(0)|答案(7)|浏览(115)

When I test the Dubbo call, the background suddenly prints out this. The call function can be provided normally. I don't know where my problem is

当我测试dubbo调用的时候,后台突然打印出这个,调用功能能正常提供,我不知道这是我哪里的问题

z2acfund

z2acfund1#

What's the error message that your application received?

h7wcgrx3

h7wcgrx32#

2020-04-21 19:43:37.022 - WARN 27390 --- [DubboServerHandler-172.18.30.18:20001-thread-10] o.a.d.r.p.d.LazyConnectExchangeClient [lineno:138]: safe guard client , should not be called ,must have a bug.

java.lang.IllegalStateException: safe guard client , should not be called ,must have a bug.
at org.apache.dubbo.rpc.protocol.dubbo.LazyConnectExchangeClient.warning(LazyConnectExchangeClient.java:138) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.protocol.dubbo.LazyConnectExchangeClient.request(LazyConnectExchangeClient.java:127) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.protocol.dubbo.ReferenceCountExchangeClient.request(ReferenceCountExchangeClient.java:91) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:100) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:162) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.protocol.AsyncToSyncInvoker.invoke(AsyncToSyncInvoker.java:52) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:78) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:89) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:51) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:55) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:82) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:259) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.cluster.interceptor.ClusterInterceptor.intercept(ClusterInterceptor.java:47) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.cluster.support.wrapper.AbstractCluster$InterceptorInvokerNode.invoke(AbstractCluster.java:92) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:82) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:74) [dubbo-2.7.6.jar!/:2.7.6]
at org.apache.dubbo.common.bytecode.proxy5.getWebsiteSolrRes(proxy5.java) [dubbo-2.7.6.jar!/:2.7.6]

ddrv8njm

ddrv8njm3#

I have the same problem.

when the provider is restarted, the consumer prints it every 5k calls.

[2020-07-27 16:04:56,245] WARN  [DubboServerHandler-172.16.2.19:21887-thread-199]          org.apache.dubbo.rpc.protocol.dubbo.LazyConnectExchangeClient:86  - [] [] safe guard client , should not be called ,must have a bug.
java.lang.IllegalStateException: safe guard client , should not be called ,must have a bug.
	at org.apache.dubbo.rpc.protocol.dubbo.LazyConnectExchangeClient.warning(LazyConnectExchangeClient.java:138)
	at org.apache.dubbo.rpc.protocol.dubbo.LazyConnectExchangeClient.request(LazyConnectExchangeClient.java:127)
	at org.apache.dubbo.rpc.protocol.dubbo.ReferenceCountExchangeClient.request(ReferenceCountExchangeClient.java:91)
	at org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:105)
	at org.apache.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:163)
	at org.apache.dubbo.rpc.protocol.AsyncToSyncInvoker.invoke(AsyncToSyncInvoker.java:52)

I saw that when the server shutdown , the client will become LazyConnectExchangeClient https://github.com/apache/dubbo/blob/4aaaea43ae75bee99837183c5be37ca2cb942741/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java#L182-L199

how can I fix it and avoid this print out ?

ldfqzlk8

ldfqzlk84#

Any response for this issue?

h22fl7wq

h22fl7wq5#

When I test the Dubbo call, the background suddenly prints out this. The call function can be provided normally. I don't know where my problem is

当我测试dubbo调用的时候,后台突然打印出这个,调用功能能正常提供,我不知道这是我哪里的问题

我也遇到这个问题,调用是正常的。用2.7以下的老版本不会有问题

5jdjgkvh

5jdjgkvh6#

What's the error message that your application received?

我也遇到了这个问题,我使用的是2.7.8的版本,虽然可以正常调用,但是强迫症的我,看到这个报错真是太扎心了,这到底是什么问题造成的啊?

org.apache.dubbo.rpc.protocol.dubbo.LazyConnectExchangeClient : safe guard client , should not be called ,must have a bug.

java.lang.IllegalStateException: safe guard client , should not be called ,must have a bug.
	at org.apache.dubbo.rpc.protocol.dubbo.LazyConnectExchangeClient.warning(LazyConnectExchangeClient.java:138)
	at org.apache.dubbo.rpc.protocol.dubbo.LazyConnectExchangeClient.request(LazyConnectExchangeClient.java:127)
	at org.apache.dubbo.rpc.protocol.dubbo.ReferenceCountExchangeClient.request(ReferenceCountExchangeClient.java:91)
	at org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:105)
	at org.apache.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:163)
	at org.apache.dubbo.rpc.protocol.AsyncToSyncInvoker.invoke(AsyncToSyncInvoker.java:52)
	at org.apache.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:78)
	at brave.dubbo.TracingFilter.invoke(TracingFilter.java:128)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:83)
	at org.apache.dubbo.rpc.filter.GenericImplFilter.invoke(GenericImplFilter.java:125)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:83)
	at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:89)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:83)
	at org.apache.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:51)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:83)
	at com.ecolovo.cloud.dubbo.filter.ConsumerFilter.invoke(ConsumerFilter.java:31)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:83)
	at org.apache.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:69)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:83)
	at org.apache.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56)
	at org.apache.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:82)
	at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:260)
	at org.apache.dubbo.rpc.cluster.interceptor.ClusterInterceptor.intercept(ClusterInterceptor.java:47)
	at org.apache.dubbo.rpc.cluster.support.wrapper.AbstractCluster$InterceptorInvokerNode.invoke(AbstractCluster.java:92)
	at org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:88)
	at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:74)
	at org.apache.dubbo.common.bytecode.proxy2.$invoke(proxy2.java)
	at com.alibaba.cloud.dubbo.service.DubboMetadataServiceInvocationHandler.invoke(DubboMetadataServiceInvocationHandler.java:48)
	at com.sun.proxy.$Proxy212.getExportedURLs(Unknown Source)
	at com.alibaba.cloud.dubbo.registry.DubboCloudRegistry.getExportedURLs(DubboCloudRegistry.java:424)
	at com.alibaba.cloud.dubbo.registry.DubboCloudRegistry.getTemplateExportedURLs(DubboCloudRegistry.java:324)
	at com.alibaba.cloud.dubbo.registry.DubboCloudRegistry.lambda$cloneExportedURLs$6(DubboCloudRegistry.java:288)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at com.alibaba.cloud.dubbo.registry.DubboCloudRegistry.cloneExportedURLs(DubboCloudRegistry.java:284)
	at com.alibaba.cloud.dubbo.registry.DubboCloudRegistry.getExportedURLs(DubboCloudRegistry.java:265)
	at com.alibaba.cloud.dubbo.registry.DubboCloudRegistry.subscribeURLs(DubboCloudRegistry.java:240)
	at com.alibaba.cloud.dubbo.registry.DubboCloudRegistry.subscribeURLs(DubboCloudRegistry.java:227)
	at com.alibaba.cloud.dubbo.registry.DubboCloudRegistry.lambda$subscribeURLs$2(DubboCloudRegistry.java:206)
	at java.lang.Iterable.forEach(Iterable.java:75)
	at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1082)
	at com.alibaba.cloud.dubbo.registry.DubboCloudRegistry.subscribeURLs(DubboCloudRegistry.java:204)
	at com.alibaba.cloud.dubbo.registry.DubboCloudRegistry.lambda$subscribeURLs$0(DubboCloudRegistry.java:194)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361)
	at com.alibaba.cloud.dubbo.autoconfigure.DubboServiceDiscoveryAutoConfiguration.dispatchServiceInstancesChangedEvent(DubboServiceDiscoveryAutoConfiguration.java:175)
	at com.alibaba.cloud.dubbo.autoconfigure.DubboServiceDiscoveryAutoConfiguration.access$200(DubboServiceDiscoveryAutoConfiguration.java:108)
	at com.alibaba.cloud.dubbo.autoconfigure.DubboServiceDiscoveryAutoConfiguration$NacosConfiguration.lambda$subscribeEventListener$1(DubboServiceDiscoveryAutoConfiguration.java:557)
	at com.alibaba.nacos.client.naming.core.EventDispatcher$Notifier.run(EventDispatcher.java:177)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
rjee0c15

rjee0c157#

看源码可能原因是,业务代码中出现错误导致调用了close方法,dubbo框架中做了处理,做了一个标记,标识这个被业务关闭的连接为幽灵客户端,每5000次告警一次,具体可能需要排查哪里出错导致调用了close方法。
源码如下:

//幽灵client,
private LazyConnectExchangeClient replaceWithLazyClient(){
//这个操作只为了防止程序bug错误关闭client做的防御措施,初始client必须为false状态
URL lazyUrl = url.addParameter(Constants.LAZY_CONNECT_INITIAL_STATE_KEY, Boolean.FALSE)
.addParameter(Constants.RECONNECT_KEY, Boolean.FALSE)
.addParameter(Constants.SEND_RECONNECT_KEY, Boolean.TRUE.toString())
.addParameter("warning", Boolean.TRUE.toString())
.addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true)
.addParameter("_client_memo", "referencecounthandler.replacewithlazyclient");

String key = url.getAddress();
    //最差情况下只有一个幽灵连接
    LazyConnectExchangeClient gclient = ghostClientMap.get(key);
    if (gclient == null || gclient.isClosed()){
        gclient = new LazyConnectExchangeClient(lazyUrl, client.getExchangeHandler());
        ghostClientMap.put(key, gclient);
    }
    return gclient;
}

相关问题