Home > Database > Mysql Tutorial > body text

What is the mysql query deadlock statement?

藏色散人
Release: 2023-02-15 10:00:50
Original
4015 people have browsed it

mysql query deadlock statement: 1. The "select * from information_schema.innodb_locks;" statement can determine whether to lock the table; 2. The "select * from information_schema.innodb_locks;" statement can query the transaction being locked; 3 , "select * from information_schema..." statement to query transactions waiting for locks, etc.

What is the mysql query deadlock statement?

The operating environment of this tutorial: Windows 10 system, MySQL version 5.7, Dell G3 computer.

What is the mysql query deadlock statement?

mysql query table deadlock statement

1. Determine whether to lock the table

select * from information_schema.innodb_locks;
Copy after login
Copy after login

2. Query the transaction being locked

select * from information_schema.innodb_locks;
Copy after login
Copy after login

3. Query transactions waiting for locks

select * from information_schema.innodb_lock_waits;
Copy after login

4. Query uncommitted transactions

select * from information_schema.innodb_trx
Copy after login

5. Query all threads

select * from information_schema.PROCESSLIST;
Copy after login

Related extensions:

Lock type

mysql lock level: page level, table level, row level

Table level lock: low overhead, fast locking; no deadlock; large locking granularity, probability of lock conflict The highest and the lowest concurrency.

Row-level locks: high overhead, slow locking; deadlocks may occur; the locking granularity is the smallest, the probability of lock conflicts is the lowest, and the concurrency is the highest.

Page lock: The cost and locking time are between table locks and row locks; deadlocks will occur; the locking granularity is between table locks and row locks, and the concurrency is average

1. Cause:

Deadlock refers to a phenomenon of two or more processes waiting for each other due to competition for resources during execution. Without external force, they will not be able to Push forward. At this time, the system is said to be in a deadlock state or the system has a deadlock. These processes that are always waiting for each other are called deadlock processes. Table-level locks will not cause deadlocks. Therefore, solving deadlocks is mainly focused on the most commonly used InnoDB.

The key to deadlock is that the order in which two (or more) Sessions are locked is inconsistent.

Then the corresponding key to solving the deadlock problem is: let different sessions be locked in order

Recommended study: "MySQL Video Tutorial"

The above is the detailed content of What is the mysql query deadlock statement?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!