You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "sandynz (via GitHub)" <gi...@apache.org> on 2023/02/19 11:08:23 UTC

[GitHub] [shardingsphere] sandynz opened a new issue, #24243: Proxy with MySQL protocol respond invalid server variable value cause MariaDB java client connect to proxy failed

sandynz opened a new issue, #24243:
URL: https://github.com/apache/shardingsphere/issues/24243

   ## Feature Request
   
   ### Is your feature request related to a problem?
   Yes
   
   ### Describe the feature you would like.
   There's branch database type, e.g. MariaDBDatabaseType, its trunk database is MySQL.
   
   Currently, there's no branch database pipeline job E2E, I'm trying to add one. I found some error when testing.
   
   MariaDB 10.11 is installed on local docker.
   
   MariaDB JDBC driver dependency:
   ```
               <dependency>
                   <groupId>org.mariadb.jdbc</groupId>
                   <artifactId>mariadb-java-client</artifactId>
                   <version>2.7.8</version>
               </dependency>
   ```
   
   mysql-connecter version is 5.1.47.
   
   Test code:
   ```
   public class MariaDBClientTest {
       
       public static void main(String[] args) throws Exception {
           // port 3306 is MariaDB, port 3307 is proxy
           try (Connection connection = DriverManager.getConnection("jdbc:mariadb://localhost:3307", "root", "root");
                Statement statement = connection.createStatement()) {
               ResultSet resultSet = statement.executeQuery("SELECT now()");
               resultSet.next();
               Object now = resultSet.getObject(1);
               System.out.println("now=" + now);
           }
       }
   }
   ```
   
   It works when connection with `jdbc:mariadb://localhost:3306` or `jdbc:mysql://localhost:3306`.
   
   When connecting with `jdbc:mariadb://localhost:3307`, there's exception:
   ```
   Exception in thread "main" java.lang.NumberFormatException: For input string: ""
   	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
   	at java.base/java.lang.Integer.parseInt(Integer.java:662)
   	at java.base/java.lang.Integer.parseInt(Integer.java:770)
   	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.postConnectionQueries(AbstractConnectProtocol.java:908)
   	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.createConnection(AbstractConnectProtocol.java:610)
   	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1399)
   	at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:635)
   	at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:150)
   	at org.mariadb.jdbc.Driver.connect(Driver.java:89)
   	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
   	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
   	at MariaDBClientTest.main(MariaDBClientTest.java:10)
   ```
   Related code in `org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol`:
   ```
   writer.setMaxAllowedPacket(Integer.parseInt(serverData.get("max_allowed_packet")));
   ```
   
   When connecting with `jdbc:mysql://localhost:3307`, there's warning log:
   ```
   Sun Feb 19 18:59:21 CST 2023 WARN: Invalid value '' for server variable named 'auto_increment_increment', falling back to sane default of '1'.
   Sun Feb 19 18:59:21 CST 2023 WARN: Invalid value '' for server variable named 'max_allowed_packet', falling back to sane default of '-1'.
   Sun Feb 19 18:59:21 CST 2023 WARN: Invalid value '' for server variable named 'net_buffer_length', falling back to sane default of '16,384'.
   ```
   
   Maybe proxy respond invalid server variable to client.
   


-- 
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.apache.org

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


[GitHub] [shardingsphere] TeslaCN commented on issue #24243: Proxy with MySQL protocol respond invalid server variable value cause MariaDB java client connect to proxy failed

Posted by "TeslaCN (via GitHub)" <gi...@apache.org>.
TeslaCN commented on issue #24243:
URL: https://github.com/apache/shardingsphere/issues/24243#issuecomment-1519341575

   Hi @sandynz 
   I could not reproduce this issue. I used ShardingSphere-Proxy 7caa7c490a56cedc1c2267389bcdf49e689a314c with the following configuration.
   ```
   schemaName: freedom
   
   dataSources:
     ds_0:
       url: jdbc:mysql://127.0.0.1:3310/freedom
       username: root
       password: root
       connectionTimeoutMilliseconds: 1000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 128
       minPoolSize: 0
   
   rules: []
   ```
   
   I've checked source code of `mariadb-java-client` 2.7.8 and 3.1.3. But found nothing about querying variable `net_buffer_length`.
   
   https://github.com/mariadb-corporation/mariadb-connector-j/search?q=net_buffer_length
   


-- 
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] strongduanmu commented on issue #24243: Proxy with MySQL protocol respond invalid server variable value cause MariaDB java client connect to proxy failed

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on issue #24243:
URL: https://github.com/apache/shardingsphere/issues/24243#issuecomment-1436905748

   @TeslaCN Can you help investigate this issue?


-- 
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 closed issue #24243: Proxy with MySQL protocol respond invalid server variable value cause MariaDB java client connect to proxy failed

Posted by "TeslaCN (via GitHub)" <gi...@apache.org>.
TeslaCN closed issue #24243: Proxy with MySQL protocol respond invalid server variable value cause MariaDB java client connect to proxy failed
URL: https://github.com/apache/shardingsphere/issues/24243


-- 
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 #24243: Proxy with MySQL protocol respond invalid server variable value cause MariaDB java client connect to proxy failed

Posted by "TeslaCN (via GitHub)" <gi...@apache.org>.
TeslaCN commented on issue #24243:
URL: https://github.com/apache/shardingsphere/issues/24243#issuecomment-1519345168

   I think this issue has been fixed by #25265.


-- 
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 #24243: Proxy with MySQL protocol respond invalid server variable value cause MariaDB java client connect to proxy failed

Posted by "TeslaCN (via GitHub)" <gi...@apache.org>.
TeslaCN commented on issue #24243:
URL: https://github.com/apache/shardingsphere/issues/24243#issuecomment-1519344899

   If `proxy-mysql-default-version` GTE `5.7`, the following error would occurred when using `mysql-connector-java` to connect ShardingSphere-Proxy with MariaDB backend.
   ```
   Exception in thread "main" java.sql.SQLException: (conn=47) Unknown system variable 'transaction_isolation'
   	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)
   	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3933)
   	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3869)
   	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2524)
   	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2675)
   	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2465)
   	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2439)
   	at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1365)
   	at com.mysql.jdbc.ConnectionImpl.loadServerVariables(ConnectionImpl.java:3767)
   	at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3196)
   	at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2233)
   	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2015)
   	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:768)
   	at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
   	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
   	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
   	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
   	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
   	at com.mysql.jdbc.Util.handleNewInstance(Util.java:403)
   	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:385)
   	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:323)
   	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:681)
   	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229)
   	at icu.wwj.hello.jdbc.mariadb.MariaClientTest.main(MariaClientTest.java:12)
   ```


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