Mysql low_priority for innodb:选择死锁时应该回滚哪个查询
我有一组两个查询,偶尔会出现死锁。
一种是只需要偶尔运行的离线查询。我想要某种方法让 innodb 在发生死锁时更愿意回滚这个查询,而不是另一个,有点像 low_priority 关键字对 myisam 的工作方式。
有什么方法可以告诉 innodb 在发生死锁时回滚给定的查询是相对可以的吗?
I have a set of two queries which I've occasionally seen deadlocking.
One is an offline query that only needs to be run occasionally. I'd like some way to have innodb prefer to roll this query back in the event of a deadlock and not the other, sort of like the way the low_priority keyword works for myisam.
Is there any way to tell innodb that it's relatively ok to roll back a given query in the event of a deadlock?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
回答你的问题:不,没有办法。
只要前台进程不死锁,你可以尝试提前获取所有锁吗? (选择...进行更新)。
另一种选择是更改后台进程以与前台进程相同的顺序获取锁。
To answer your question: no, there is no way.
As long as foreground processes aren't deadlocking foreground processes, you could try acquiring all locks in advance? (SELECT ... FOR UPDATE).
The other option is to change the background process to acquire locks in the same order as the foreground process.
MySQL 论坛提供了一个解决方案通过更新(更多)虚拟行来赋予事务更高的优先级。
There's a work-around solution from the MySQL forums to give a transaction a higher priority by making it update (more) dummy rows.