dragonorant opened a new issue, #18008:
URL: https://github.com/apache/shardingsphere/issues/18008

   When I use shardingsphere version 5.1.1, transaction rollback fails. When 
using version 5.0.0 or not, the transaction failure rollback is successful
   
   ```pom
   <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>
   
   ```
   
   ```app.yml
   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
   
   ```
   
   ```java
   
   @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;
       }
   }
   
   ```
   
   ```test
   
   @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();
       }
   
   }
   
   ```


-- 
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]

Reply via email to