-
Notifications
You must be signed in to change notification settings - Fork 720
Description
Describe the Bug
I have three dubbo project, to make it simple, their names are A, B and C. A is a consumer, B is both a provider and a consumer, and C is a provider, so the call chain is like this:
A-->B-->C
when I start a request, it pass through the whole chain, after finishing the request, I find the trace info in last project(i.e. project C) is error, the following trace info indicates the error:
A
kind CLIENT: traceId:70d0 spanId:9340 parentId:70d0
B
kind SERVER: traceId:70d0 spanId:9340 parentId:70d0
kind CLIENT: traceId:70d0 spanId:4211 parentId:9340
C
kind SERVER: traceId:70d0 spanId:9340 parentId:70d0
there is an obvious error in this trace info, the info of C kind SERVER should be spanId:4211 parentId:9340
The cause of the Bug
Perhaps this code in org.apache.dubbo.rpc.protocol.AbstractInvoker line 160 causes the error, the code context as follows:
Map<String, Object> contextAttachments = RpcContext.getContext().getObjectAttachments();
if (CollectionUtils.isNotEmptyMap(contextAttachments)) {
invocation.addObjectAttachments(contextAttachments);
}this code indicates that before B makes an invocation to C, trace info in Invocation object is fresh, but it is old in RpcContext, and this code replace fresh trace info with old one! so the error happens.