InnoDB数据库死锁
场景描述
问题分析
解决方法
/**
* 2016-03-15
* linxuan
* handle deadlock while update table
*/
private void updateWithDeadLock(TestMapper mapper, Test record) throws InterruptedException {
boolean oops;
int retries = 5;
do{
oops = false;
try{
mapper.updateByPrimaryKeySelective(record);
}
catch (DeadlockLoserDataAccessException dlEx){
oops = true;
Thread.sleep((long) (Math.random() * 500));
}
finally {
}
} while(oops == true && retries-- >0);
}数据库死锁例子
Last updated