Bug #92169 When connection is initializing, the jdbc 's maxAllowedPacket is -1
Submitted: 24 Aug 2018 2:53 Modified: 28 Sep 2018 16:18
Reporter: Long Su Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1.44 OS:CentOS
Assigned to: Filipe Silva CPU Architecture:x86

[24 Aug 2018 2:53] Long Su
Description:
1 The tomcat jdbc tries to reconnect
2 The jdbc driver executes " set sql_mod= ...", and gets warnings.
2 The jdbc driver executes "show warnings", but maxAllowedPacket is -1 ,and PacketTooBigException is thrown.

Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (27 > -1). You can change this value on the server by setting the max_allowed_packet' variable.
        at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:577)
        at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:417)
        at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:3112)
        at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:2341)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2736)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2483)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2441)
        at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1381)
        at com.mysql.jdbc.SQLError.convertShowWarningsToSQLWarnings(SQLError.java:704)
        at com.mysql.jdbc.MysqlIO.scanForAndThrowDataTruncation(MysqlIO.java:4188)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2804)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2483)
        at com.mysql.jdbc.ConnectionImpl.setupServerForTruncationChecks(ConnectionImpl.java:5150)
        at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3393)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2235)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2017)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:779)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
        at sun.reflect.GeneratedConstructorAccessor26.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:389)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
        at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:310)
        at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203)
        at org.apache.tomcat.jdbc.pool.PooledConnection.reconnect(PooledConnection.java:361)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:821)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:651)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:198)
        at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:132)
        at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
        at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:225)
        at com.sun.proxy.$Proxy57.prepareStatement(Unknown Source)
        at org.jooq.impl.ProviderEnabledConnection.prepareStatement(ProviderEnabledConnection.java:112)
        at org.jooq.impl.SettingsEnabledConnection.prepareStatement(SettingsEnabledConnection.java:76)
        at org.jooq.impl.AbstractResultQuery.prepare(AbstractResultQuery.java:232)
        at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:322)

How to repeat:
tomcat jdbc
mysql 5.7
mysql jdbc driver 5.1.44
[24 Aug 2018 7:02] Long Su
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.51b Source distribution
[28 Aug 2018 16:18] Filipe Silva
Hi Long Su,

Thank you for your interest in MySQL and Connector/J.

What is it? Are you connecting to a MySQL 5.7 or some other 5.0 server?

I failed to reproduce this with Connector/J 5.1.44 and latest MySQL 5.7.

Please update your Connector/J driver to latest version and provide more info if the problem persists. We'd also need some details about connection properties used and so. If possible, please also provide a test case without using Tomcat in the middle to reproduce this issue.

Thanks
[29 Sep 2018 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".