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/10 03:56:12 UTC

[GitHub] [shardingsphere] jianliu opened a new issue #10746: Insert error with IntervalShardingAlgorithm when no db route configs in multi datatources and datanode name is unique

jianliu opened a new issue #10746:
URL: https://github.com/apache/shardingsphere/issues/10746


   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   master branch
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-Proxy & governance
   
   ### Expected behavior
   table columns:
   -  id(bigint)
   -  create_at(datetime)
   
   This is my config rules:
   ``` 
   - !SHARDING
     tables:
       fixed_test:
         actualDataNodes: ds_0.fixed_test_${0..1},ds_1.fixed_test_${2..3}
         tableStrategy:
           standard:
             shardingAlgorithmName: fixed_test_hash_mod
             shardingColumn: id
         keyGenerateStrategy:
           column: id
           keyGeneratorName: snowflake
       range_test:
         actualDataNodes: ds_0.range_test_${0..4},ds_1.range_test_${5..9}
         tableStrategy:
           standard:
             shardingAlgorithmName: range_test_volume_range
             shardingColumn: level
         keyGenerateStrategy:
           column: id
           keyGeneratorName: snowflake
       time_test:
         actualDataNodes: ds_0.time_test_2021062,ds_0.time_test_2021063,ds_1.time_test_2021064,ds_1.time_test_2021071
         tableStrategy:
           standard: 
             shardingAlgorithmName: time_test_interval
             shardingColumn: create_at
         keyGenerateStrategy:
           column: id
           keyGeneratorName: snowflake
     shardingAlgorithms:
       fixed_test_hash_mod:
         type: HASH_MOD
         props:
           sharding-count: 4
       range_test_volume_range:
         type: VOLUME_RANGE
         props:
           range-lower: 1
           range-upper: 1000
           sharding-volume: 100
       time_test_interval:
         type: INTERVAL
         props:
           datetime-lower: '2021-06-13 00:00:01'
           datetime-interval-unit: weeks
           datetime-interval-amount: 1
           datetime-pattern: yyyy-MM-dd HH:mm:ss
           sharding-suffix-pattern: yyyyMMW
     keyGenerators:
       snowflake:
         type: SNOWFLAKE
       uuid:
         type: uuid
   
   ```  
   
   sql:
   ``` 
   INSERT INTO `time_test` (`create_at`) VALUES ('2021-06-13 03:01:01');
   ```
   expect insert success
   
   ### Actual behavior
   <e>查询:insert into `time_test` (`create_at`) values ('2021-06-13 03:01:01')
   
   错误代码: 1999
   Unknown exception: [failed to shard value PreciseShardingValue(logicTableName=time_test, columnName=create_at, value=2021-06-13 03:01:01), and availableTables [time_test_2021064, time_test_2021071]]
   
   ### Reason analyze (If you can)
   ![image](https://user-images.githubusercontent.com/1589099/121461902-532a3900-c9e2-11eb-8330-a63b74d9c862.png)
   why:
   because there is not db routed,so both ds_0 and ds_1 will enter this code span and make this error finally.
   ps:
   doSharding with PreciseShardingValue should only return one datanodes
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   ### Example codes for reproduce this issue (such as a github link).
   
   IntervalShardingAlgorithm do not throw exception ,and check preciseSharding result at parent invoke span.
   If you think this is a problem,I`d like to resolve it
   


-- 
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] zhujunxxxxx commented on issue #10746: Insert error with IntervalShardingAlgorithm when no db route configs in multi datatources and datanode name is unique

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


   @strongduanmu I'd like to fix it.


-- 
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] jianliu commented on issue #10746: Insert error with IntervalShardingAlgorithm when no db route configs in multi datatources and datanode name is unique

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


   @zhujunxxxxx Thanks for your attention.I have fix it by myself. Sorry for not having comment in the first place.
   @strongduanmu Please review the code when you have time.
   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.

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



[GitHub] [shardingsphere] strongduanmu commented on issue #10746: Insert error with IntervalShardingAlgorithm when no db route configs in multi datatources and datanode name is unique

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


   @jianliu Thank you for your feedback. The way that `doSharding` method of the `IntervalShardingAlgorithm` class throws an exception is really not good. Are you interested in raising a PR to optimize this problem?


-- 
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] strongduanmu closed issue #10746: Insert error with IntervalShardingAlgorithm when no db route configs in multi datatources and datanode name is unique

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


   


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