Alleninggx opened a new issue, #14485:
URL: https://github.com/apache/dubbo/issues/14485

   ### Pre-check
   
   - [X] I am sure that all the content I provide is in English.
   
   
   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Apache Dubbo Component
   
   Java SDK (apache/dubbo)
   
   ### Dubbo Version
   
   dubbo 3.2
   seata 2.0..0
   dubbo-filter-seata 1.0.2
   
   seata and dubbo-filter-seata relies on spring-cloud-alibaba-bom
   
   ### Steps to reproduce this issue
   
   ```java
   @Override
   @GlobalTransactional
   public boolean edit() throws BizException {
       System.err.println("xid " + RootContext.getXID());  // xid = 123
       Dept dept = deptDubbo.getById(id);                      // deptDubbo and 
the current class are in the same service
       System.err.println("xid " + RootContext.getXID());  // xid = null
   }
   ```
   
当在全局事务中,调用一个来自本服务的一个Dubbo接口时,会使RootContext中的xid丢失(仅RootContext的xid丢失了,DefaultGlobalTransaction中并没有)
   
   我在Dubbo Filter中,结合多个Consumer验证了这个结论:
   ```
   @Activate(group = CommonConstants.CONSUMER)
   public class DubboConsumerContextFilter implements Filter {
   
       @Override
       public Result invoke(Invoker<?> invoker, Invocation invocation) throws 
RpcException {
           
RpcContext.getClientAttachment().setObjectAttachment(AttachmentName.SECURITY_CONTEXT,
 ContextHolder.getSecurityContext());
           
RpcContext.getClientAttachment().setObjectAttachment(AttachmentName.I18N_CONTEXT,
 ContextHolder.getI18nContext());
   
           System.out.println(RootContext.getXID());   // xid = 123
           Result result = invoker.invoke(invocation);
           System.out.println(RootContext.getXID());   // xid = null
           return result;
       }
   
   }
   ```
   
   
   ### What you expected to happen
   
   
我觉得应该是`SeataTransactionPropagationProviderFilter`的问题,它的作用是把消费端的xid设置到服务端的RootContext中,结束后它有一步是在结束调用后解绑,但是因为Consumer和Provider都是同一个服务,所以RootContext也是同一个,导致了解绑时把Consumer的xid解绑了。
   
![image](https://github.com/user-attachments/assets/5a2ca346-1b91-46f5-b588-cc32f51de9bf)
   
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request to fix on your own?
   
   - [ ] Yes I am willing to submit a pull request on my own!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to