Restarting transaction in MySQL after deadlock

前端 未结 4 1108
后悔当初
后悔当初 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:01

    Restarting a transaction means:

    • (Optionally) initiate a new database connection handle;
    • Execute the first function/line code which initiates a new transaction and retries the entire execution path until commit.

    Because the database engine cannot possibly know the queries which would have been executed after the deadlock occured, it cannot retry the whole thing for you (not to mention there could be application logic which would maybe execute different queries based on newly changed database data).

提交回复
热议问题