shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

shardingsphere-jdbc standard alg. initialization problem

Open piggytough opened this issue 6 years ago • 10 comments

Which version of ShardingSphere did you use?

5.0.0-RC1-SNAPSHOT

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-JDBC

problem

standard sharding algorithm configuration not loaded

configuration below:

spring:
  shardingsphere:
    dataSources: 
      ...
    rules:
      sharding:
        tables:
          quantityaggregationdata:
            logicTable: quantityaggregationdata
            actualDataNodes: shardingdata.quantityaggregationdata_0_$->{0..7}
            tableStrategy:
              standard:
                shardingColumn: logtime
                shardingAlgorithmName: range-sharding
                tx: com.example.demosharding.strategy.ShardingAlgorithm
            keyGenerateStrategy:
              column: id
              keyGeneratorName: snowflake
        shardingAlgorithms:
          range-sharding:
            type: BOUNDARY_RANGE
            props:
              sharding-ranges: 0, 10, 20, 30, 40, 50, 60, 70

cause I cannot find some useful configuration example except for INLINE sharding, i'm not sure my config is properly set.

In my opinion, maybe the initation function's not called before doSharding. like this. sharding config

Maybe complex sharding's got the same problem as well.

thank you!

piggytough avatar Oct 24 '20 05:10 piggytough

You can refer to the following configuration documents: Spring Boot Sharding Configuration Spring Boot Sharding Algorithm Configuration Here is complete Spring Boot Example

avalon5666 avatar Oct 26 '20 04:10 avalon5666

You can refer to the following configuration documents: Spring Boot Sharding Configuration Spring Boot Sharding Algorithm Configuration Here is complete Spring Boot Example

thanks for your reply.

I've read the document, a detailed configuration example. Yet my main question still remains. I mean, the initialization of algorithm is not properly triggered while applicaition''s started, few clue's found. Couldyou check out this for me? thank you.

BTW, I suggest buildin complex algorithm like range + hash etc.

piggytough avatar Oct 27 '20 08:10 piggytough

Meanwhile, what''s the difference between autotable and table?

piggytough avatar Oct 27 '20 08:10 piggytough

You can refer to the following configuration documents: Spring Boot Sharding Configuration Spring Boot Sharding Algorithm Configuration Here is complete Spring Boot Example

thanks for your reply.

I've read the document, a detailed configuration example. Yet my main question still remains. I mean, the initialization of algorithm is not properly triggered while applicaition''s started, few clue's found. Couldyou check out this for me? thank you.

BTW, I suggest buildin complex algorithm like range + hash etc.

Have you ever tried inserting data? The result is your expect?

avalon5666 avatar Oct 27 '20 11:10 avalon5666

Yeah I tried. like this:

  1. the initiazation never triggered. image
  2. after manually init and got partitionRange, another error occured. Integer cast to Long problem. image

piggytough avatar Oct 28 '20 07:10 piggytough

For Q1, can you make a breakpoint here, ensure the algorithm is loaded.

image

By the way your code is lastest?

avalon5666 avatar Oct 29 '20 01:10 avalon5666

sorry for replying late.

I made a pull yesterday, it's almost latest. I made the breakpoint by it's not loaded. howhowever the bean BoundaryBasedRangeShardingAlgorithm is loaded, I can't find any clue. image

btw. my configuration's like below, I can't find anything wrong with that but the init is never loaded. image

piggytough avatar Nov 03 '20 09:11 piggytough

Did you have a custom BeanPostProcessor? It seem some class skipped auto proxying.

avalon5666 avatar Nov 04 '20 07:11 avalon5666

nope, it's only a simple demo. few classes were created except for ordinary controller/repository and druid connection. I can't see anything special

piggytough avatar Nov 04 '20 08:11 piggytough

Oh sorry, My FAULT. After reCreating a demo project, it's ok to init. maybe some class's made the skip, I'll find that. thank you for your patience. problem closed.

piggytough avatar Nov 05 '20 06:11 piggytough