You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/05/11 10:32:43 UTC

[GitHub] [shardingsphere] hongfuli opened a new issue #5531: Failed to switch schema, please terminate current transaction.

hongfuli opened a new issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531


   ## 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`:
   ```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).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] yoloz edited a comment on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
yoloz edited a comment on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-759192957


   ```java
   package org.apache.shardingsphere.proxy.backend.communication.jdbc.connection;
   public final class BackendConnection implements JDBCExecutionConnection {
    /**
        * Change schema of current channel.
        *
        * @param schemaName schema name
        */
      public void setCurrentSchema(final String schemaName) {
           //todo 临时处理
           if (!Strings.isNullOrEmpty(this.schemaName) && this.schemaName.equals(schemaName)) return;
           if (transactionStatus.isInTransaction()) {
               throw new ShardingSphereException("Failed to switch schema, please terminate current transaction.");
           }
           this.schemaName = schemaName;
       }
   }
   ```
   temporary,as the same schema return directly
   @cherrylzhao 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] 1006572352 commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
1006572352 commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-657316294


   The same error info in sqoop1.4.6+sharding-proxy-5.0.0-RC1


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] kimmking commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
kimmking commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-626646652


   what is the whole error logs in proxy console?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] hongfuli commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
hongfuli commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-636309436


   @cherrylzhao 
   Can I use a fixed version for this problem? 
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] 1006572352 edited a comment on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
1006572352 edited a comment on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-657316294


   The same error info in sqoop import with sqoop-1.4.6+sharding-proxy-5.0.0-RC1


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] yoloz removed a comment on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
yoloz removed a comment on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-759192957


   ```java
   package org.apache.shardingsphere.proxy.backend.communication.jdbc.connection;
   public final class BackendConnection implements JDBCExecutionConnection {
    /**
        * Change schema of current channel.
        *
        * @param schemaName schema name
        */
      public void setCurrentSchema(final String schemaName) {
           //todo 临时处理
           if (!Strings.isNullOrEmpty(this.schemaName) && this.schemaName.equals(schemaName)) return;
           if (transactionStatus.isInTransaction()) {
               throw new ShardingSphereException("Failed to switch schema, please terminate current transaction.");
           }
           this.schemaName = schemaName;
       }
   }
   ```
   temporary,as the same schema return directly
   @cherrylzhao 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] nimeijian commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
nimeijian commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-751921254


   When I use dataX to connect shardingproxy, I encountered the same error. I tried version 3.1.0/4.1.1/5.0.0-alpha, all have this problem.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] yoloz commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
yoloz commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-759192957


   ```java
   package org.apache.shardingsphere.proxy.backend.communication.jdbc.connection;
   public final class BackendConnection implements JDBCExecutionConnection {
    /**
        * Change schema of current channel.
        *
        * @param schemaName schema name
        */
      public void setCurrentSchema(final String schemaName) {
           //todo 临时处理
           if (!Strings.isNullOrEmpty(this.schemaName) && this.schemaName.equals(schemaName)) return;
           if (transactionStatus.isInTransaction()) {
               throw new ShardingSphereException("Failed to switch schema, please terminate current transaction.");
           }
           this.schemaName = schemaName;
       }
   }
   ```
   as the same schema can  directly return ?
   @cherrylzhao 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] anxinlong commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
anxinlong commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-966273557


   +1 this issue has been open for more than one year😂


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] cherrylzhao commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
cherrylzhao commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-626659176


   thanks for feedback, I can do some investigate for that.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jingshanglu commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-1070367662


   It maybe fixed by #14983 .


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] userkdg commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
userkdg commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-963751668


   +1 都到2021年尾了,bug还在?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] lijintaotzx commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
lijintaotzx commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-656552358


   Has the problem been solved ? I have the same problem in my django project.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] hongfuli commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
hongfuli commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-626661188


   > what is the whole error logs in proxy console?
   
   [ERROR] 17:02:22.479 [ShardingSphere-Command-3] o.a.s.s.b.c.j.c.BackendConnection - Cannot do switch, exceed maximum retry count:[5].
   [ERROR] 17:02:22.479 [ShardingSphere-Command-3] o.a.s.s.f.c.CommandExecutorTask - Exception occur:
   org.apache.shardingsphere.underlying.common.exception.ShardingSphereException: Failed to switch schema, please terminate current transaction.
           at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection.setCurrentSchema(BackendConnection.java:112)
           at org.apache.shardingsphere.shardingproxy.backend.text.admin.BroadcastBackendHandler.execute(BroadcastBackendHandler.java:50)
           at org.apache.shardingsphere.shardingproxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:73)
           at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:93)
           at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:71)
           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
           at java.lang.Thread.run(Thread.java:748)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] ssxlulu commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
ssxlulu commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-626676775


   I think sharding-proxy doesn't support the sql syntax `SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED` which ORM framework send.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jingshanglu closed issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
jingshanglu closed issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] hongfuli commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
hongfuli commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-626660916


   > console
   
   [ERROR] 17:02:22.479 [ShardingSphere-Command-3] o.a.s.s.b.c.j.c.BackendConnection - Cannot do switch, exceed maximum retry count:[5].
   [ERROR] 17:02:22.479 [ShardingSphere-Command-3] o.a.s.s.f.c.CommandExecutorTask - Exception occur:
   org.apache.shardingsphere.underlying.common.exception.ShardingSphereException: Failed to switch schema, please terminate current transaction.
           at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection.setCurrentSchema(BackendConnection.java:112)
           at org.apache.shardingsphere.shardingproxy.backend.text.admin.BroadcastBackendHandler.execute(BroadcastBackendHandler.java:50)
           at org.apache.shardingsphere.shardingproxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:73)
           at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:93)
           at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:71)
           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
           at java.lang.Thread.run(Thread.java:748)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] huangtaogege commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
huangtaogege commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-955873398


   > 当我使用dataX连接分片代理时,我遇到了同样的错误。我试过3.1.0/4.1.1/5.0.0-alpha版本,都存在这个问题。
   
    有解决么


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] yoloz commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
yoloz commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-759181211


   use dbcp2 and connection.setAutoCommit(false), get the same error, mysqlProxy version 5.0-alpha


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] ChuckPerry commented on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
ChuckPerry commented on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-643863241


   did this problem resoled? I catch same problem in qrtz frame.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] hongfuli removed a comment on issue #5531: Failed to switch schema, please terminate current transaction.

Posted by GitBox <gi...@apache.org>.
hongfuli removed a comment on issue #5531:
URL: https://github.com/apache/shardingsphere/issues/5531#issuecomment-626660916


   > console
   
   [ERROR] 17:02:22.479 [ShardingSphere-Command-3] o.a.s.s.b.c.j.c.BackendConnection - Cannot do switch, exceed maximum retry count:[5].
   [ERROR] 17:02:22.479 [ShardingSphere-Command-3] o.a.s.s.f.c.CommandExecutorTask - Exception occur:
   org.apache.shardingsphere.underlying.common.exception.ShardingSphereException: Failed to switch schema, please terminate current transaction.
           at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection.setCurrentSchema(BackendConnection.java:112)
           at org.apache.shardingsphere.shardingproxy.backend.text.admin.BroadcastBackendHandler.execute(BroadcastBackendHandler.java:50)
           at org.apache.shardingsphere.shardingproxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:73)
           at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:93)
           at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:71)
           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
           at java.lang.Thread.run(Thread.java:748)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org