Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-34

AssertionError is thrown from PacketOutputStream when server goes away

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1.3
    • Component/s: None
    • Labels:
      None

      Description

      When I call Connection::close(), I get an AssertionError from PacketOutputStream. Disabling assertions doesn't work because these exceptions are for some reason thrown explicitly and on purpose. Please change these to common catchable/swallowable exceptions. I am now having to catch this specifically (or worse Throwable which gets things like OutOfMemoryError) when trying to swallow exceptions on close().

      Here is a stack trace with c3p0:

      java.lang.AssertionError: Last packet not finished
              at org.mariadb.jdbc.internal.common.packet.PacketOutputStream.startPacket(PacketOutputStream.java:38)
              at org.mariadb.jdbc.internal.common.packet.commands.ClosePacket.send(ClosePacket.java:66)
              at org.mariadb.jdbc.internal.mysql.MySQLProtocol.close(MySQLProtocol.java:563)
              at org.mariadb.jdbc.internal.mysql.MySQLProtocol.close(MySQLProtocol.java:600)
              at org.mariadb.jdbc.MySQLConnection.close(MySQLConnection.java:249)
              at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:549)
              at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:234)
              at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:470)
              at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:964)
              at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
      

      It can happen elsewhere:

      java.lang.AssertionError: Last packet not finished
              at org.mariadb.jdbc.internal.common.packet.PacketOutputStream.startPacket(PacketOutputStream.java:38)
              at org.mariadb.jdbc.internal.common.packet.commands.StreamedQueryPacket.send(StreamedQueryPacket.java:76)
              at org.mariadb.jdbc.internal.mysql.MySQLProtocol.executeQuery(MySQLProtocol.java:789)
              at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:282)
              at org.mariadb.jdbc.MySQLStatement.executeQuery(MySQLStatement.java:302)
              at org.mariadb.jdbc.MySQLStatement.executeQuery(MySQLStatement.java:361)
              at org.mariadb.jdbc.MySQLConnection.getAutoCommit(MySQLConnection.java:199)
              at com.mchange.v2.c3p0.impl.C3P0ImplUtils.resetTxnState(C3P0ImplUtils.java:270)
              at com.mchange.v2.c3p0.impl.NewPooledConnection.reset(NewPooledConnection.java:388)
              at com.mchange.v2.c3p0.impl.NewPooledConnection.markClosedProxyConnection(NewPooledConnection.java:362)
              at com.mchange.v2.c3p0.impl.NewProxyConnection.close(NewProxyConnection.java:1246)
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              mraeholling Marissa Hollingsworth added a comment -

              Does anyone know what may cause the second case mentioned in the description? The exception seems to occur frequently when the setAutoCommit command is executed.

              Caused by: java.lang.AssertionError: Last packet not finished
              at org.mariadb.jdbc.internal.common.packet.PacketOutputStream.startPacket(PacketOutputStream.java:38)
              at org.mariadb.jdbc.internal.common.packet.commands.StreamedQueryPacket.send(StreamedQueryPacket.java:76)
              at org.mariadb.jdbc.internal.mysql.MySQLProtocol.executeQuery(MySQLProtocol.java:898)
              at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:282)
              at org.mariadb.jdbc.MySQLStatement.executeUpdate(MySQLStatement.java:317)
              at org.mariadb.jdbc.MySQLStatement.executeUpdate(MySQLStatement.java:349)
              at org.mariadb.jdbc.MySQLConnection.setAutoCommit(MySQLConnection.java:188)
              at org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331)
              at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317)
              at $Proxy98.setAutoCommit(Unknown Source)

              Show
              mraeholling Marissa Hollingsworth added a comment - Does anyone know what may cause the second case mentioned in the description? The exception seems to occur frequently when the setAutoCommit command is executed. Caused by: java.lang.AssertionError: Last packet not finished at org.mariadb.jdbc.internal.common.packet.PacketOutputStream.startPacket(PacketOutputStream.java:38) at org.mariadb.jdbc.internal.common.packet.commands.StreamedQueryPacket.send(StreamedQueryPacket.java:76) at org.mariadb.jdbc.internal.mysql.MySQLProtocol.executeQuery(MySQLProtocol.java:898) at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:282) at org.mariadb.jdbc.MySQLStatement.executeUpdate(MySQLStatement.java:317) at org.mariadb.jdbc.MySQLStatement.executeUpdate(MySQLStatement.java:349) at org.mariadb.jdbc.MySQLConnection.setAutoCommit(MySQLConnection.java:188) at org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331) at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317) at $Proxy98.setAutoCommit(Unknown Source)
              Hide
              wlad Vladislav Vaintroub added a comment -

              One of possible causes is that server has shut down or connection was killed, or inactivity timeout was reached, and as reasult socket was closed on the server side.

              Show
              wlad Vladislav Vaintroub added a comment - One of possible causes is that server has shut down or connection was killed, or inactivity timeout was reached, and as reasult socket was closed on the server side.

                People

                • Assignee:
                  wlad Vladislav Vaintroub
                  Reporter:
                  cretz Chad Retz
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 30 minutes
                    30m