MySQL fails after awhile

Discussion in 'Plugin Development' started by peman3232, Feb 11, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    peman3232

    I'm working on a MySQL plugin but it always seems to fail even after awhile.
    The line of code that fails here runs every 30 seconds and can run hundreds of times before ultimately failing like this.
    I've looked into increasing the timeout as well as making sure a query is run at least that often and eventually my plugin still fails with

    Code:
    2013-02-11 00:04:26 [SEVERE] com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
     
    The last packet successfully received from the server was 30,013 milliseconds ago.  The last packet sent successfully to the server was 7 milliseconds ago.
    2013-02-11 00:04:26 [SEVERE]    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    2013-02-11 00:04:26 [SEVERE]    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    2013-02-11 00:04:26 [SEVERE]    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    2013-02-11 00:04:26 [SEVERE]    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    2013-02-11 00:04:26 [SEVERE]    at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
    2013-02-11 00:04:26 [SEVERE]    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
    2013-02-11 00:04:26 [SEVERE]    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3082)
    2013-02-11 00:04:26 [SEVERE]    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2968)
    2013-02-11 00:04:26 [SEVERE]    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3516)
    2013-02-11 00:04:26 [SEVERE]    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986)
    2013-02-11 00:04:26 [SEVERE]    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140)
    2013-02-11 00:04:26 [SEVERE]    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2620)
    2013-02-11 00:04:26 [SEVERE]    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2570)
    2013-02-11 00:04:26 [SEVERE]    at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:779)
    2013-02-11 00:04:26 [SEVERE]    at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:622)
    2013-02-11 00:04:26 [SEVERE]    at lib.PatPeter.SQLibrary.Database.query(Database.java:209)
    2013-02-11 00:04:26 [SEVERE]    at net.somethingsuperawesome.sqlbans.SQLBans$1.run(SQLBans.java:198)
    2013-02-11 00:04:26 [SEVERE]    at org.bukkit.craftbukkit.v1_4_R1.scheduler.CraftTask.run(CraftTask.java:53)
    2013-02-11 00:04:26 [SEVERE]    at org.bukkit.craftbukkit.v1_4_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
    2013-02-11 00:04:26 [SEVERE]    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    2013-02-11 00:04:26 [SEVERE]    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    2013-02-11 00:04:26 [SEVERE]    at java.lang.Thread.run(Unknown Source)
    2013-02-11 00:04:26 [SEVERE] Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
    2013-02-11 00:04:26 [SEVERE]    at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2529)
    2013-02-11 00:04:26 [SEVERE]    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2979)
    2013-02-11 00:04:26 [SEVERE]    ... 15 more
     
  2. Offline

    caseif

    It just seems like the plugin temporarily couldn't connect to the database. It shouldn't be too big of an issue, unless it halts the code completely. Maybe you could just restart the scheduler inside the catch block?
     
  3. Offline

    peman3232

    It doesn't break the scheduler, and missing 1 scheduled task would be fine.

    I'm testing to make sure the database is open now, but it doesn't seem to work right.

    Code:
    public boolean checkMySQL()
        {
            this.log.info(this.logPrefix + "checking mySQL");
           
            if(mysql.checkConnection())
            {
                this.log.info(this.logPrefix + "mySQL open");
                return true;
            }
            else
            {
                mysql.open();
                return mysql.checkConnection();
            }
        }
    Even when the Database connection fails it always passes the checkConnection() from SQLibrary. (It always prints "mySQL open" even when it then throws a huge error like above.)

    Once it fails once it never opens again.
     
Thread Status:
Not open for further replies.

Share This Page