You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/08/26 06:42:32 UTC

[GitHub] [dubbo] zrlw opened a new issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

zrlw opened a new issue #8602:
URL: https://github.com/apache/dubbo/issues/8602


   ### Environment
   
   * Dubbo version:  2.7.13
   尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象,而是后续dubbo调用使用的rpcContext里面的consumerURL。
   
   ### Steps to reproduce this issue
   1. 修改一下MethodConfigCallbackTest.java单元测试类:
   ```
   public class MethodConfigCallbackTest {
       ...
       @DubboReference(check = false, async = true,
               parameters = { "refId", "ref-1" },
               methods = {@Method(name = "sayHello",
                       oninvoke = "methodCallback.oninvoke",
                       onreturn = "methodCallback.onreturn",
                       onthrow = "methodCallback.onthrow")})
       private HelloService helloServiceMethodCallBack;
   
       @DubboReference(check = false, async = true,
               parameters = { "refId", "ref-2" },
               methods = {@Method(name = "sayHello",
                       oninvoke = "methodCallback.oninvoke",
                       onreturn = "methodCallback.onreturn",
                       onthrow = "methodCallback.onthrow")})
       private HelloService helloServiceMethodCallBack2;
   
       @Test
       public void testMethodAnnotationCallBack() {
           new Thread(() -> {
               helloServiceMethodCallBack.sayHello("dubbo");
               helloServiceMethodCallBack2.sayHello("dubbo(2)");
           }).start();
           try {
               // wait for async callback finished
               Thread.sleep(3000);
           } catch (InterruptedException e) {
           }
           MethodCallback notify = (MethodCallback) context.getBean("methodCallback");
           Assertions.assertEquals("dubbo invoke success,dubbo invoke success(2)", notify.getOnInvoke());
           Assertions.assertEquals("dubbo return success,dubbo return success(2)", notify.getOnReturn());
       }
       ...
   ```
   2. 修改一下MethodCallbackImpl.java测试类:
   ```
   public class MethodCallbackImpl implements MethodCallback {
       private String onInvoke1;
       private String onReturn1;
       private String onThrow1;
       
       private String onInvoke2;
       private String onReturn2;
       private String onThrow2;
   
       @Autowired
       private Environment environment;
   
       @Autowired
       private ApplicationContext context;
   
       private AtomicInteger cnt1 = new AtomicInteger();
       private AtomicInteger cnt2 = new AtomicInteger();
       
       @PostConstruct
       protected void init() {
           checkInjection();
       }
   
       @Transactional(rollbackFor = Exception.class)
       @Override
       public void oninvoke(String request) {
           try {
               checkInjection();
               checkTranscation();
               switch (RpcContext.getContext().getConsumerUrl().getParameter("refId")) {
               case "ref-1":
                   this.onInvoke1 = "dubbo invoke success";
                   break;
               case "ref-2":
                   this.onInvoke2 = "dubbo invoke success(2)";
                   break;
               }
           } catch (Exception e) {
               switch (RpcContext.getContext().getConsumerUrl().getParameter("refId")) {
               case "ref-1":
                   this.onInvoke1 = e.toString();
                   break;
               case "ref-2":
                   this.onInvoke2 = e.toString();
                   break;
               }
               throw e;
           }
       }
   
       @Override
       @Transactional(rollbackFor = Exception.class)
       public void onreturn(String response, String request) {
           try {
               checkInjection();
               checkTranscation();
               switch (RpcContext.getContext().getConsumerUrl().getParameter("refId")) {
               case "ref-1":
                   this.onReturn1 = "dubbo return success";
                   if (cnt1.incrementAndGet() == 2) {
                       this.onReturn1 = "double 1!";
                   }
                   break;
               case "ref-2":
                   this.onReturn2 = "dubbo return success(2)";
                   if (cnt2.incrementAndGet() == 2) {
                       this.onReturn2 = "double 2!";
                   }
                   break;
               }
           } catch (Exception e) {
               switch (RpcContext.getContext().getConsumerUrl().getParameter("refId")) {
               case "ref-1":
                   this.onReturn1 = e.toString();
                   break;
               case "ref-2":
                   this.onReturn2 = e.toString();
                   break;
               }
               throw e;
           }
       }
   
       @Override
       @Transactional(rollbackFor = Exception.class)
       public void onthrow(Throwable ex, String request) {
           try {
               checkInjection();
               checkTranscation();
               switch (RpcContext.getContext().getConsumerUrl().getParameter("refId")) {
               case "ref-1":
                   this.onThrow1 = "dubbo throw exception";
                   break;
               case "ref-2":
                   this.onThrow2 = "dubbo throw exception(2)";
                   break;
               }
           } catch (Exception e) {
               switch (RpcContext.getContext().getConsumerUrl().getParameter("refId")) {
               case "ref-1":
                   this.onThrow1 = e.toString();
                   break;
               case "ref-2":
                   this.onThrow2 = e.toString();
                   break;
               }
               throw e;
           }
       }
   
       public String getOnInvoke() {
           return this.onInvoke1 + ',' + this.onInvoke2;
       }
   
       public String getOnReturn() {
           return this.onReturn1 + ',' + this.onReturn2;
       }
   
       public String getOnThrow() {
           return this.onThrow1 + ',' + this.onThrow2;
       }
   ...
   ```
   
   ### Expected Result
   
   单元测试通过。
   
   ### Actual Result
   多跑几次,大概率是```Assertions.assertEquals("dubbo return success,dubbo return success(2)", notify.getOnReturn());```断言失败,onreturn方法的rpcContext里面的consumerUrl里面的refId大概率都是ref-2
   
   ### 原因
   ```helloServiceMethodCallBack.sayHello("dubbo");```这个异步回调onReturn尚未开始时,InvokerInvocationHandler的invoke方法处理```helloServiceMethodCallBack2.sayHello("dubbo(2)");```第二次dubbo接口调用时(同一个线程)就直接复用了前者的rpcContext,将其中的consumerURL进行了重置:```RpcContext.setRpcContext(invoker.getUrl());```


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] chickenlj commented on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
chickenlj commented on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-998613793


   ```java
   new Thread(() -> {
       helloServiceMethodCallBack.sayHello("dubbo");
       helloServiceMethodCallBack2.sayHello("dubbo(2)");
   }).start();
   ```
   
   如果按照这个调用模型,理论上来说 `helloServiceMethodCallBack2.sayHello("dubbo(2)");` 应该是用的一个全新的 RpcContext 实例,因为第一次 `helloServiceMethodCallBack.sayHello("dubbo");` 调用后,Dubbo会通过 ConsumerContextFilter 清空之前生成的 RpcContext 实例。
   
   如下图 RpcContext.setRpcContext() 已经是一个全新的 RpcContext 实例
   
   ![image](https://user-images.githubusercontent.com/18097545/146905465-6b6414fe-9d20-4505-95ca-7ce0a11c3be1.png)
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] zrlw commented on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
zrlw commented on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-906271927


   RpcContext属性太多了,深度克隆太麻烦了,效率也很差。
   那么每个异步的Dubbo Reference可否单独创建一个工作线程呢?


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] zrlw commented on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
zrlw commented on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-910157545


   先抛块砖, PR #8650 利用callback线程的thread local做了consumer url的恢复。
   这个PR能解决当前这个问题,希望能看到社区的整体解决方案。


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] zrlw commented on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
zrlw commented on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-906340548


   用了一个投机的应对办法,每次异步dubbo调用单独创建一个线程发起调用,调用完了这个线程就完成使命直接结束生命,虽然不优雅,但好歹不再乱搞了


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] chickenlj edited a comment on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
chickenlj edited a comment on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-998776946


   I will try to add RpcContext copy on AsyncRpcResult construction anyways. Functionality always comes first to performance, and also, I will try to distinguish synchronous calls from asynchronous ones.


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] chickenlj closed issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
chickenlj closed issue #8602:
URL: https://github.com/apache/dubbo/issues/8602


   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] chickenlj commented on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
