Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to view deadlock log in MySQL

Shulou Source: shulou.com Published: 2022-06-02 11:08:44 11月15日 Update

This article introduces you how to view the deadlock log in MySQL, the content is very detailed, interested friends can refer to, hope to be helpful to you.

MySQL View deadlock Log

Under what circumstances will show engine innodb status cause deadlock?

The so-called deadlock: refers to two or more processes in the implementation process, caused by the competition for resources caused by a mutual waiting phenomenon, if there is no external force, they will not be able to move forward. At this point, it is said that the system is in a deadlock state or that the system has a deadlock. These processes that are always waiting for each other are called deadlock processes. Table-level locks do not produce deadlocks. Therefore, the solution to deadlock is mainly aimed at the most commonly used InnoDB.

Deadlock case

For example (the following session id is the primary key):

Mysql > select * from T3 where id=9 for update +-+ | id | course | name | ctime | +-+ | 9 | JX | f | 2016-03-01 11:36: 30 | +-+ row in set (0.00 sec)

Session2:

Mysql > select * from T3 where id insert into T3 values; ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction

Session2 is waiting for Session1's id=9 to lock, and session2 holds locks from 1 to 8 (note that the range of 9 to 19 is not locked by session2). Finally, session1 has to wait for session2 when inserting a new row, so a deadlock occurs.

About how to view the deadlock log in MySQL to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Deadlock log process two content more system help good function interest external force boy partner commonly used situation article case status phenomenon Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi NVidia Shulou Technology Shulou Information Apple