apache / apache/dubbo

Dubbo升级Netty4后,异步调用场景存在参数窜包的问题

Open
#10,688 3 comments 0 reactions 0 assignees View on GitHub
type/discussion
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

问题发现在dubbo2.5.x,初步分析dubbo3应该同样存在。
问题场景:
消费方和提供方默认的通信SPI均切换到netty4,消费方侧reference配置async=true。在如下的代码场景:
Pojo a = new Pojo();
a.setName("zhangsan");
aysncService1.serve(a);
Future f1 = RpcContext.getContext().getFuture();

a.setName("lisi");
aysncService2.serve(a);
Future f2 = RpcContext.getContext().getFuture();

f1.get()+"--"+f2.get();

其中aysncService1和aysncService2两个服务引用均采用异步的配置,在netty4场景下,aysncService1.serve(a),传递给提供方的a对象,属性也编程lisi了,在netty3作为通信组件时,不存在该问题。

初步分析:由于netty4和netty3在客户端的线程模型上有较大的改动。netty3会先将数据序列化后交给nioworker,netty4中直接将对象打包到给nioworker的任务队列,在数据发送时才触发序列化。

解决思路:异步场景发送前对报文深拷贝后丢给任务队列,或者 将序列化前移到业务线程。

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.