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

   ## Bug Report
   
   **@Transactional not work**, each update or insert operation will execute 
the commit action
   Background:
   - springboot version: 2.6.6
   - orm: mybatis-plus 3.5.2
   - db: mysql 5.7
   - local transaction
   - sharding configurations:
   ```
   # sharding jdbc datasource configs
   spring.shardingsphere.datasource.names=ds_0
   spring.shardingsphere.datasource.ds0.type=com.zaxxer.hikari.HikariDataSource
   
spring.shardingsphere.datasource.ds0.driver-class-name=com.mysql.cj.jdbc.Driver
   
spring.shardingsphere.datasource.ds0.url=jdbc:mysql://xxx:3306/xx?allowPublicKeyRetrieval=true&useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai
   spring.shardingsphere.datasource.ds0.username=xx
   spring.shardingsphere.datasource.ds0.password=xxx
   spring.shardingsphere.datasource.ds0.maximum-pool-size=50
   # sharding jdbc table rules configs
   
spring.shardingsphere.rules.sharding.tables.cert.actual-data-nodes=ds_0.cert,ds_0.cert_${0..2},ds_0.cert_${100..102},ds_0.cert_${200..202},ds_0.cert_${300..302}
   
spring.shardingsphere.rules.sharding.tables.cert.table-strategy.standard.sharding-column=ca_id
   
spring.shardingsphere.rules.sharding.tables.cert.table-strategy.standard.sharding-algorithm-name=cert-class-based
   
spring.shardingsphere.rules.sharding.tables.cert.key-generate-strategy.column=id
   
spring.shardingsphere.rules.sharding.tables.cert.key-generate-strategy.key-generator-name=snowflake
   # sharding jdbc custom class based algorithm config
   
spring.shardingsphere.rules.sharding.sharding-algorithms.cert-class-based.type=CLASS_BASED
   
spring.shardingsphere.rules.sharding.sharding-algorithms.cert-class-based.props.strategy=standard
   
spring.shardingsphere.rules.sharding.sharding-algorithms.cert-class-based.props.algorithmClassName=xxx.CertShardingByRowsNoAlgorithm
   # shardingsphere common props
   spring.shardingsphere.props.sql-show=false
   spring.shardingsphere.props.max-connections-size-per-query=5
   ```
   - business code
   ```
    @Override
       @Transactional(rollbackFor = Exception.class)
       public boolean newRecord (RecordDto recordDto)  {
     
               recordMapper.insert(record1); // insert record1, after executing 
here, you can see the new record by sql query, it committed
              Boolean success =  recordMapper.insert(record2); // insert record 
2, after executing here, you can see the new record by sql query, it committed 
as well
              success = false
               if (false) {
                  // throw  exception, the transaction should be rollback, but 
the rollback not happen as expected
                   throw new Exception("saving records failed");
               }
               
       }
   ```
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub 
issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere 
Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more 
details. 
   If no response anymore and we cannot reproduce it on current information, we 
will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   5.1.2
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   
   ### Expected behavior
   Sharding-jdbc should work  well with springboot @Transactional annatation
   
   ### Actual behavior
   After enable sharding-jdbca, @Transactional will not work
   
   ### Reason analyze (If you can)
   When not use sharding jdbc, the @Transaction can work as expected, so is 
sharding-jdbc caused this problem, it may change the transaction work-flow 
internally?
   
   


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