Restarting transaction in MySQL after deadlock

前端 未结 4 1081
后悔当初
后悔当初 2021-01-18 01:20

I am facing a deadlock in my MySQL. How can I configure MySQL to restart the transaction automatically when it encounters a deadlock?

4条回答
  •  隐瞒了意图╮
    2021-01-18 02:18

    You cannot do that automatically, as the deadlock occurred, because two transactions were trying to modify the same data. If you know that simply retrying the same statements again will be the right thing to do, you need to implement this in your application.

    However having the database do that automatically would be irresponsible, because there might just as well be cases where your application first needs to take a look at the new situation in the database, before issuing potentially modified statements, if any at all.

提交回复
热议问题