Skip to content
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

Fix remove tag issue for DubboProviderInterceptor in consumer side #1652

Conversation

rztao
Copy link
Contributor

@rztao rztao commented Oct 23, 2024

…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

  • Make sure there is a GitHub_issue related with this PR before you start working on it.
  • Make sure you have squashed your change to one single commit.
  • GitHub Actions works fine in this PR.

…t will cause previously traffic tag removed and the follow up invocation can not get traffic tag from thread local

Signed-off-by: rztao <[email protected]>
Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../interceptors/AlibabaDubboProviderInterceptor.java 50.00% 2 Missing ⚠️
...2/interceptors/ApacheDubboProviderInterceptor.java 50.00% 2 Missing ⚠️
...3/interceptors/ApacheDubboProviderInterceptor.java 50.00% 2 Missing ⚠️
Flag Coverage Δ Complexity Δ
unittests 44.21% <50.00%> (+<0.01%) 181.00 <0.00> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ Complexity Δ
.../interceptors/AlibabaDubboProviderInterceptor.java 65.00% <50.00%> (-1.67%) 0.00 <0.00> (ø)
...2/interceptors/ApacheDubboProviderInterceptor.java 67.56% <50.00%> (-2.13%) 0.00 <0.00> (ø)
...3/interceptors/ApacheDubboProviderInterceptor.java 68.42% <50.00%> (-2.17%) 0.00 <0.00> (ø)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants