Skip to content
This repository has been archived by the owner on Jun 2, 2021. It is now read-only.

Intermittent java.sql.SQLException: Incorrect arguments to sleep. #3

Open
xgp opened this issue Jun 20, 2016 · 2 comments
Open

Intermittent java.sql.SQLException: Incorrect arguments to sleep. #3

xgp opened this issue Jun 20, 2016 · 2 comments
Labels

Comments

@xgp
Copy link

xgp commented Jun 20, 2016

I get the following exception intermittently when using the MySQLBasedQueue. I'm running MySQL 5.7.12 Community Server on Ubuntu.

I'm guessing this has something to do with the lines

nanosTimeout -= (System.nanoTime() - now);

and

s.setFloat(1, Math.round(nanosTimeout / 1000000.0) / 1000f);

which could sometimes yield a negative number, given how the JVM calculates these.

java.lang.RuntimeException: java.sql.SQLException: Incorrect arguments to sleep.
                            at net.bramp.db_patterns.locks.MySQLSleepBasedCondition.awaitNanosInternal(MySQLSleepBasedCondition.java:113)
                            at net.bramp.db_patterns.locks.MySQLSleepBasedCondition.awaitUntil(MySQLSleepBasedCondition.java:149)
                            at net.bramp.db_patterns.queues.MySQLBasedQueue.poll(MySQLBasedQueue.java:243)
Caused by: java.sql.SQLException: Incorrect arguments to sleep.
       at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
       at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3878)
       at com.mysql.jdbc.MysqlIO.nextRowFast(MysqlIO.java:2090)
       at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1964)
       at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:3306)
       at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:463)
       at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:3040)
       at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:2288)
       at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2681)
       at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2551)
       at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
       at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1192)
       at net.bramp.db_patterns.locks.MySQLSleepBasedCondition.awaitNanosInternal(MySQLSleepBasedCondition.java:96)
       ... 7 common frames omitted
@xgp
Copy link
Author

xgp commented Jun 20, 2016

I'm testing adding a second negative check at line 92, and I haven't seen the problem resurface.

if (nanosTimeout <= 0) return false;

@bramp bramp added the bug label Jun 20, 2016
@bramp
Copy link
Owner

bramp commented Jun 20, 2016

Ah yes, I think you found a bug :) Pull requests welcome.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants