You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/06/29 16:33:47 UTC

[GitHub] [shardingsphere] kxw07 opened a new issue #11066: Why Insert existed primary key with no error

kxw07 opened a new issue #11066:
URL: https://github.com/apache/shardingsphere/issues/11066


   I was testing XA and use shardingsphere-jdbc-core, shardingsphere-transaction-xa-core 5.0.0-beta
   
   have a table in db
   ```sql
   CREATE TABLE test_order (order_id bigint NOT NULL, user_id bigint DEFAULT NULL, PRIMARY KEY(order_id)
   ```
   
   And already have a row in table
   order_id, user_id
   123, 123
   
   
   Then insert a row with same value (123, 123) again, there's no error in log.
   I think it should show duplicate entry error.
   ```java
   try (Connection conn = dataSource.getConnection()) { // connection auto commit is true.
         PreparedStatement ps = conn.prepareStatement("INSERT INTO test_order (order_id, user_id) VALUES (?, ?)");
         ps.setLong(1, 123L);
         ps.setLong(2, 123L);
         ps.execute();
   }
   ```
   
   
   Here is my yaml
   ```yaml
   dataSources:
     ds_0:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       jdbcUrl: jdbc:mysql://localhost:3316/java_course
       username: root
       password:
     ds_1:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       jdbcUrl: jdbc:mysql://localhost:3336/java_course
       username: root
       password:
   
   rules:
   - !SHARDING
     tables:
       test_order:
         actualDataNodes: ds_${0..1}.test_order_${0..15}
         tableStrategy:
           standard:
             shardingColumn: order_id
             shardingAlgorithmName: table_inline
         keyGenerateStrategy:
           column: order_id
           keyGeneratorName: snowflake
     defaultDatabaseStrategy:
       standard:
         shardingColumn: user_id
         shardingAlgorithmName: database_inline
     defaultTableStrategy:
       none:
   
     shardingAlgorithms:
       database_inline:
         type: INLINE
         props:
           algorithm-expression: ds_${user_id % 2}
       table_inline:
         type: INLINE
         props:
           algorithm-expression: test_order_${order_id % 16}
   
     keyGenerators:
       snowflake:
         type: SNOWFLAKE
         props:
             worker-id: 123
   
   props:
     sql-show: true
   ```
   
   
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] avalon5666 commented on issue #11066: Why Insert existed primary key with no error

Posted by GitBox <gi...@apache.org>.
avalon5666 commented on issue #11066:
URL: https://github.com/apache/shardingsphere/issues/11066#issuecomment-871027770


   Duplicate with #11063


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] avalon5666 commented on issue #11066: Why Insert existed primary key with no error

Posted by GitBox <gi...@apache.org>.
avalon5666 commented on issue #11066:
URL: https://github.com/apache/shardingsphere/issues/11066#issuecomment-871062746


   Fixed by #10845, You can build from master and test again.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] kxw07 closed issue #11066: Why Insert existed primary key with no error

Posted by GitBox <gi...@apache.org>.
kxw07 closed issue #11066:
URL: https://github.com/apache/shardingsphere/issues/11066


   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] kxw07 commented on issue #11066: Why Insert existed primary key with no error

Posted by GitBox <gi...@apache.org>.
kxw07 commented on issue #11066:
URL: https://github.com/apache/shardingsphere/issues/11066#issuecomment-871477778


   works, thank you.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org