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 2022/03/17 06:13:02 UTC

[GitHub] [shardingsphere] TeslaCN opened a new issue #16145: Connect to ShardingSphere-Proxy PostgreSQL by postgresql:42.3.1 caused ERROR: Failed to switch schema, please terminate current transaction

TeslaCN opened a new issue #16145:
URL: https://github.com/apache/shardingsphere/issues/16145


   ## Bug Report
   
   Connect to ShardingSphere-Proxy PostgreSQL by JDBC driver `postgresql:42.2.5` cannot reproduce this issue.
   
   ### Which version of ShardingSphere did you use?
   master - 47e6d19fae76d2d904dbf65c253dcd6a97f4ac22
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-Proxy PostgreSQL
   
   ### Expected behavior
   
   No error occur.
   
   ### Actual behavior
   
   ```
   Mar 17, 2022 2:08:19 PM org.postgresql.Driver connect
   FINE: Connecting with URL: jdbc:postgresql://127.0.0.1:55432/sbtest?prepareThreshold=1&loggerLevel=debug
   Mar 17, 2022 2:08:19 PM org.postgresql.jdbc.PgConnection <init>
   FINE: PostgreSQL JDBC Driver 42.3.1
   Mar 17, 2022 2:08:19 PM org.postgresql.jdbc.PgConnection setDefaultFetchSize
   FINE:   setDefaultFetchSize = 0
   Mar 17, 2022 2:08:19 PM org.postgresql.jdbc.PgConnection setPrepareThreshold
   FINE:   setPrepareThreshold = 1
   Mar 17, 2022 2:08:19 PM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
   FINE: Trying to establish a protocol version 3 connection to 127.0.0.1:55432
   Mar 17, 2022 2:08:19 PM org.postgresql.core.v3.ConnectionFactoryImpl tryConnect
   FINE: Receive Buffer Size is 65,536
   Mar 17, 2022 2:08:19 PM org.postgresql.core.v3.ConnectionFactoryImpl tryConnect
   FINE: Send Buffer Size is 1,313,280
   Mar 17, 2022 2:08:19 PM org.postgresql.Driver connect
   FINE: Connection error: 
   org.postgresql.util.PSQLException: ERROR: Failed to switch schema, please terminate current transaction.
   	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2674)
   	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2364)
   	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:354)
   	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:314)
   	at org.postgresql.core.SetupQueryRunner.run(SetupQueryRunner.java:55)
   	at org.postgresql.core.v3.ConnectionFactoryImpl.runInitialQueries(ConnectionFactoryImpl.java:849)
   	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:286)
   	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
   	at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:225)
   	at org.postgresql.Driver.makeConnection(Driver.java:466)
   	at org.postgresql.Driver.connect(Driver.java:265)
   	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:681)
   	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229)
   	at icu.wwj.PrepareThreshold.getConnection(PrepareThreshold.java:33)
   	at icu.wwj.PrepareThreshold.main(PrepareThreshold.java:13)
   
   Exception in thread "main" org.postgresql.util.PSQLException: ERROR: Failed to switch schema, please terminate current transaction.
   	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2674)
   	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2364)
   	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:354)
   	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:314)
   	at org.postgresql.core.SetupQueryRunner.run(SetupQueryRunner.java:55)
   	at org.postgresql.core.v3.ConnectionFactoryImpl.runInitialQueries(ConnectionFactoryImpl.java:849)
   	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:286)
   	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
   	at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:225)
   	at org.postgresql.Driver.makeConnection(Driver.java:466)
   	at org.postgresql.Driver.connect(Driver.java:265)
   	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:681)
   	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229)
   	at icu.wwj.PrepareThreshold.getConnection(PrepareThreshold.java:33)
   	at icu.wwj.PrepareThreshold.main(PrepareThreshold.java:13)
   ```
   
   ### Reason analyze (If you can)
   
   The SQL `SET extra_float_digits = 3` which will be routed to all data sources was sent after `begin`.
   
   ![image](https://user-images.githubusercontent.com/20503072/158747490-bea6a086-3161-47af-a7d0-6f3ed8ff6968.png)
   
   ![image](https://user-images.githubusercontent.com/20503072/158747515-710b712a-aee9-425e-a5a9-2fede3480326.png)
   
   ### Example codes for reproduce this issue (such as a github link).
   
   ```java
   try (Connection connection = getConnection()) {
       connection.setAutoCommit(false);
       try (PreparedStatement preparedStatement = connection.prepareStatement("/*$0*/insert into sbtest1 /* $0 */ -- $0 \n (id, k, c, pad) \r values \r\n(?, ?, 'apsbd$31a', '$99')/*$0*/ \n--$0")) {
           preparedStatement.setInt(1, -1);
           preparedStatement.setInt(2, ThreadLocalRandom.current().nextInt());
           preparedStatement.executeUpdate();
       }
       try (PreparedStatement preparedStatement = connection.prepareStatement("select * from sbtest1 where id = ?")) {
           preparedStatement.setInt(1, -1);
           try (ResultSet resultSet = preparedStatement.executeQuery()) {
               while (resultSet.next()) {
                   System.out.println("c=" + resultSet.getString("c").trim() + ", pad=" + resultSet.getString("pad").trim());
               }
           }
       }
       connection.rollback();
   }
   
   ```
   


-- 
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] tristaZero closed issue #16145: Connect to ShardingSphere-Proxy PostgreSQL by postgresql:42.3.1 caused ERROR: Failed to switch schema, please terminate current transaction

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


   


-- 
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] TeslaCN commented on issue #16145: Connect to ShardingSphere-Proxy PostgreSQL by postgresql:42.3.1 caused ERROR: Failed to switch schema, please terminate current transaction

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


   I found this issue is caused by https://github.com/pgjdbc/pgjdbc/pull/1977.


-- 
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] tristaZero closed issue #16145: Connect to ShardingSphere-Proxy PostgreSQL by postgresql:42.3.1 caused ERROR: Failed to switch schema, please terminate current transaction

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


   


-- 
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] tristaZero commented on issue #16145: Connect to ShardingSphere-Proxy PostgreSQL by postgresql:42.3.1 caused ERROR: Failed to switch schema, please terminate current transaction

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


   @TeslaCN Nice work.


-- 
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