打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Lock conflict on no wait transaction

Lock conflict on no wait transaction


This is actually not an error, but a normal exception caused by transaction management. You'll get this message when one transaction tries to update or delete a record that was changed by another transaction after the current transaction has started. It only happens when the current transaction is a NO WAIT transaction, so it doesn't wait for other transaction to finish, but rather reports the error and gives up immediately.

Please note that this is a normal event with NO WAIT transactions and your application should be prepared for it and able to deal with it. This is needed in order to maintain database consistency. Imagine for example that you have a table with record:

ID VALUE
-- -----
10 15000

Now, we have two transactions starting at approximately the same time, and both run: 

UPDATE t1 SET value = value + 20 WHERE id = 10;

You would expect the column to have value of 15040 after they both commit. But, let's take a look what happens in a real database. Transaction one reads value 15000 from the column, adds 20 and puts 15020 - it does not commit yet, but goes on to do other things. Transaction two starts, reads 15000 from the column (as transaction one did not commit yet), adds 20 and puts 15020. If there was no error raised, you would end up with value 15020 instead of 15040 in the column. However, the exception will be raised. If it's a NO WAIT transaction, the message would should up at once. On the other hand, WAIT transaction would wait for other transaction to finish before going further (if the first one rolls back) or throwing an error (if the first one commits). 

When you get such message, it often helps to change transactions from NO WAIT to WAIT, although you should investigate the issue closely as bad transaction management can lead to poor performance. 


本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
关于Lock wait timeout exceeded; try restarting transaction
总结:事务阻塞Lock wait timeout exceeded; try restarting transaction解决办法:
[Bernstein09] Section 7.6. Shadow-paging Algorithm
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction的问题解决(备忘)
MySQL的timeout那点事
Mysql事物锁等待超时 Lock wait timeout exceeded; try restarting transaction
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服