question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

insert statement error : Route table does not exist, available actual table

See original GitHub issue

Question

The table created by the DDL statement was successfully created on shardingsphere-proxy. But an error occurs when using the inset statement to insert, can you help explain what the problem is?

this is my config file

schemaName: sharding_db
dataSources:
  master_0:
    url: jdbc:mysql://192.168.80.172:23306/demo_0?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
    username: root
    password: Aa123456.
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
    minPoolSize: 1
  slave_0:
    url: jdbc:mysql://192.168.80.172:23307/demo_0?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
    username: root
    password: Aa123456.
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
    minPoolSize: 1
  master_1:
    url: jdbc:mysql://192.168.80.176:23306/demo_1?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
    username: root
    password: Aa123456.
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
    minPoolSize: 1
  slave_1:
    url: jdbc:mysql://192.168.80.176:23307/demo_1?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
    username: root
    password: Aa123456.
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
    minPoolSize: 1
rules:
  - !SHARDING
    defaultTableStrategy:
      none:
    tables:
      biz_ymcz_minclass:
        actualDataNodes: master_0.biz_ymcz_minclass_${[36]},master_1.biz_ymcz_minclass_${[41]}
        tableStrategy:
          standard:
            shardingColumn: area_code
            shardingAlgorithmName: biz_ymcz_minclass_inline
        keyGenerateStrategy:
          column: id
          keyGeneratorName: snowflake
      biz_ymcz:
        actualDataNodes: master_0.biz_ymcz_${[36]},master_1.biz_ymcz_${[41]}
        tableStrategy:
          standard:
            shardingColumn: area_code
            shardingAlgorithmName: biz_ymcz_inline
        keyGenerateStrategy:
          column: id
          keyGeneratorName: snowflake
    shardingAlgorithms:
      biz_ymcz_inline:
        type: INLINE
        props:
          algorithm-expression: biz_ymcz_${area_code[0..1]}
      biz_ymcz_minclass_inline:
        type: INLINE
        props:
          algorithm-expression: biz_ymcz_minclass_${area_code[0..1]}
    keyGenerators:
      snowflake:
        type: SNOWFLAKE

  - !READWRITE_SPLITTING
    dataSources:
      master_0: 
        type: Static
        props:
          write-data-source-name: master_0
          read-data-source-names: slave_0
      master_1: 
        type: Static
        props:
          write-data-source-name: master_1
          read-data-source-names: slave_1

The successfully created table is shown in the following figure, on two different master nodes respectively

image image

This is the error message

1997 - Runtime exception: [Route table biz_ymcz_minclass_36 does not exist, available actual table: [biz_ymcz_minclass_41]], Time: 0.049000s

The versions I have tried are 5.0.0 , 5.1.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
strongduanmucommented, Apr 12, 2022

Hi @zorohu, I found some problems from your configuration. First problem is dataSourceName in actualDataNodes. If you want to use read-write splitting feature, you need to configure read-write splitting aggregation data source with a unique name and use it in actualDataNodes. I made the following modifications to your configuration.

The second problem is that according to the sharding strategy you specified, the actual table cannot be found, and you need to adjust the sharding strategy. The current sharding strategy routes insert statements to the biz_ymcz_minclass_36 table of the ds_1 data source.

schemaName: sharding_db
dataSources:
  master_0:
    url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
    username: root
    password: 123456
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
    minPoolSize: 1
  slave_0:
    url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
    username: root
    password: 123456
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
    minPoolSize: 1
  master_1:
    url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
    username: root
    password: 123456
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
    minPoolSize: 1
  slave_1:
    url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
    username: root
    password: 123456
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
    minPoolSize: 1
rules:
- !SHARDING
  defaultTableStrategy:
    none:
  defaultDatabaseStrategy:
    none:
  tables:
    biz_ymcz_minclass:
      actualDataNodes: ds_0.biz_ymcz_minclass_${[36]},ds_1.biz_ymcz_minclass_${[41]}
      databaseStrategy:
        #none:
        standard:
          shardingColumn: area_code
          shardingAlgorithmName: area_code_database_inline
      tableStrategy:
        standard:
          shardingColumn: area_code
          shardingAlgorithmName: biz_ymcz_minclass_inline
      keyGenerateStrategy:
        column: id
        keyGeneratorName: snowflake
  shardingAlgorithms:
    area_code_database_inline:
      type: INLINE
      props:
        algorithm-expression: ds_1
    biz_ymcz_minclass_inline:
      type: INLINE
      props:
        algorithm-expression: biz_ymcz_minclass_${area_code[0..1]}

- !READWRITE_SPLITTING
  dataSources:
    ds_0:
      type: Static
      props:
        write-data-source-name: master_0
        read-data-source-names: slave_0
    ds_1:
      type: Static
      props:
        write-data-source-name: master_1
        read-data-source-names: slave_1
1reaction
zorohucommented, Apr 8, 2022

this is a simplified version of the initialization statement

CREATE TABLE `biz_ymcz_minclass` (
  `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `min_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `min_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0',
  `area_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `uq_minid` (`min_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;

INSERT INTO `biz_ymcz_minclass` VALUES ('1480067538049560578', '12345678-12345678', '123456789', '3600003');

Read more comments on GitHub >

github_iconTop Results From Across the Web

Show error message: Route table null does not exist ... - GitHub
insert data to databases and success. Actual behavior. show message: Route table null does not exist, available actual table. Reason analyze (If ...
Read more >
sql - Get table does not exist error, when trying to insert into ...
However, the table does exist and I can run queries on it and it returns the data I inserted when I created the...
Read more >
Database Engine events and errors - SQL Server
In this article. The table contains error message numbers and the description, which is the text of the error message from the sys.messages...
Read more >
MySQL 8.0 Reference Manual :: 13.2.7 INSERT Statement
In this case, a value for each named column must be provided by the VALUES list, VALUES ROW() list, or SELECT statement. For...
Read more >
ELT Insert-Select - SnapLogic Documentation - Confluence
Returns an error if any specified column name is not found in the target table. Some Source and Target Column names are identical,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found