chickenlj commented on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-996362302


   I think it's not only with consumer URL, other properties in RpcContext could have the same problem. Will a deep copy of RpcContext solve the problem?


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] chickenlj commented on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
chickenlj commented on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-998776946


   I will try to add RpcContext copy on AsyncRpcResult construction anyways.


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] zrlw commented on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
zrlw commented on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-915113040


   期待3.0多实例框架早日推广到2.7.x


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] chickenlj commented on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
chickenlj commented on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-998619384


   所以最好还是使用不同的服务名来验证,排除是相同接口名声明两次带来的影响。


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] CrazyHZM commented on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
CrazyHZM commented on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-986161060


   @zrlw 
   Multi-instance will not be supported to version 2.7.x, we recommend upgrading to version 3.0.
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] zrlw edited a comment on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
zrlw edited a comment on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-906166600


   可否改一下asyncRpcResult的构造方法,clone一份RpcContext.getContext()存入storedContext?


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] chickenlj commented on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
chickenlj commented on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-1070369301


   This issue is supposed to have been fixed in the latest 3.x branch, please verify.


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] zrlw commented on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
zrlw commented on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-906145874


   dubbo处理invoke请求的工作线程里的rpcContext只有一份,当处理第二次invoke时,直接复用上一次dubbo尚未完成回调的rpcContext,会将上次异步调用时保存到asyncRpcResult里面的storedContext的consumerURL属性进行重置。
   相关代码截图如下:
   ![dubbo事件通知缺陷](https://user-images.githubusercontent.com/40652892/130915524-b30c408f-f904-4278-a40c-6772f76ed183.png)
   
   PS:
   本issue源于尝试解决 #8567 
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] zrlw commented on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
zrlw commented on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-906438595


   测试项目代码:https://github.com/zrlw/dubbo/tree/test-asyncRpc
   单元测试类:MethodConfigCallbackTest.java
   如果想看一下rpcContext被复用的效果,修改一下上面的MethodConfigCallbackTest测试类,把里面的两个new Thread去掉,然后测试两下应该就能看到了。


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] chickenlj commented on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
chickenlj commented on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-996382063


   For performance consideration, we may need to distinguish between synchronous and asynchronous calls.


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] zrlw commented on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
zrlw commented on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-906166600


   可否改一下asyncRpcResul的构造方法,clone一份RpcContext.getContext()存入storedContext?


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] zrlw edited a comment on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
zrlw edited a comment on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-906145874


   dubbo处理invoke请求的工作线程里的rpcContext只有一份,当处理第二次invoke时,直接复用上一次dubbo尚未完成回调的rpcContext,会将上次异步调用时保存到asyncRpcResult里面的storedContext的consumerURL属性进行重置。
   相关代码截图如下:
   ![dubbo事件通知缺陷](https://user-images.githubusercontent.com/40652892/130915524-b30c408f-f904-4278-a40c-6772f76ed183.png)
   ![dubbo事件通知缺陷-调用栈](https://user-images.githubusercontent.com/40652892/130918288-7278b450-bbff-4d9d-b1d4-b9e193bb6313.png)
   
   PS:
   本issue源于尝试解决 #8567 
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] zrlw edited a comment on issue #8602: [2.7.13] 尚未完成异步回调的rpcContext被直接复用于后续dubbo调用处理,导致异步回调方法rpcContext里面的consumerURL并不是asyncRpcResult保存的对象

Posted by GitBox <gi...@apache.org>.
zrlw edited a comment on issue #8602:
URL: https://github.com/apache/dubbo/issues/8602#issuecomment-906438595


   测试项目代码:https://github.com/zrlw/dubbo/tree/test-asyncRpc
   单元测试类:MethodConfigCallbackTest.java
   如果想看一下rpcContext被复用的效果,修改一下上面的MethodConfigCallbackTest测试类,把里面的两个new Thread合并为一个new Thread,然后测试两下应该就能看到了。


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org