springboot 2.6.3 and shardingsphere 5.1.1 , transaction do not roll back
See original GitHub issueWhen I use shardingsphere version 5.1.1, transaction rollback fails. When using version 5.0.0 or not, the transaction failure rollback is successful
<properties>
<spring-boot.version>2.6.3</spring-boot.version>
<spring-cloud.version>2021.0.2</spring-cloud.version>
<spring-cloud-alibaba.version>2021.0.1.0</spring-cloud-alibaba.version>
<!--<sharding-sphere.version>5.0.0</sharding-sphere.version>-->
<sharding-sphere.version>5.0.0</sharding-sphere.version>
</>
<dependencyManagement>
<dependencies>
<!-- spring boot 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- spring cloud 依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- spring cloud alibaba 依赖 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${spring-cloud-alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
<version>${sharding-sphere.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
server:
tomcat:
uri-encoding: UTF-8
threads:
max: 1000
min-spare: 30
connection-timeout: 5000ms
port: 8090
servlet:
context-path: /sanyi/manager
spring:
transaction:
rollback-on-commit-failure: true
jackson:
default-property-inclusion: non_null
# 不使用 shardingSphere
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: root
url: jdbc:mysql://192.168.2.254:3307/sanyi_manager?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
# 5.0.0 版本配置
#shardingsphere:
# datasource:
# names: master
# master:
# type: com.zaxxer.hikari.HikariDataSource
# driver-class-name: com.mysql.cj.jdbc.Driver
# username: root
# password: root
# jdbc-url: jdbc:mysql://192.168.2.254:3307/sanyi_manager?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
# props:
# sql-show: true
# enabled: true
# rules:
# # 读写分离
# readwrite_splitting:
# data-sources:
# sanyi_manager:
# write-data-source-name: master
# read-data-source-names: master
# load-balancers-name: round-robin
# load-balancers:
# round-robin:
# type: ROUND_ROBIN
# props:
# workId: 1
# 5.1.1 版本配置 数据源
#shardingsphere:
# datasource:
# names: master
# master:
# type: com.zaxxer.hikari.HikariDataSource
# driver-class-name: com.mysql.cj.jdbc.Driver
# username: root
# password: root
# jdbc-url: jdbc:mysql://192.168.2.254:3307/sanyi_manager?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
# props:
# sql-show: true
# enabled: true
# rules:
# # 读写分离
# readwrite-splitting:
# data-sources:
# onn_auth:
# type: DYNAMIC
# props:
# auto-aware-data-source-name: master
# write-data-source-name: master
# read-data-source-names: master
# load-balancers-name: round-robin
# load-balancers:
# round-robin:
# type: ROUND_ROBIN
# props:
# workId: 1
# Spring 相关
# mybaits-plus配置
mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml
global-config:
db-config:
id-type: auto
table-underline: true
logic-delete-value: 1
logic-not-delete-value: 0
db-column-underline: true
refresh-mapper: true
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
default-enum-type-handler: org.apache.ibatis.type.EnumOrdinalTypeHandler
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
type-enums-package: com.demo.**.enums
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "status_record")
@Builder
public class StatusRecord implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@TableField(value = "project_id")
private Integer projectId;
}
/**
* by zhaowenyuan create 2022/5/27 17:45
*/
public interface StatusRecordMapper extends BaseMapper<StatusRecord> {
}
/**
* by zhaowenyuan create 2022/5/27 17:45
*/
public interface StatusRecordService extends IService<StatusRecord> {
void saveTest();
}
@Slf4j
@Service
public class StatusRecordServiceImpl extends ServiceImpl<StatusRecordMapper, StatusRecord> implements StatusRecordService {
@Override
@Transactional
public void saveTest() {
save(StatusRecord.builder()
.projectId(11)
.build());
int s = 1 / 0;
}
}
@Slf4j
@SpringBootTest(classes = DemoApplication.class)
@RunWith(SpringRunner.class)
public class DemoTest {
@Autowired
StatusRecordService statusRecordService;
/**
* success
* shardingsphere version 5.0.0 and do not use shardingsphere
* error
* shardingsphere version 5.1.1
*
*/
@Test
public void transactionalTest(){
statusRecordService.saveTest();
}
}
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
FAQ - Apache ShardingSphere
The use norm of Spring Namespace does not require to deploy xsd files to the official ... in spring boot project when integrating...
Read more >Spring Boot Transaction not rolling back - jpa - Stack Overflow
The problem is that the transacction not rollback on exceptions, with or without the rollBackFor attribute.
Read more >Search Results - CVE
Since Apache Hama is EOL, we do not expect these issues to be fixed. ... To revert to the original behaviour, the administrator...
Read more >How does Apache ShardingSphere implement distributed ...
If not, a background process will clear the data. The app runs the rollback command, and the connection registered in the transaction that...
Read more >PoC in GitHub - Domini's blog
CVE-2020-0976. A spoofing vulnerability exists when Microsoft SharePoint Server does not properly sanitize a specially crafted web request to an ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello , this issue has not received a reply for several days. This issue is supposed to be closed.
Thank you for your advice