Bug #102791 | A deadlock occurs one innodb tables between unrelated rows | ||
---|---|---|---|
Submitted: | 3 Mar 2021 5:03 | Modified: | 4 Mar 2021 16:02 |
Reporter: | HULONG CUI | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 5.7.30 GA | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[3 Mar 2021 5:03]
HULONG CUI
[3 Mar 2021 15:57]
MySQL Verification Team
Hi Mr. jacky, Thank you for your bug report. However, this is not a bug. When you are using transactional database systems, with multiple connections running, getting a deadlock is a proof that MySQL with InnoDB storage engine, functions absolutely correctly. Deadlocks happen when one thread is holding lock on row A , while asking for a lock on row B. In the same time another thread is holding a lock on the row B, while asking for a lock on the row A. Hence , a deadlock. Standard defines that in these cases all involved transactions (and there can be N of those in a graph) should be immediately rolled back. It is then on the application developer to resubmit those transactions again. Hence, not a bug.
[4 Mar 2021 7:27]
HULONG CUI
Understand the deadlocks occur,but two session sql not have same condition. sql1: DELETE FROM `PROCESS_CONTEXT` WHERE ID = 193275447 sql2: UPDATE `PROCESS_CONTEXT` SET ... WHERE ID = 193274884 why sql2 is RECORD LOCKS space id 36 page no 13097 n bits 144
[4 Mar 2021 13:23]
MySQL Verification Team
Hi Mr. jacky, Conditions are not what is important. The relevant info is that both queries are accessing the same record. For the further diagnosis , you should look carefully at the EXPLAIN of the DMLs.
[4 Mar 2021 16:02]
HULONG CUI
1) explain DELETE FROM `PROCESS_CONTEXT` WHERE ID = 193275447; +----+-------------+-----------------+------------+-------+---------------+---------+---------+-------+------+----------+-------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-----------------+------------+-------+---------------+---------+---------+-------+------+----------+-------------+ | 1 | DELETE | PROCESS_CONTEXT | NULL | range | PRIMARY | PRIMARY | 8 | const | 1 | 100.00 | Using where | +----+-------------+-----------------+------------+-------+---------------+---------+---------+-------+------+----------+-------------+ 2)explain UPDATE `PROCESS_CONTEXT` SET `SID` = 'ai15e7180c0a5446f0b6b733ea0428ee13', `KEY` = 'currentNodeId', `VALUE` = '1683', `SOURCE` = 'CALL', `LAST_UPDATOR` = null, `CODE` = null WHERE ID = 193274884; +----+-------------+-----------------+------------+-------+---------------+---------+---------+-------+------+----------+-------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-----------------+------------+-------+---------------+---------+---------+-------+------+----------+-------------+ | 1 | UPDATE | PROCESS_CONTEXT | NULL | range | PRIMARY | PRIMARY | 8 | const | 1 | 100.00 | Using where | +----+-------------+-----------------+------------+-------+---------------+---------+---------+-------+------+----------+-------------+
[4 Mar 2021 16:02]
HULONG CUI
1) explain DELETE FROM `PROCESS_CONTEXT` WHERE ID = 193275447; +----+-------------+-----------------+------------+-------+---------------+---------+---------+-------+------+----------+-------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-----------------+------------+-------+---------------+---------+---------+-------+------+----------+-------------+ | 1 | DELETE | PROCESS_CONTEXT | NULL | range | PRIMARY | PRIMARY | 8 | const | 1 | 100.00 | Using where | +----+-------------+-----------------+------------+-------+---------------+---------+---------+-------+------+----------+-------------+ 2)explain UPDATE `PROCESS_CONTEXT` SET `SID` = 'ai15e7180c0a5446f0b6b733ea0428ee13', `KEY` = 'currentNodeId', `VALUE` = '1683', `SOURCE` = 'CALL', `LAST_UPDATOR` = null, `CODE` = null WHERE ID = 193274884; +----+-------------+-----------------+------------+-------+---------------+---------+---------+-------+------+----------+-------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-----------------+------------+-------+---------------+---------+---------+-------+------+----------+-------------+ | 1 | UPDATE | PROCESS_CONTEXT | NULL | range | PRIMARY | PRIMARY | 8 | const | 1 | 100.00 | Using where | +----+-------------+-----------------+------------+-------+---------------+---------+---------+-------+------+----------+-------------+
[5 Mar 2021 13:13]
MySQL Verification Team
We're sorry, but the bug system is not the appropriate forum for asking help on using MySQL products. Your problem is not the result of a bug. For details on getting support for MySQL products see http://www.mysql.com/support/ You can also check our forums (free) at http://forums.mysql.com/ Thank you for your interest in MySQL.