You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "zy1263188600 (via GitHub)" <gi...@apache.org> on 2023/03/02 09:20:59 UTC

[GitHub] [shardingsphere] zy1263188600 opened a new issue, #24422: Special SQL about not executing ComplexKeysShardingAlgorithm.dosharding()

zy1263188600 opened a new issue, #24422:
URL: https://github.com/apache/shardingsphere/issues/24422

   ## Bug Report
   
   **For English only**, other languages will not accept.
   关于多分库键复合算法自定义ComplexKeysShardingAlgorithm不执行 BUG
   About Multi-Database Key Composite Algorithm Customization ComplexKeysShardingAlgorithm Do Not Execute BUG
   or?
   WhereClauseShardingConditionEngine.mergeListShardingValues() 对于 相同Key 不同值的AND条件处理异常的BUG
   WhereClauseShardingConditionEngine. mergeListShardingValues() BUG handling exceptions for AND conditions with the same key and different values
   
   ### Which version of ShardingSphere did you use?
   
   shardingsphere-5.2.0
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   ShardingSphere-JDBC
   
   ### Expected behavior
   
   我觉得定义了ComplexKeysShardingAlgorithm的情况下,只要SQL Where中含有分库键就应该执行ComplexKeysShardingAlgorithm.dosharding()
   I think that when the ComplexKeysShardingAlgorithm is defined, as long as the sub-database key is included in the SQL where, the ComplexKeysShardingAlgorithm. dosharing() should be executed
   
   
   ### Actual behavior
   
        在我的配置中,使用SQL1、2会进入 ShardingUnicastRoutingEngine 并不会经由ShardingComplexRoutingEngine执行     
        ComplexKeysShardingAlgorithm.dosharding(),我认为这是一个BUG,因为是一个很奇怪的行为而ShardingUnicastRoutingEngine并没有正确的执行分库策略,看上去是默认取了第一个数据源的第一个表,并且不会抛出异常,这在生产环境没有DEBUG调试环境和没开启sql-show时非常致命并且难以追踪BUG。
        In my configuration, using SQL1 and SQL2 will enter the ShardingUnicastRoutingEngine and will not execute the ComplexKeysShardingAlgorithm. dosharing() through the ShardingComplexRoutingEngine. I think this is a bug, because it is a very strange behavior. The ShardingUnicastRoutingEngine does not correctly execute the sub-database policy. It seems that it takes the first table of the first data source by default and will not throw an exception, This is very fatal when there is no DEBUG debugging environment in the production environment and sql-show is not enabled, and it is difficult to track the BUG.
        或者是我理解错了ComplexKeysShardingAlgorithm的用法还是这是一个BUG,如果是BUG我很乐意尝试进行修复。
        Either I misunderstood the use of ComplexKeysSharingAlgorithm or this is a bug. If it is a bug, I am happy to try to repair it.
   
   ### Reason analyze (If you can)
   
       在使用1、2SQL执行的情况下会被WhereClauseShardingConditionEngine.mergeListShardingValues()中的以下这行逻辑返回空list
       In the case of using 1 and 2 SQL to execute, an empty list will be returned by the following logic in WhereClauseShardingConditionEngine. mergeListShardingValues()
   
   ![image](https://user-images.githubusercontent.com/74887513/222385671-cc6edc6b-6b7c-41e2-be7b-8f247636e4b9.png)
   ![image](https://user-images.githubusercontent.com/74887513/222386059-68200333-2369-4fb2-9720-6890d81449a5.png)
   
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   发生异常的SQL (不会进入ComplexKeysShardingAlgorithm.dosharding())
   1、SELECT  *  FROM f_busi  WHERE (id = 1 **AND** id = 2)
   2、SELECT  *  FROM f_busi  WHERE (cust_sex = 1 **AND** cust_sex = 2)
   正常的SQL (会进入ComplexKeysShardingAlgorithm.dosharding())
   3、SELECT  *  FROM busi where id = 1
   4、SELECT  *  FROM busi where sex =1 
   5、SELECT  *  FROM f_busi  WHERE (id = 1 **OR** id = 2)
   6、SELECT  *  FROM f_busi  WHERE (cust_sex = 1 **OR** cust_sex = 2)
   
   
   config
   。。。
   spring.shardingsphere.rules.sharding.tables.f_busi.actual-data-nodes=fbusi-$->{2020..2027}.f_busi_$->{(1..12).collect{t ->t.toString().padLeft(2,'0')}}
   spring.shardingsphere.rules.sharding.tables.f_busi.table-strategy.complex.sharding-columns=id,sex,start_time
   spring.shardingsphere.rules.sharding.tables.f_busi.table-strategy.complex.sharding-algorithm-name=f-busi-inline
   spring.shardingsphere.rules.sharding.sharding-algorithms.f-busi-inline.type=CLASS_BASED
   spring.shardingsphere.rules.sharding.sharding-algorithms.f-busi-inline.props.strategy=complex
   spring.shardingsphere.rules.sharding.sharding-algorithms.f-busi-inline.props.algorithmClassName=com.cdfortis.fbusihistoricaldata.config.algorithm.MyComplexShardingAlgorithmTB
   。。。。
   
   MyComplexShardingAlgorithmTB class
   ![image](https://user-images.githubusercontent.com/74887513/222379457-9cbf0498-96d9-426b-ae00-28c2de2ca9a8.png)
   
   
   


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

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


[GitHub] [shardingsphere] zy1263188600 commented on issue #24422: Special SQL about not executing ComplexKeysShardingAlgorithm.dosharding()

Posted by "zy1263188600 (via GitHub)" <gi...@apache.org>.
zy1263188600 commented on issue #24422:
URL: https://github.com/apache/shardingsphere/issues/24422#issuecomment-1455546392

   Hi,please have a look. @FlyingZC 


-- 
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] zy1263188600 commented on issue #24422: Special SQL about not executing ComplexKeysShardingAlgorithm.dosharding()

Posted by "zy1263188600 (via GitHub)" <gi...@apache.org>.
zy1263188600 commented on issue #24422:
URL: https://github.com/apache/shardingsphere/issues/24422#issuecomment-1471135588

   @FlyingZC thank ,I understand


-- 
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] FlyingZC commented on issue #24422: Special SQL about not executing ComplexKeysShardingAlgorithm.dosharding()

Posted by "FlyingZC (via GitHub)" <gi...@apache.org>.
FlyingZC commented on issue #24422:
URL: https://github.com/apache/shardingsphere/issues/24422#issuecomment-1459184080

   ```sql
   1、SELECT * FROM f_busi WHERE (id = 1 AND id = 2)
   2、SELECT * FROM f_busi WHERE (cust_sex = 1 AND cust_sex = 2)
   ```
   @zy1263188600 Hi, when you execute these sql on mysql, you should not be able to find the data. I think the semantics of this sql is problematic. It should be meaningless to go to the ComplexShardingAlgorithm.


-- 
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] FlyingZC commented on issue #24422: Special SQL about not executing ComplexKeysShardingAlgorithm.dosharding()

Posted by "FlyingZC (via GitHub)" <gi...@apache.org>.
FlyingZC commented on issue #24422:
URL: https://github.com/apache/shardingsphere/issues/24422#issuecomment-1459165907

   @zy1263188600 Hi, It's a bug, would you want to try to fix it.
   ```sql
   mysql> select * from t_order where user_id=1 and user_id=2;
   Empty set (0.01 sec)
   
   mysql> select * from t_order where user_id in(1,2);
   +----------+---------+--------+
   | order_id | user_id | status |
   +----------+---------+--------+
   |        2 |       2 | 2      |
   |        1 |       1 | 1      |
   +----------+---------+--------+
   2 rows in set (0.07 sec)
   ```


-- 
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] zy1263188600 closed issue #24422: Special SQL about not executing ComplexKeysShardingAlgorithm.dosharding()

Posted by "zy1263188600 (via GitHub)" <gi...@apache.org>.
zy1263188600 closed issue #24422: Special SQL about not executing ComplexKeysShardingAlgorithm.dosharding()
URL: https://github.com/apache/shardingsphere/issues/24422


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