GitHub user Ligen2022 edited a discussion: XA模式,先远程调用写,再远程调用读,但读不到刚才写的数据
### 环境
MySQL8,可重复读隔离级别
spring-cloud-alibaba 2021.0.6.0
seata 1.6.1
nacos, feign
### 伪代码
其中`serviceA`是另一个微服务。
```
@GlobalTransactional
public void method() {
// 远程调用写
Long id = serviceA.add(user);
// 远程调用读,根据id查询,但是查不到数据
serviceA.getById(id);
}
```
`Long id = serviceA.add(user)`可以正常执行,但是执行`serviceA.getById(id)`时,报错查询不到数据。
### 我的分析
在执行`serviceA.add(user)`时,`serviceA`会开启本地事务并执行,但不提交。当执行`serviceA.getById(id)`时,`serviceA`会开启另一个本地事务,而不是复用上一个。因此在可重复读隔离级别下,查询不到上一个事务的新增数据。
### 疑问
1. 如果我的上述分析是正确的,是否是因为我配置或使用错误,导致第二个事务没有合并到上一个事务?这个问题是否可以解决?
2. 如果我的使用是正确的,是否seata自身的设计就是如此呢?
GitHub link: https://github.com/apache/incubator-seata/discussions/7896
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]