Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to distinguish between deadlock and lock waiting in MySQL

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces how to distinguish between deadlock and lock waiting in MySQL. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

[database version] MySQL5.7

Program error 1205 Lock wat timeout exceeded, thought to be deadlock, in fact, are two concepts, indicating that the deadlock monitoring module is no problem. Deadlock monitoring is a deadlock, not lock waiting.

The error message is as follows:

SQLSTATEHY000]: General error: 1205 Lock wat timeout exceeded; try restarting transaction (SQL: UPDATE xx set xxx = 1205 where id=1 and rock_id > 1)

1213 Deadlock found when trying to get lock; try restarting transaction

Https://www.cnblogs.com/tartis/p/9366574.html

Https://dev.mysql.com/doc/refman/8.0/en/innodb-deadlock-example.html

MySQL 5.7We can query lock status information with the following statement

SELECT r.trx_id waiting_trx_id, r.trx_mysql_thread_id waiting_thread, r.trx_query waiting_query, b.trx_id blocking_trx_id, b.trx_mysql_thread_id blocking_thread B.trx_query blocking_query FROM information_ schema.`INNODB _ LOCK_ WAITS` w INNER JOIN information_ schema.`INNODB _ TRX`b ON b.`trx _ id` = w.`requests _ trx_ id`INNER JOIN information_ schema.`INNODB _ T RX`r ON r.`trx _ id` = w.`requesting _ trx_ id`

MySQL8.0, we view the lock information with the following statement

Select * from * innocent database lockout waits; this is all about how to distinguish between deadlocks and lock waits in MySQL. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report