Hi,

I just answer the questions.

For question 1:

The sharding strategy you provide is too complicated, can you try the
simple sharding strategy first and make sure the strategy is work fine as
you want?
We just concentrate the tech point of ShardingSphere, we need split
business logic first and then we can discuss about ShardingSphere future.

For question 2:

Please provide your ShardingSphere version number and logs of `sql.show`,
it is necessary to let us debug and reproduce the bug.

For question 3:

We need logs of `sql.show` to get your actual SQL too, please provide it.


A last, I have a suggestion, mailing-list should for search friendly, so it
is better separate your 3 questions to 3 different emails and give every
email a good title.

------------------

Liang Zhang (John)
Apache ShardingSphere & Dubbo


xu <[email protected]> 于2019年12月4日周三 下午4:53写道:

> Question 1:
>
> I have configured a strategy of sub table:
>
> The configuration file is as follows:
>
>
>
> <bean id="preciseModuloTableShardingAlgorithm"
> class="com.jd.bdp.cv.common.PreciseModuloShardingTableAlgorithm" />
> <bean id="rangeModuloShardingTableAlgorithm"
> class="com.jd.bdp.cv.common.RangeModuloShardingTableAlgorithm" />
>
> <sharding:standard-strategy id="tableShardingStrategy"
> sharding-column="task_id"
> precise-algorithm-ref="preciseModuloTableShardingAlgorithm"
> range-algorithm-ref="rangeModuloShardingTableAlgorithm"/>
>
>
> <sharding:data-source id="shardingDataSource">
>     <sharding:sharding-rule data-source-names="cv_dataSource">
>         <sharding:table-rules>
>             <sharding:table-rule logic-table="cv_user_task"
> actual-data-nodes="cv_dataSource.cv_user_task_${0..1}"
> table-strategy-ref="tableShardingStrategy"  />
>         </sharding:table-rules>
>        <!-- <sharding:binding-table-rules>
>             <sharding:binding-table-rule
> logic-tables="t_order,t_order_item"/>
>         </sharding:binding-table-rules>
>         <sharding:broadcast-table-rules>
>             <sharding:broadcast-table-rule table="t_address"/>
>         </sharding:broadcast-table-rules>-->
>    </sharding:sharding-rule>
>     <sharding:props>
>         <prop key="sql.show">true</prop>
>     </sharding:props>
> </sharding:data-source>
>
>
>
>
>
> My sub table logic is as follows:
>
>
>
> if (shardingValue.getValue()<7800){
>     return  "cv_user_task_0";
>
> }
> else {
>     Long modValue = shardingValue.getValue() % tableNames.size();
>     String modStr = modValue.toString();
>     for (String each : tableNames) {
>         if (each.endsWith(modStr)) {
>             return each;
>         }
>     }
> }
>
>
> throw new IllegalArgumentException();
>
>
>
> The specific logic is as follows: in order to be compatible with the old
> data, when the shardingvalue is less than a certain value (such as 1230),
> query the previous table, and when it is greater than a certain value, use
> the table splitting logic. The sub table logic is routed according to the
> modular operation. But I found that this logic did not take effect. There
> are two specific problems:
>
> 1. When debugging, you can only enter the doshading method for the first
> time, and then the breakpoint will not enter.
>
> 2. All the table fields in my database are smaller than 1230, so the
> original table CV user task should be selected according to the logic, but
> still go to CV user task 0, CV user task 1 from the console
>
>
>
> And no data can be found. So I suspect that if the table is not defined in
> the actual data nodes = "cv_datasource. Cv_user_task" ${0.. 1} ", the data
> cannot be queried. After testing, I found that my suspicion is correct. It
> can be queried to put the historical data into the two tables CV ﹣ user ﹣
> task ﹣ 0 and CV ﹣ user ﹣ task ﹣ 1. But what about my historical data? (must
> data migration be performed)
>
> Question two:
> After I use sharding, the function now () in SQL is not supported (using
> mybatis)
>
> Report errors:
>
>        Data truncation: Incorrect datetime value: 'now()' for column
> 'created' at row 1
>
>
>
> Question three:
>
>
>
> To test my sub table logic, it is written as follows:
>
>
>
> @Override
> public String doSharding(final Collection<String> tableNames, final
> PreciseShardingValue<Long> shardingValue) {
>
>
>     return  "cv_user_task_0";
>
> }
>
> I configured the return values to cv_user_task_0
>
>
>
> But from the console
>
>
>
> Both CV user task 0 and CV user task 1 are not valid at all. The queried
> data is also in the CV user task table.
>
>
>
> Is it because of my configuration?
>
>
>
>
>
>
>

Reply via email to