Home >Database >Mysql Tutorial >What is the mysql query deadlock statement?

What is the mysql query deadlock statement?

藏色散人
藏色散人Original
2023-02-15 10:00:504310browse

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;

2. Query the transaction being locked

select * from information_schema.innodb_locks;

3. Query transactions waiting for locks

select * from information_schema.innodb_lock_waits;

4. Query uncommitted transactions

select * from information_schema.innodb_trx

5. Query all threads

select * from information_schema.PROCESSLIST;

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!

Statement:
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 admin@php.cn