shardingsphere: Failed to switch schema, please terminate current transaction.

Bug Report

Which version of ShardingSphere did you use?

4.1.0

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

Sharding-Proxy

Steps to reproduce the behavior

My project developed by Django wants to connect mysql proxy, errors are always reported when initializing the connection, but after the initialization is complete, it can continue to work fine.

I used wireshark to grab the data package that initialized the connection process(the login process is omitted):

SET AUTOCOMMIT = 0
SELECT @@SQL_AUTO_IS_NULL
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED

get error response: 2Unknown exception: [Failed to switch schema, please terminate current transaction.]

the content of config-sharding.yaml:

schemaName: sharding_db

dataSources:
  ds_0:
    url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
    username: root
    password: admin
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
  ds_1:
    url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
    username: root
    password: admin
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50

shardingRule:
  tables:
    t_order:
      actualDataNodes: ds_${0..1}.t_order_${0..1}
      tableStrategy:
        inline:
          shardingColumn: order_id
          algorithmExpression: t_order_${order_id % 2}
      keyGenerator:
        type: SNOWFLAKE
        column: order_id
    t_order_item:
      actualDataNodes: ds_${0..1}.t_order_item_${0..1}
      tableStrategy:
        inline:
          shardingColumn: order_id
          algorithmExpression: t_order_item_${order_id % 2}
      keyGenerator:
        type: SNOWFLAKE
        column: order_item_id
  bindingTables:
    - t_order,t_order_item
  defaultDatabaseStrategy:
    inline:
      shardingColumn: user_id
      algorithmExpression: ds_${user_id % 2}
  defaultTableStrategy:
    none:

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

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 30 (22 by maintainers)

Most upvoted comments

Will the issue be resolved in the 5 milestone or 4.1.x version? I hope to solve it as soon as possible because I need it urgently 😃