Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shardingsphere insert statement error : Route table does not exist #33784

Open
BroFanta opened this issue Nov 24, 2024 · 0 comments
Open

shardingsphere insert statement error : Route table does not exist #33784

BroFanta opened this issue Nov 24, 2024 · 0 comments

Comments

@BroFanta
Copy link

Question

I first set up MySQL on port 3306 and created a database named dis_database0. Then, I set up MySQL2 on port 3308 and created another database named dis_database1. After that, I used ShardingSphere (port 3307) to connect these two databases. When I created the table HuangHStu in ShardingSphere, corresponding sharded tables were automatically generated in both databases. However, when executing an INSERT statement, an error occurs. Please help me resolve this issue.

Version information

shardingsphere:apache-shardingsphere-5.4.1
mysql:8.0.40

config-sharding.yaml

databaseName: sharding_db
 
dataSources:
  ds_0:
    url: jdbc:mysql://127.0.0.1:3306/dis_database0?serverTimezone=UTC&useSSL=false
    username: root
    password: root
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
    minPoolSize: 1
  ds_1:
    url: jdbc:mysql://127.0.0.1:3308/dis_database1?serverTimezone=UTC&useSSL=false
    username: root
    password: root
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
    minPoolSize: 1
rules:
- !SHARDING
  tables:
    HuangHStu:
      actualDataNodes: ds_${0..1}.HuangHStu
      tableStrategy:
        standard:
          shardingColumn: Sno
          shardingAlgorithmName: Sno_inline
    HuangHSC:
      actualDataNodes: ds_${0..1}.HuangHSC
      tableStrategy:
        standard:
          shardingColumn: Sno
          shardingAlgorithmName: Sno_inline
  bindingTables:
    - HuangHStu,HuangHSC
  defaultDatabaseStrategy:
    none:
  defaultTableStrategy:
    none:
  shardingAlgorithms:
    Sno_inline:
      type: INLINE
      props:
        algorithm-expression: ds_${(Sno % 2).abs()}
- !BROADCAST
  tables:
   - HuangHCou

Series of operations

I executed the following CREATE TABLE operation in sharding_db.

CREATE TABLE if not exists HuangHStu (
    Sno INT PRIMARY KEY,          -- 学号,主键,长度最多为6
    Sname VARCHAR(50) NOT NULL,         -- 姓名,不允许为空
    Sdept VARCHAR(100),                 -- 学院
    Stel VARCHAR(15),                   -- 联系方式,建议格式为手机或电话号码
    Sex CHAR(1) CHECK (Sex IN ('M', 'F')), -- 性别,仅允许 'M'(男)或 'F'(女)
    Sage INT, -- 年龄,范围在 0-150
    Saddr VARCHAR(200),                 -- 家庭住址
    Spost VARCHAR(10)                   -- 邮编
);

The subsequent database state is shown in the image.
image
image
Next, I executed the following INSERT operation in HuangHStu within sharding_db.

INSERT INTO HuangHStu (Sno, Sname, Sdept, Stel, Sex, Sage, Saddr, Spost)
VALUES 
(100001, '张三', '计算机学院', '13812345678', 'M', 20, '四川省成都市青羊区', '610000');

An error occurred while executing the INSERT operation.

Error details

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants