shardingsphere5.1.2+seata1.5.1
The error is displayed when data is inserted Table primary keys are generated automatically and I did not specify them
Here is the SQL I executed and the error message insert into icloud_team_picture ( folder_id, user_id, team_id, organize_id, picture_name, picture_path, picture_size, picture_time, picture_status ) values (?,?, ?,?,?, ?,?,?, ? )
Cause: java.sql.SQLException: io.seata.common.exception.ShouldNeverHappenException
; uncategorized SQLException; SQL state [null]; error code [0]; io.seata.common.exception.ShouldNeverHappenException; nested exception is java.sql.SQLException: io.seata.common.exception.ShouldNeverHappenException] with root cause io.seata.common.exception.ShouldNeverHappenException: null
Can you provide your shardingsphere and seata configuration.
shardingsphere configuration
spring:
shardingsphere:
datasource:
ds-0:
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://192.168.0.xx2:3307/xx?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8
username: root
password: xx
names: ds-0
rules:
sharding:
# 设置绑定表
binding-tables:
- icloud_user_picture
tables:
# 个人图片基本信息表
icloud_user_picture: # 逻辑表名称
actualDataNodes: ds-0.icloud_user_picture_$->{0..1} # 由数据源名 + 表名组成(参考 Inline 语法规则)
tableStrategy: # 分表策略,同分库策略
standard:
shardingColumn: user_id #分配键
shardingAlgorithmName: icloud_user_picture_inline #分片规则
keyGenerateStrategy: # 分布式序列策略
column: picture_id # 自增列名称,缺省表示不使用自增主键生成器
keyGeneratorName: leaf # 分布式序列算法名称
# 分片规则
sharding-algorithms:
icloud_sys_log_inline:
type: CLASS_BASED
props:
strategy: STANDARD
algorithmClassName: com.ydtx.camera.icloud.config.CustomPreciseShardingAlgorithm
icloud_user_picture_inline:
type: inline
props:
algorithm-expression: icloud_user_picture_$->{user_id % 2}
keyGenerators:
leaf:
type: "LEAF"
props:
sql-show: true
seata configuration
seata:
registry:
type: nacos
config:
type: nacos
nacos:
server-addr: 127.0.0.1:8848
group: SEATA_GROUP
username: nacos
password: nacos
#对应nacos配置 service.vgroupMapping.XXXX
tx-service-group: camera-icloud-tx-group
application-id: camera-icloud
use-jdk-proxy: true
@FlyingZC
Thanks for the feedback, I will try.
Hello, there is another case that sharding key will be lost after using seata proxy for shardingsphere data source, which will not happen if I use primary key @FlyingZC
- This cannot be reproduced in https://github.com/apache/shardingsphere/blob/4ef16afe4b740dbd45287edefbf3b3b4e9fdeadc/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/transactions/base/SeataTest.java in master branch. This exception cannot be reproduced under either HotSpot VM or GraalVM Native Image.
- @chengyonghu You need to provide an example with minimal reproducible unit test. The database and seata server should be created by testcontainers-java.
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
- This is not something that the master branch has... I'm assuming this is your private SPI implementation. Without being able to reproduce, I don't see the point in keeping the current issue open.
keyGenerators:
leaf:
type: "LEAF"