shardingsphere
shardingsphere copied to clipboard
transactions not rolled back,
Bug Report
Which version of ShardingSphere did you use?
3.1.0.M1
Which project did you use? Sharding-JDBC or Sharding-Proxy?
Sharding-JDBC
Expected behavior
I am testing xa transactions, first i just use TransactionType.LOCAL ,the transaction should have been rolled back
Actual behavior
But The transaction cannot be rolled back,
Reason analyze (If you can)
Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when
Example codes for reproduce this issue (such as a github link).
@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)
public int insertUser(UserInfo userInfo) throws Exception {
TransactionTypeHolder.set(TransactionType.LOCAL);
UserInfo userInfo1 = new UserInfo();
int user_id = 45;
for (int j = 0; j < 10; j++) {
userInfo1.setAccount("Account" + j);
userInfo1.setPassword("pass" + j);
userInfo1.setUserName("name" + j);
userInfo1.setCreateTime(new Date());
userInfoMapper.insert(userInfo1);
CommonInfo commonInfo = new CommonInfo();
commonInfo.setId(j);
commonInfo.setName("name " + j);
commonInfoMapper.insert(commonInfo);
if (j > 3) {
throw new RuntimeException();
}
}
return 0 ;
}
If the following xa dependencies are not incloud, the transaction is normally rolled back.
<dependency>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-transaction-2pc-xa</artifactId>
<version>${sharding-sphere.version}</version>
</dependency>
userInfoMapper is sharding, commonInfoMapper is not sharding. I found that only commonInfoMapper are not rolled back
是要排除(exclude = JtaAutoConfiguration.class), 这个东西
fixed at https://github.com/sharding-sphere/sharding-spring/pull/9