SELECT UUID_SHORT() across data sources
See original GitHub issueQuestion
I used SELECT UUID_SHORT() to generate UUID in MyBatis. It should have been the same data source to generate the id, but I switched the data source at this time.
Creating a new SqlSession Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@39f5eba4] JDBC Connection [org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection@5f662dd] will be managed by Spring ==> Preparing: SELECT UUID_SHORT() ==> Parameters: 2022-04-14 10:33:03.387 INFO 11536 — [ main] ShardingSphere-SQL : Logic SQL: SELECT UUID_SHORT() 2022-04-14 10:33:03.388 INFO 11536 — [ main] ShardingSphere-SQL : SQLStatement: MySQLSelectStatement(limit=Optional.empty, lock=Optional.empty, window=Optional.empty) 2022-04-14 10:33:03.389 INFO 11536 — [ main] ShardingSphere-SQL : Actual SQL: ds-1 ::: SELECT UUID_SHORT() <== Columns: UUID_SHORT() <== Row: 16384652781207687349 <== Total: 1 ==> Preparing: insert into tb_commodity_cat (id, account_id, parent_id, cat_name, sort_order, create_time, update_time, comment, creator, last_modified_by) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ==> Parameters: 16384652781207687349(String), 302390790179528704(String), 0(String), 芙蓉王1(String), 1(Integer), 2022-04-14 10:33:02.602(Timestamp), 2022-04-14 10:33:02.602(Timestamp), 测试(String), null, xxx(String) 2022-04-14 10:33:03.711 INFO 11536 — [ main] ShardingSphere-SQL : Logic SQL: insert into
tb_commodity_cat
(id, account_id, parent_id, cat_name, sort_order, create_time,
update_time, comment, creator, last_modified_by)
values (?, ?, ?, ?, ?, ?,
?, ?, ?, ?)
2022-04-14 10:33:03.712 INFO 11536 — [ main] ShardingSphere-SQL : SQLStatement: MySQLInsertStatement(setAssignment=Optional.empty, onDuplicateKeyColumns=Optional.empty) 2022-04-14 10:33:03.712 INFO 11536 — [ main] ShardingSphere-SQL : Actual SQL: ds-2 ::: insert into
tb_commodity_cat
(id, account_id, parent_id, cat_name, sort_order, create_time,
update_time, comment, creator, last_modified_by)
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ::: [16384652781207687349, 302390790179528704, 0, 芙蓉王1, 1, 2022-04-14 10:33:02.602, 2022-04-14 10:33:02.602, 测试, null, xxx]
<== Updates: 1 Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@39f5eba4]``
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Hello , this issue has not received a reply for several days. This issue is supposed to be closed.
datasource.initialSize=5 datasource.minIdle=5 datasource.maxActive=20 datasource.maxWait=60000 datasource.timeBetweenEvictionRunsMillis=60000 datasource.minEvictableIdleTimeMillis=300000 datasource.validationQuery=select current_timestamp() datasource.testWhileIdle=true datasource.testOnBorrow=true datasource.testOnReturn=false datasource.poolPreparedStatements=true datasource.maxPoolPreparedStatementPerConnectionSize=20
spring.shardingsphere.datasource.ds-0.type=com.alibaba.druid.pool.DruidDataSource spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.cj.jdbc.Driver spring.shardingsphere.datasource.ds-0.url=jdbc:mysql://${mysql.db.ds0}/db_transaction_n0?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false spring.shardingsphere.datasource.ds-0.username=root spring.shardingsphere.datasource.ds-0.password=${MYSQL_PASSWORD:sql_mYpwd@123} spring.shardingsphere.datasource.ds-0.initialSize=${datasource.initialSize} spring.shardingsphere.datasource.ds-0.minIdle=${datasource.minIdle} spring.shardingsphere.datasource.ds-0.maxActive=${datasource.maxActive} spring.shardingsphere.datasource.ds-0.maxWait=${datasource.maxWait} spring.shardingsphere.datasource.ds-0.timeBetweenEvictionRunsMillis=${datasource.timeBetweenEvictionRunsMillis} spring.shardingsphere.datasource.ds-0.minEvictableIdleTimeMillis=${datasource.minEvictableIdleTimeMillis} spring.shardingsphere.datasource.ds-0.validationQuery=${datasource.validationQuery} spring.shardingsphere.datasource.ds-0.testWhileIdle=${datasource.testWhileIdle} spring.shardingsphere.datasource.ds-0.testOnBorrow=${datasource.testOnBorrow} spring.shardingsphere.datasource.ds-0.testOnReturn=${datasource.testOnReturn} spring.shardingsphere.datasource.ds-0.poolPreparedStatements=${datasource.poolPreparedStatements} spring.shardingsphere.datasource.ds-0.maxPoolPreparedStatementPerConnectionSize=${datasource.maxPoolPreparedStatementPerConnectionSize}
spring.shardingsphere.datasource.ds-1.type=com.alibaba.druid.pool.DruidDataSource spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.cj.jdbc.Driver spring.shardingsphere.datasource.ds-1.url=jdbc:mysql://${mysql.db.ds1}/db_transaction_n1?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false spring.shardingsphere.datasource.ds-1.username=root spring.shardingsphere.datasource.ds-1.password=${MYSQL_PASSWORD:sql_mYpwd@123} spring.shardingsphere.datasource.ds-1.initialSize=${datasource.initialSize} spring.shardingsphere.datasource.ds-1.minIdle=${datasource.minIdle} spring.shardingsphere.datasource.ds-1.maxActive=${datasource.maxActive} spring.shardingsphere.datasource.ds-1.maxWait=${datasource.maxWait} spring.shardingsphere.datasource.ds-1.timeBetweenEvictionRunsMillis=${datasource.timeBetweenEvictionRunsMillis} spring.shardingsphere.datasource.ds-1.minEvictableIdleTimeMillis=${datasource.minEvictableIdleTimeMillis} spring.shardingsphere.datasource.ds-1.validationQuery=${datasource.validationQuery} spring.shardingsphere.datasource.ds-1.testWhileIdle=${datasource.testWhileIdle} spring.shardingsphere.datasource.ds-1.testOnBorrow=${datasource.testOnBorrow} spring.shardingsphere.datasource.ds-1.testOnReturn=${datasource.testOnReturn} spring.shardingsphere.datasource.ds-1.poolPreparedStatements=${datasource.poolPreparedStatements} spring.shardingsphere.datasource.ds-1.maxPoolPreparedStatementPerConnectionSize=${datasource.maxPoolPreparedStatementPerConnectionSize}
spring.shardingsphere.datasource.ds-2.type=com.alibaba.druid.pool.DruidDataSource spring.shardingsphere.datasource.ds-2.driver-class-name=com.mysql.cj.jdbc.Driver spring.shardingsphere.datasource.ds-2.url=jdbc:mysql://${mysql.db.ds2}/db_transaction_n2?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false spring.shardingsphere.datasource.ds-2.username=root spring.shardingsphere.datasource.ds-2.password=${MYSQL_PASSWORD:sql_mYpwd@123} spring.shardingsphere.datasource.ds-2.initialSize=${datasource.initialSize} spring.shardingsphere.datasource.ds-2.minIdle=${datasource.minIdle} spring.shardingsphere.datasource.ds-2.maxActive=${datasource.maxActive} spring.shardingsphere.datasource.ds-2.maxWait=${datasource.maxWait} spring.shardingsphere.datasource.ds-2.timeBetweenEvictionRunsMillis=${datasource.timeBetweenEvictionRunsMillis} spring.shardingsphere.datasource.ds-2.minEvictableIdleTimeMillis=${datasource.minEvictableIdleTimeMillis} spring.shardingsphere.datasource.ds-2.validationQuery=${datasource.validationQuery} spring.shardingsphere.datasource.ds-2.testWhileIdle=${datasource.testWhileIdle} spring.shardingsphere.datasource.ds-2.testOnBorrow=${datasource.testOnBorrow} spring.shardingsphere.datasource.ds-2.testOnReturn=${datasource.testOnReturn} spring.shardingsphere.datasource.ds-2.poolPreparedStatements=${datasource.poolPreparedStatements} spring.shardingsphere.datasource.ds-2.maxPoolPreparedStatementPerConnectionSize=${datasource.maxPoolPreparedStatementPerConnectionSize}
#默认的数据库分片列(数据表列) 以及 自定义的分片算法名称(在文件指定) spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=account_id spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=account-sharding
#绑定表的实际节点命名规则为(由数据源名 + 表名组成,以小数点分隔。多个表以逗号分隔,支持inline表达式。) spring.shardingsphere.rules.sharding.tables.tb_transaction_detail.actual-data-nodes=ds-$->{0…2}.tb_transaction_detail spring.shardingsphere.rules.sharding.tables.tb_sub_transaction_detail.actual-data-nodes=ds-$->{0…2}.tb_sub_transaction_detail spring.shardingsphere.rules.sharding.tables.tb_pay_method.actual-data-nodes=ds-$->{0…2}.tb_pay_method spring.shardingsphere.rules.sharding.tables.tb_pay_order.actual-data-nodes=ds-$->{0…2}.tb_pay_order spring.shardingsphere.rules.sharding.tables.tb_business_process.actual-data-nodes=ds-$->{0…2}.tb_business_process #商品服务实际数据节点 spring.shardingsphere.rules.sharding.tables.tb_assemble_split_item.actual-data-nodes=ds-$->{0…2}.tb_assemble_split_item spring.shardingsphere.rules.sharding.tables.tb_assemble_split_rule.actual-data-nodes=ds-$->{0…2}.tb_assemble_split_rule spring.shardingsphere.rules.sharding.tables.tb_break_reason.actual-data-nodes=ds-$->{0…2}.tb_break_reason spring.shardingsphere.rules.sharding.tables.tb_commodity_break.actual-data-nodes=ds-$->{0…2}.tb_commodity_break spring.shardingsphere.rules.sharding.tables.tb_commodity_break_item.actual-data-nodes=ds-$->{0…2}.tb_commodity_break_item spring.shardingsphere.rules.sharding.tables.tb_commodity_cat.actual-data-nodes=ds-$->{0…2}.tb_commodity_cat spring.shardingsphere.rules.sharding.tables.tb_commodity_check.actual-data-nodes=ds-$->{0…2}.tb_commodity_check spring.shardingsphere.rules.sharding.tables.tb_commodity_check_item.actual-data-nodes=ds-$->{0…2}.tb_commodity_check_item spring.shardingsphere.rules.sharding.tables.tb_commodity_info.actual-data-nodes=ds-$->{0…2}.tb_commodity_info spring.shardingsphere.rules.sharding.tables.tb_stock_change.actual-data-nodes=ds-$->{0…2}.tb_stock_change spring.shardingsphere.rules.sharding.tables.tb_stock_flow.actual-data-nodes=ds-$->{0…2}.tb_stock_flow spring.shardingsphere.rules.sharding.tables.tb_stock_flow_item.actual-data-nodes=ds-$->{0…2}.tb_stock_flow_item spring.shardingsphere.rules.sharding.tables.tb_supplier.actual-data-nodes=ds-$->{0…2}.tb_supplier spring.shardingsphere.rules.sharding.tables.tb_custom_field.actual-data-nodes=ds-$->{0…2}.tb_custom_field
#指定的分片算法,自定义算法命名不能有下划线_ spring.shardingsphere.rules.sharding.sharding-algorithms.account-sharding.type=CLASS_BASED spring.shardingsphere.rules.sharding.sharding-algorithms.account-sharding.props.strategy=STANDARD spring.shardingsphere.rules.sharding.sharding-algorithms.account-sharding.props.algorithmClassName=com.liwen.pay.trans.sharding.StandardDBShardingStrategy
spring.shardingsphere.rules.sharding.binding-tables=tb_transaction_detail,tb_sub_transaction_detail
#打印日志 spring.shardingsphere.props.sql-show=true #是否开启联邦查询 spring.shardingsphere.props.sql-federation-enabled=true