I am Working around MySQL error “Deadlock found when trying to get lock; try restarting transaction”
I found out that the transaction can be safely reattempted
Deadlocks are not dangerous. Just try again.
http://dev.mysql.com/doc/refman/5.0/en/innodb-deadlocks.html
There was a single "super insert..select" statement that inserted into the bottleneck table after selecting a joined combo of two other tables and using sub-statements conditions on the bottleneck table as well as a few tiny tables.
The bottle neck was "waiting for lock", it was waiting for write lock no doubt. InnoDB seemed the perfect fit. (for write-heavy table) And the hesitations on this one statement are now all gone.
But now the problem arises: For every 100 executions of the statement, about 1 or 2 of them will fail because of the deadlock. I believe the deadlock only occurs between instances of the "super insert..select". I will install an auto retry of that statement, but I wondered
Question: Does MySQL JDBC have an option to turn on auto-retry of statements after receiving the exception, or do I have to write my own code for that?
com.mysql.jdbc.exceptions.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
In this case, I do not have start transaction or stop transaction commands. Just that one "super insert..select" statement