shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

Use ShardingSphere-JDBC4.1.1 can not print actual route log

Open wang7241 opened this issue 6 years ago • 10 comments

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

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

print actual route log

Actual behavior

print ordinarylog

Reason analyze (If you can)

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

yaml as follow:

spring: shardingsphere: datasource: default-data-source-name: ds0 names: ds0 ds0: type: com.zaxxer.hikari.HikariDataSource driver-class-name: com.mysql.jdbc.Driver jdbcUrl: jdbc:mysql://127.0.0.1:3306/fiforal_cw?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true&&useSSL=true username: root password: root sharding: props: sql: show: true ###I have tried sql.show: true,it is useless neither. tables: oral_cw_classwork_stu: actual-data-nodes: ds0.oral_cw_classwork_stu_${0..9} table-strategy: inline: sharding-column: school_id algorithm-expression: oral_cw_classwork_stu_$->{school_id.toLong() % 10} oral_cw_classwork_stu_content: actual-data-nodes: ds0.oral_cw_classwork_stu_content_${0..9} table-strategy: inline: sharding-column: school_id algorithm-expression: oral_cw_classwork_stu_content_$->{school_id.toLong() % 10} oral_cw_multilateral_assessment: actual-data-nodes: ds0.oral_cw_multilateral_assessment_${0..9} table-strategy: inline: sharding-column: school_id algorithm-expression: oral_cw_multilateral_assessment_$->{school_id.toLong() % 10} oral_cw_replys: actual-data-nodes: ds0.oral_cw_replys_${0..9} table-strategy: inline: sharding-column: school_id algorithm-expression: oral_cw_replys_$->{school_id.toLong() % 10} oral_cw_thumbs: actual-data-nodes: ds0.oral_cw_thumbs_${0..9} table-strategy: inline: sharding-column: school_id algorithm-expression: oral_cw_thumbs_$$->{school_id.toLong() % 10} oral_cw_comments: actual-data-nodes: ds0.oral_cw_comments${0..9} table-strategy: inline: sharding-column: school_id algorithm-expression: oral_cw_comments_$_$->{school_id.toLong() % 10}
binding-tables: oral_cw_classwork_stu,oral_cw_classwork_stu_content

pom.xml as follow: spring-boot is 2.2.1 version

 <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.47</version>
    </dependency>

    <dependency>
        <groupId>org.apache.shardingsphere</groupId>
        <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
        <version>4.1.1</version>
    </dependency>

Example codes for reproduce this issue (such as a github link).

wang7241 avatar Aug 17 '20 06:08 wang7241

Could you format the yaml configuration.

menghaoranss avatar Aug 18 '20 02:08 menghaoranss

@wang7241 Hi, when you set sql.show = true, there are no changes for your log info? Does other configuration work well, except for sql.show?

tristaZero avatar Aug 18 '20 03:08 tristaZero

@wang7241 Hi, when you set sql.show = true, there are no changes for your log info? Does other configuration work well, except for sql.show? Q:Hi, when you set sql.show = true, there are no changes for your log info? A:Yes Q:Does other configuration work well, except for sql.show? A:Yes

wang7241 avatar Aug 18 '20 03:08 wang7241

Could you format the yaml configuration.

When I copied YAML in here, its formatting failed. I wonder why,if you need,i can sent it to your email

wang7241 avatar Aug 18 '20 03:08 wang7241

Could you format the yaml configuration.

When I copied YAML in here, its formatting failed. I wonder why,if you need,i can sent it to your email

Yes, please send to [email protected] .

menghaoranss avatar Aug 18 '20 03:08 menghaoranss

[email protected]

I have sent

wang7241 avatar Aug 18 '20 03:08 wang7241

spring:
  shardingsphere:
    datasource:
      default-data-source-name: ds0
      names: ds0
      ds0:
        type: com.zaxxer.hikari.HikariDataSource
        driver-class-name: com.mysql.jdbc.Driver
        jdbcUrl: jdbc:mysql://127.0.0.1:3306/fiforal_cw?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true&&useSSL=true
        username: root
        password: root
    sharding:
      props:
        sql:
          show: true  ###sql.show: true I hava tried
      tables:
        oral_cw_classwork_stu:
          actual-data-nodes: ds0.oral_cw_classwork_stu_${0..9}
          table-strategy:
            inline:
              sharding-column: school_id
              algorithm-expression: oral_cw_classwork_stu_$->{school_id.toLong()  % 10}
        oral_cw_classwork_stu_content:
          actual-data-nodes: ds0.oral_cw_classwork_stu_content_${0..9}
          table-strategy:
            inline:
              sharding-column: school_id
              algorithm-expression: oral_cw_classwork_stu_content_$->{school_id.toLong()  % 10}
        oral_cw_multilateral_assessment:
          actual-data-nodes: ds0.oral_cw_multilateral_assessment_${0..9}
          table-strategy:
            inline:
              sharding-column: school_id
              algorithm-expression: oral_cw_multilateral_assessment_$->{school_id.toLong()  % 10}
        oral_cw_replys:
          actual-data-nodes: ds0.oral_cw_replys_${0..9}
          table-strategy:
            inline:
              sharding-column: school_id
              algorithm-expression: oral_cw_replys_$->{school_id.toLong()  % 10}
        oral_cw_thumbs:
          actual-data-nodes: ds0.oral_cw_thumbs_${0..9}
          table-strategy:
            inline:
              sharding-column: school_id
              algorithm-expression: oral_cw_thumbs_$_$->{school_id.toLong()  % 10}
        oral_cw_comments:
          actual-data-nodes: ds0.oral_cw_comments_${0..9}
          table-strategy:
            inline:
              sharding-column: school_id
              algorithm-expression: oral_cw_comments_$_$->{school_id.toLong()  % 10}      
      binding-tables: oral_cw_classwork_stu,oral_cw_classwork_stu_content

menghaoranss avatar Aug 18 '20 03:08 menghaoranss

@wang7241 Please try again according to the configuration below

spring:
  shardingsphere:
    props:
      sql.show: true
    datasource:
      default-data-source-name: ds0
      names: ds0
      ds0:
        type: com.zaxxer.hikari.HikariDataSource
        driver-class-name: com.mysql.jdbc.Driver
        jdbcUrl: jdbc:mysql://127.0.0.1:3306/fiforal_cw?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true&&useSSL=true
        username: root
        password: root
...

menghaoranss avatar Aug 18 '20 04:08 menghaoranss

@wang7241 Please try again according to the configuration below

spring:
  shardingsphere:
    props:
      sql.show: true
    datasource:
      default-data-source-name: ds0
      names: ds0
      ds0:
        type: com.zaxxer.hikari.HikariDataSource
        driver-class-name: com.mysql.jdbc.Driver
        jdbcUrl: jdbc:mysql://127.0.0.1:3306/fiforal_cw?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true&&useSSL=true
        username: root
        password: root
...

thank you it work

wang7241 avatar Aug 18 '20 04:08 wang7241

@wang7241 Please try again according to the configuration below

spring:
  shardingsphere:
    props:
      sql.show: true
    datasource:
      default-data-source-name: ds0
      names: ds0
      ds0:
        type: com.zaxxer.hikari.HikariDataSource
        driver-class-name: com.mysql.jdbc.Driver
        jdbcUrl: jdbc:mysql://127.0.0.1:3306/fiforal_cw?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true&&useSSL=true
        username: root
        password: root
...

it is means sharding tables does not work

wang7241 avatar Aug 18 '20 04:08 wang7241