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/10/22 18:49:52 UTC

[GitHub] [shardingsphere] Totuying opened a new issue #13233: update using case when causes fragmentation routing to drift

Totuying opened a new issue #13233:
URL: https://github.com/apache/shardingsphere/issues/13233


   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response anymore and we cannot reproduce it on current information, we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   4.1.1
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   
   ### Expected behavior
   routeValue = 'DS632624670761930754'
   
   
   ### Actual behavior
   routeValue = '2021-10-23 01:59:44.034'
   
   
   ### Reason analyze (If you can)
   Version 3.1.0 is no problem ,But upgrading to 4.1.1 fragmented routing has problems
   I tried to experiment with several schemes,
   Finally, tracking and debugging found,
   If I only use the case when statement to update, there is no problem, if the non-case when statement is added, the fragmentation strategy will drift。
   
   It feels like gmt_modify =? Caused by re-marking, 
   ParameterMarkerExpressionSegment(startIndex=339, stopIndex=339, parameterMarkerIndex=1)
   Theoretically, parameterMarkerIndex should be 0
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   #分片策略
   shardingRule:
     tables:
       t_asset_detail:
         actualDataNodes: ds$->{0..13}.t_asset_detail
         databaseStrategy:
           inline:
             shardingColumn: asset_item_no
             algorithmExpression: ds$->{Math.abs(asset_item_no.hashCode() % 14)}
     bindingTables:
       - t_asset_detail
   
   
   **Error example**
   UPDATE t_asset_detail
    SET holder =
           CASE WHEN 
               asset_item_no = ? AND ? >= gmt_holder THEN ? ELSE holder END ,
       gmt_modify = ? 
   WHERE asset_item_no = ?
   AND is_deleted = 0
   
   Parameters: DS632624670761930754(String), 2021-10-23 01:50:21.416(Timestamp), 4(Integer), 2021-10-23 01:50:21.416(Timestamp), DS632624670761930754(String)
   **Normal example**
   UPDATE t_asset_detail
    SET holder =
           CASE WHEN 
               asset_item_no = ? AND ? >= gmt_holder THEN ? ELSE holder END 
   WHERE asset_item_no = ?
   AND is_deleted = 0
   
   Parameters: DS632624670761930754(String), 2021-10-23 01:50:21.416(Timestamp), 4(Integer), DS632624670761930754(String)
   
   ### Example codes for reproduce this issue (such as a github link).
   


-- 
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] Totuying closed issue #13233: update using case when causes fragmentation routing to drift

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


   


-- 
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] Totuying commented on issue #13233: update using case when causes fragmentation routing to drift

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


   > Hi @Totuying Thanks for your feedback, could you try it with the latest version
   
   The 4.x version problem still exists


-- 
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] lanchengx commented on issue #13233: update using case when causes fragmentation routing to drift

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


   Hi @Totuying Thanks for your feedback, could you try it with the latest version


-- 
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] Totuying commented on issue #13233: update using case when causes fragmentation routing to drift

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


   > > > Hi @Totuying Thanks for your feedback, could you try it with the latest version
   > > 
   > > 
   > > The 4.x version problem still exists
   > 
   > you can try it with 5.x release
   
   tks ,Do not consider using the 5.x version for the time being ,We try to change the SQL order, Just move gmt_modify = ? to first row
   
   Error example
   UPDATE t_asset_detail
   SET holder =
   CASE WHEN
   asset_item_no = ? AND ? >= gmt_holder THEN ? ELSE holder END ,
   `gmt_modify = ?`
   WHERE asset_item_no = ?
   AND is_deleted = 0
   
   **The changed SQL is successful**
   UPDATE t_asset_detail
   SET 
   `gmt_modify` = ?,`
   holder =
   CASE WHEN
   asset_item_no = ? AND ? >= gmt_holder THEN ? ELSE holder END 
   WHERE asset_item_no = ?
   AND is_deleted = 0
   
   
   


-- 
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] Totuying commented on issue #13233: update using case when causes fragmentation routing to drift

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


   We found the real reason,In fact, shardingsphere does not support case when routing, so it happens that the first parameter happens to be the sharding key,This is not a bug。


-- 
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] zjcnb commented on issue #13233: update using case when causes fragmentation routing to drift

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


   > > Hi @Totuying Thanks for your feedback, could you try it with the latest version
   > 
   > The 4.x version problem still exists
   
   you can try it with 5.x release


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