YokenLiao opened a new issue, #34483:
URL: https://github.com/apache/shardingsphere/issues/34483
this is my setup:
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
<version>${sharding.jdbc.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
<version>${batis.version}</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.33</version>
</dependency>
application.properties
spring.application.name=AhKen-data-center
server.port=8790
spring.shardingsphere.database.schemal.name=data-center,test
logging.level.org.apache.shardingsphere=DEBUG
#mybatis.mapper-locations=classpath:mapper/*.xml
#mybatis.type-aliases-package=org.ahken.data.center.po
spring.shardingsphere.props.sql-show=true
#????: standalone, cluster, etc.
spring.shardingsphere.mode.type= standalone
spring.shardingsphere.datasource.names=ds0,ds1
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.jdbc-url=jdbc:mysql://127.0.0.1:3306/data-center
spring.shardingsphere.datasource.ds0.username=root
spring.shardingsphere.datasource.ds0.password=666666
spring.shardingsphere.datasource.ds1.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds1.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ds1.jdbc-url=jdbc:mysql://127.0.0.1:3306/test
spring.shardingsphere.datasource.ds1.username=root
spring.shardingsphere.datasource.ds1.password=666666
spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds$->{0..1}.t_order_$->{0..1}
spring.shardingsphere.rules.sharding.tables.t_order.database-strategy.standard.sharding-column=user_id
spring.shardingsphere.rules.sharding.tables.t_order.database-strategy.standard.sharding-algorithm-name=database-inline
spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=table-inline
spring.shardingsphere.rules.sharding.tables.t_order.keyGenerateStrategy.column=id
spring.shardingsphere.rules.sharding.tables.t_order.keyGenerateStrategy.keyGeneratorName=snowflake
#spring.shardingsphere.rules.sharding.tables.t_bill.actual-data-nodes=ds$->0.t_bill_$->{org.ahken.data.center.config.algorithms.BasedYearMonthShardingAlgorithm.getActualTableNameSuffix('2025-01',true)}
spring.shardingsphere.rules.sharding.tables.t_bill.actual-data-nodes=ds$->{0}.t_bill_${org.ahken.data.center.config.algorithms.BasedYearMonthShardingAlgorithm.getActualTableNameSuffix('2024-12',
false)}
#spring.shardingsphere.rules.sharding.tables.t_bill.database-strategy.standard.sharding-column=user_id
#spring.shardingsphere.rules.sharding.tables.t_bill.database-strategy.standard.sharding-algorithm-name=database-inline
spring.shardingsphere.rules.sharding.tables.t_bill.table-strategy.standard.sharding-column=create_time
spring.shardingsphere.rules.sharding.tables.t_bill.table-strategy.standard.sharding-algorithm-name=based_year_month
spring.shardingsphere.rules.sharding.tables.t_bill.keyGenerateStrategy.column=id
spring.shardingsphere.rules.sharding.tables.t_bill.keyGenerateStrategy.keyGeneratorName=snowflake
spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.type=INLINE
spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.props.algorithm-expression=ds$->{user_id
% 2}
spring.shardingsphere.rules.sharding.sharding-algorithms.table-inline.type=INLINE
spring.shardingsphere.rules.sharding.sharding-algorithms.table-inline.props.algorithm-expression=t_order_$->{order_id
% 2}
spring.shardingsphere.rules.sharding.sharding-algorithms.based_year_month.type=BasedYearMonth
spring.shardingsphere.rules.sharding.sharding-algorithms.based_year_month.props.year-month-lower=2024-12
logging.level.org.springframework.transaction=DEBUG
this is my operate method:
public void testTransaction() {
transactionTemplate.execute(new TransactionCallback<Void>() {
@Override
public Void doInTransaction(TransactionStatus status) {
try {
TBillPo tBillPo = new TBillPo();
tBillPo.setId("123ab");
tBillPo.setFromAccount("a");
tBillPo.setToAccount("b");
tBillPo.setAmount(BigDecimal.valueOf(1523));
tBillPo.setPurpose("test");
// tBillPo.setCreateTime(LocalDateTimeUtil.parse("2024-09-01",
DatePattern.NORM_DATE_PATTERN));
// tBillMapper.insert(tBillPo);
tBillPo.setCreateTime(LocalDateTimeUtil.parse("2025-02-01",
DatePattern.NORM_DATE_PATTERN));
tBillMapper.insert(tBillPo);
// tBillPo.setId("1232a");
// tBillPo.setCreateTime(LocalDateTimeUtil.parse("2025-03-01",
DatePattern.NORM_DATE_PATTERN));
//
// tBillMapper.insert(tBillPo);
// TOrderPo tOrderPo = new TOrderPo();
// tOrderPo.setId("o20250125");
// tOrderPo.setGoodsName("test goods");
// tOrderPo.setUserId(123l);
// tOrderPo.setOrderId(456l);
// tOrderPo.setCreateTime(LocalDateTime.now());
// tOrderMapper.insert(tOrderPo);
if (true) {
throw new BusinessException("test transaction
rollback");
}
return null;
} catch (Exception e) {
status.setRollbackOnly();
throw e;
}
}
});
}
question describe:the method handle complete ,the data still insert into
table ,but not rollback
--
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]