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 2020/05/23 11:43:23 UTC

[GitHub] [shardingsphere] hitnewbee opened a new issue #5769: WIthout keyGenerator in yaml file, insert execute multiple time

hitnewbee opened a new issue #5769:
URL: https://github.com/apache/shardingsphere/issues/5769


   table struct:
   | t_user_0 | CREATE TABLE `t_user_0` (
     `user_id` bigint(20) NOT NULL AUTO_INCREMENT,
     `username` varchar(30) NOT NULL,
     `password` varchar(30) DEFAULT NULL,
     `engines` varchar(50) DEFAULT NULL,
     PRIMARY KEY (`user_id`)
   ) ENGINE=InnoDB AUTO_INCREMENT=470908781660733445 DEFAULT CHARSET=utf8 |
   
   config-sharding.yaml:
   rules:
     - !SHARDING
       tables:
         t_user:
           actualDataNodes: ds_${0..1}.t_user_${0..1}
           tableStrategy:
             standard:
               shardingColumn: user_id
               shardingAlgorithm:
                 type: INLINE
                 props:
                   algorithm.expression: t_user_${user_id % 2}
           keyGenerator:
             type: SNOWFLAKE
             column: user_id
       bindingTables:
         - t_user
       defaultDatabaseStrategy:
         standard:
           shardingColumn: user_id
           shardingAlgorithm:
             type: INLINE
             props:
               algorithm.expression: ds_${user_id % 2}
       defaultTableStrategy:
         none:
   
   execute sql:
   mysql> insert into t_user(username) values(10);
   Query OK, 4 rows affected (0.21 sec)
   
   actual sql:
   [INFO ] 19:41:23.334 [ShardingSphere-Command-6] ShardingSphere-SQL - Actual SQL: ds_0 ::: insert into t_user_0(username) values(10)
   [INFO ] 19:41:23.334 [ShardingSphere-Command-6] ShardingSphere-SQL - Actual SQL: ds_0 ::: insert into t_user_1(username) values(10)
   [INFO ] 19:41:23.334 [ShardingSphere-Command-6] ShardingSphere-SQL - Actual SQL: ds_1 ::: insert into t_user_0(username) values(10)
   [INFO ] 19:41:23.334 [ShardingSphere-Command-6] ShardingSphere-SQL - Actual SQL: ds_1 ::: insert into t_user_1(username) values(10)
   
   


----------------------------------------------------------------
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.

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



[GitHub] [shardingsphere] hitnewbee commented on issue #5769: WIthout keyGenerator in yaml file, insert execute multiple time

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


   Seem like valid sharding condition donot generate on purpose in this situation, if the sharding column and value not specific with sql, maybe pick a random table or show error?


----------------------------------------------------------------
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.

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



[GitHub] [shardingsphere] kimmking commented on issue #5769: WIthout keyGenerator in yaml file, insert execute multiple time

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


   In your first post, there is a 'keyGenerator' for `t_user`, do you mean it's missing in your case?
   


----------------------------------------------------------------
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.

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



[GitHub] [shardingsphere] hitnewbee commented on issue #5769: WIthout keyGenerator in yaml file, insert execute multiple time

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


   > In your first post, there is a 'keyGenerator' for `t_user`, do you mean it's missing in your case?
   
   Sorry, pasted previous yaml file, I remove the keyGenerator and double check it. With keyGenerator missing,  the sql mentioned above will add four record to db;


----------------------------------------------------------------
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.

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



[GitHub] [shardingsphere] kimmking closed issue #5769: Without keyGenerator in yaml file, insert execute multiple time

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


   


----------------------------------------------------------------
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.

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



[GitHub] [shardingsphere] kimmking commented on issue #5769: Without keyGenerator in yaml file, insert execute multiple time

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


   You know, with a key generator, there will be added a key value to insert statement, and then shardingsphere will route insert statement to a certain database/table.
   
   But without a key generator, there will be not a key value, so shardingsphere will not know how ti route this statement.


----------------------------------------------------------------
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.

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