question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SELECT UUID_SHORT() across data sources

See original GitHub issue

Question

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:open
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
github-actions[bot]commented, Oct 8, 2022

Hello , this issue has not received a reply for several days. This issue is supposed to be closed.

0reactions
Green524commented, Jul 20, 2022

What is your configuration?

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

UUID_SHORT() function in MySQL - GeeksforGeeks
This function in MySQL is used to return a “short” universal identifier as a 64-bit unsigned integer. The value of UUID_SHORT() is ...
Read more >
UUID_SHORT - MariaDB Knowledge Base
Returns a "short" universally unique identifier as a 64-bit unsigned integer (rather than a string-form 128-bit identifier as returned by the UUID() ......
Read more >
MySQL UUID_SHORT() Function - A Complete Guide
In this article, we will study the MySQL UUID_SHORT() function with its syntax, ... It is auto-incremented, will be unique across all the...
Read more >
UUID_short() in mysql - CodeProject
I am storing UUID_Short() values in a unique key of my table, now I am trying to use my table's data to SQL...
Read more >
MySQL 5.7 Reference Manual :: 12.21 Miscellaneous Functions
UUID_SHORT(), Return an integer-valued universal identifier ... It may be that, due to some property of a given data set, you know that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found