Closed win-ho closed 2 years ago
it works normally with the same configurations at version 5.1.1
it works normally with the same configurations at version 5.1.1
me too
Can you provide a demo to reproduce this bug?
Can you provide a demo to reproduce this bug?
Sure. Is it zip package ok ?
@win-ho Ok, you can push demo to your github repository, and paste link here.
application.yml:
spring:
shardingsphere:
props:
sql-show: true
datasource:
names: ds1,ds2
ds1:
driver-class-name: com.mysql.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
jdbc-url: jdbc:mysql://x.x.x.x:3306/course_db?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
username: xxx
password: xxx
ds2:
driver-class-name: com.mysql.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
jdbc-url: jdbc:mysql://xx.xx.xx.xx:3306/course_db?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
username: xxx
password: xxx
mode:
overwrite: false
type: Cluster
repository:
type: ZooKeeper
props:
namespace: shardingsphere-rw
retryIntervalMilliseconds: 500
server-lists: zoo1:2181,zoo2:2182,zoo3:2183
timeToLiveSeconds: 60
rules:
readwrite-splitting:
data-sources:
ds:
type: Static
load-balancer-name: my_lb
props:
write-data-source-name: ds1
read-data-source-names: ds2
load-balancers:
my_lb:
type: ROUND_ROBIN
sharding:
key-generators:
snowflake:
type: SNOWFLAKE
sharding-algorithms:
hl-course-inline:
type: INLINE
props:
algorithm-expression: hl_course_$->{cid % 2 + 1}
tables:
hl_course:
actual-data-nodes: ds.hl_course_$->{1..2}
key-generate-strategy:
column: cid
key-generator-name: snowflake
table-strategy:
standard:
sharding-algorithm-name: hl-course-inline
sharding-column: cid
#----------------------log---------------------------
logging:
level:
org.apache.shardingsphere: debug
#----------------------mybatisplus---------------------------
mybatis-plus:
print-sql: true
configuration:
cache-enabled: false
map-underscore-to-camel-case: true
use-generated-keys: true
default-statement-timeout: 600
global-config:
banner: false
db-config:
table-prefix: hl_
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.atguigu</groupId>
<artifactId>shardingjdbcdemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>shardingjdbcdemo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
<version>5.1.2</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Error Message:
I find that,maybe it's not a bug! but still, it got some confusing problems.
I just found a directory which named .shardingsphere
in my project directory. it worked normally after I delete this directory!
I truely config the physical table table_0
and table_1
(test-db.student$->{0..1}) in first time! but I did not notice that a directory was generated in my project. And then I config phsical tables (`test-db.student$->{0..2}`), and rerun my project, error which I just issued just occured.
Thanks for your reminder, it's work for me when I deleted shardingsphere-rw
directory from zookeeper.
I just found a directory which named
.shardingsphere
in my project directory. it worked normally after I delete this directory!
This is a cluster mode, it will store config file to .shardingsphere
directory.
@win-ho So, can you close this issue now?
@win-ho So, can you close this issue now?
OK
I just found a directory which named
.shardingsphere
in my project directory. it worked normally after I delete this directory!This is a cluster mode, it will store config file to
.shardingsphere
directory.
But still, I want to know that why it worked abnormally in 5.1.2, but not in 5.1.1 without deleting .shardingsphere
?
I truely config the physical table table_0 and table1 (test-db.student$->{0..1}) in first time! but I did not notice that a directory was generated in my project. And then I config phsical tables (test-db.student_$->{0..2}), and rerun my project, error which I just issued just occured.
Maybe you can set overwrite: true
.
I truely config the physical table table_0 and table_1 (test-db.student_Missing superscript or subscript argument
$->{0..1}) in first time! but I did not notice that a directory was generated in my project. And then I config phsical tables (test-db.student_$->{0..2}), and rerun my project, error which I just issued just occured.
Maybe you can set
overwrite: true
.
Thanks for your advice
As it shows, I have configured the logic table
student
with 3 physic tables:student_0
,student_1
andstudent_2
. But it does not work when inserting data intostudent_2
. And it reminds me thatstudent_2
does not exist.