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 2019/12/05 09:39:20 UTC

[GitHub] [incubator-shardingsphere] lightning-pro opened a new issue #3666: sharding-proxy Help wanted.

lightning-pro opened a new issue #3666: sharding-proxy Help wanted.
URL: https://github.com/apache/incubator-shardingsphere/issues/3666
 
 
   Hello,最近被这个sharding-proxy折腾得太厉害了,遇到的问题诡异,如果问题有价值,后面再用英文再描述一次。
   问题背景:在用RC2遇到timestamp 读写bug的问题后,从源码编译RC4,timestamp bug是解决了。但inline的表达式不能支持简单的查询比如
   `SELECT * FROM CUSTOMER_SMS_NUM WHERE SMS_NUM_ID > 11`
   raise了两次,建议是自己写sharding算法。经过一番研究后。我实现了自己的sharding算法,并打包到conf/lib下。
   如下
   PreciseShardingAlgorithm的实现类
   ```
   @Override
       public String doSharding(Collection<String> collection, PreciseShardingValue<Integer> preciseShardingValue) {
           for (String each : collection) {
               if (each.endsWith(String.valueOf(preciseShardingValue.getValue() % collection.size()))) {
                   return each;
               }
           }
           return null;
       }
   ```
   
   RangeShardingAlgorithm的实现类
   ```
   @Override
       public Collection<String> doSharding(Collection<String> availableTargetNames, RangeShardingValue<Integer> shardingValue) {
           Collection<String> result = new HashSet<>();
           if(shardingValue.getValueRange().hasUpperBound()){
               for (int i = shardingValue.getValueRange().lowerEndpoint(); i <= shardingValue.getValueRange().upperEndpoint(); i++) {
                   for (String each : availableTargetNames) {
                       if (each.endsWith(String.valueOf(i % availableTargetNames.size()))) {
                           result.add(each);
                       }
                   }
               }
           }else {
               result = availableTargetNames;
           }
   
           return result;
       }
   ```
   想问我的实现类有什么问题吗?查询数据会有很奇怪的问题,我大概觉得是merge结果的问题,不知道是我git pull拉的代码不’纯粹‘,还是真的是bug.还是我的实现类不是正确的实现
   
   现象如下:
   
   1.SELECT * FROM CUSTOMER_SMS_NUM where sms_num_id = 1 没有问题,显示结果很好。
   
   2.SELECT * from customer_sms_num limit 0,10 有问题。显示第一条数据是17,我的分表的数量刚好是这个值。其它9条数据全是null。
   
   3.SELECT * from customer_sms_num order by SMS_NUM_ID  limit 0,10 有问题,显示第一条数据是1,刚好是第一条数据。其它9条数据全是null。
   
   4.SELECT SMS_NUM_ID,PUBLIC_VIEW_ID,SMS_NUM_TYPE_ID,SMS_NUM_MIN,SMS_NUM_MAX from customer_sms_num order by SMS_NUM_ID limit 0,10
   显式的选择字段,没有问题,数据也正确。
   
   5.SELECT * FROM CUSTOMER_SMS_NUM  WHERE SMS_NUM_ID > 11 order by SMS_NUM_ID limit 0,10 有问题,只有第一条数据正常,其它9条为都是null
   
   6.SELECT SMS_NUM_ID,PUBLIC_VIEW_ID,SMS_NUM_TYPE_ID,SMS_NUM_MIN,SMS_NUM_MAX FROM CUSTOMER_SMS_NUM 
   WHERE SMS_NUM_ID > 11 order by SMS_NUM_ID limit 0,10
   显示选择字段没有问题
   
   7.SELECT * FROM CUSTOMER_SMS_NUM  WHERE SMS_NUM_ID > 1 and SMS_NUM_ID < 100 order by SMS_NUM_ID limit 0,10
   不正常,三条数据显示,其余为null,显示的数据相隔均匀
   
   8.SELECT SMS_NUM_ID,PUBLIC_VIEW_ID,SMS_NUM_TYPE_ID,SMS_NUM_MIN,SMS_NUM_MAX FROM CUSTOMER_SMS_NUM WHERE SMS_NUM_ID > 1 and SMS_NUM_ID < 100 order by SMS_NUM_ID limit 0,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


With regards,
Apache Git Services