El 05/08/2014 15:54, Andrus Adamchik escribió:
After years working with MySQL I stumbled on a problem for the first time that
seems rather old and common. MySQL would throw when 2 InnoDB transactions are
trying to update the same row:
com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock
found when trying to get lock; try restarting transaction
I am wondering whether we should add a “catch/restart tx” to Cayenne to handle
that. The purpose of this message is to ask how often if ever folks in the
community have to deal with this exception?
Thanks,
Andrus
I have been seen that error for a while, we use an abstract Dao
inherited by all daos so all commits use this funcion:
public void commitChanges() {
this.commitChanges(0);
}
public void commitChanges(int level) {
try {
getThreadDataContext().commitChanges();
} catch (RuntimeException cre) {
if (level < 3 &&
(cre.getCause() instanceof
MySQLTransactionRollbackException
|| cre.getCause() instanceof
com.mysql.jdbc.exceptions.MySQLTransactionRollbackException)) {
commitChanges(level+1);
} else {
CayenneCommitException cce = new
CayenneCommitException(cre, getThreadDataContext());
rollbackChanges();
throw cce;
}
}
}
Not sure if this helps or not but currently we only see like 1 of those
errors per month and I think that previously it was more frequent.