Fix remove tag issue for DubboProviderInterceptor in consumer side #1652
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…t will cause previously traffic tag removed and the follow up invocation can not get traffic tag from thread local
What type of PR is this?
Bug
What this PR does / why we need it?
DubboProviderInterceptor will be invoked in consumer side(MonitorFilter is enable in both provider and consumer side in default), it will cause previous traffic tag removed and the follow up invocation can not get traffic tag from ThreadLocal when the traffic tag used for traffic route later if remove traffic tag unconditionally.
Here is stack for real case and the route later which use traffic tag does not work because the traffic tag is removed by DubboProviderInterceptor method previously executed.
ts=2024-10-22 17:20:38.674;thread_name=rpc-core-13;id=754;is_daemon=false;priority=5;TCCL=org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader@3a1eb893 @com.huaweicloud.sermant.core.utils.tag.TrafficUtils.removeTrafficTag() at com.huaweicloud.sermant.tag.transmission.dubbov3.interceptors.ApacheDubboProviderInterceptor.doAfter(ApacheDubboProviderInterceptor.java:86) at com.huaweicloud.sermant.tag.transmission.interceptors.AbstractServerInterceptor.after(AbstractServerInterceptor.java:58) at com.huaweicloud.sermant.core.plugin.agent.template.BaseAdviseHandler.handleMethodExit(BaseAdviseHandler.java:169) at com.huaweicloud.sermant.core.plugin.agent.template.BaseAdviseHandler.handleMethodExit(BaseAdviseHandler.java:130) at com.huaweicloud.sermant.core.plugin.agent.template.DefaultAdviser.onMethodExit(DefaultAdviser.java:63) at com.huaweicloud.sermant.core.plugin.agent.adviser.AdviserScheduler.onMethodExit(AdviserScheduler.java:96) at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:91) at org.apache.dubbo.rpc.protocol.FilterNode.invoke(FilterNode.java:61) at org.apache.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:52) at org.apache.dubbo.rpc.protocol.FilterNode.invoke(FilterNode.java:61) at org.apache.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:69) at org.apache.dubbo.rpc.protocol.FilterNode.invoke(FilterNode.java:61) 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:265) 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:93) at org.apache.dubbo.registry.client.migration.MigrationInvoker.invoke(MigrationInvoker.java:169) at org.apache.dubbo.rpc.cluster.support.registry.ZoneAwareClusterInvoker.doInvoke(ZoneAwareClusterInvoker.java:105) at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:265) 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.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:96) at org.apache.dubbo.common.bytecode.proxy4.queryPage(proxy4.java:-1) ...
Which issue(s) this PR fixes?
It will not remove traffic tag if DubboProviderInterceptor in consumer side in after method.
#1654
Does this PR introduce a user-facing change?
No
Checklist