Bug #116459 | Deadlocks in transaction using Insert Ignore Statements post Upgrade to Mysql 8 | ||
---|---|---|---|
Submitted: | 23 Oct 12:01 | Modified: | 23 Oct 13:04 |
Reporter: | Kishan Kumar | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 8.0.28 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | mysql8 |
[23 Oct 12:01]
Kishan Kumar
[23 Oct 12:13]
Kishan Kumar
The schema name shows "masters" in the lock information instead of "datalocktest", please ignore this typo of database schema name. "datalocktest" was just a representible name for creating the bug report.
[23 Oct 12:39]
MySQL Verification Team
Hi Mr. Kumar, Thank you for your bug report. However, it is not a bug. First of all, you are not getting any deadlocks. You are only getting timeout on waiting for the lock. InnoDB Storage Engine is a very safe engine and it follows all the standards necessary for the safe transactional engines. Regardless of whether you set IGNORE or not, all locks have to be respected. The fact that you get lock wait timeout, means that InnoDB is functioning properly and in accordance with MVCC standards. Do not forget that you can always tune lock_wait_timeout, as described in our Reference Manual. In short, this is not a bug, this is expected , standardised behaviour that only proves that InnoDB is in compliance with all safety standards. It is possible that earlier versions have not been fully compliant, but this is fixed now ..... Not a bug.
[23 Oct 12:50]
Kishan Kumar
Some More insights. Locks Info post Session 1 transaction insertion with duplicate UNIQUE Key SELECT ENGINE_TRANSACTION_ID,OBJECT_NAME,INDEX_NAME,LOCK_TYPE,LOCK_MODE,LOCK_STATUS,LOCK_DATA FROM performance_schema.data_locks; +-----------------------+-------------+------------+-----------+-----------+-------------+------------------------+ | ENGINE_TRANSACTION_ID | OBJECT_NAME | INDEX_NAME | LOCK_TYPE | LOCK_MODE | LOCK_STATUS | LOCK_DATA | +-----------------------+-------------+------------+-----------+-----------+-------------+------------------------+ | 2178 | products | NULL | TABLE | IX | GRANTED | NULL | | 2178 | products | sku | RECORD | S | GRANTED | 'sku1', 1, 100 | | 2178 | products | PRIMARY | RECORD | X | GRANTED | supremum pseudo-record | +-----------------------+-------------+------------+-----------+-----------+-------------+------------------------+ 3 rows in set (0.00 sec) Locks Info post Session 2 transaction insertion with different uniqe dataset SELECT ENGINE_TRANSACTION_ID,OBJECT_NAME,INDEX_NAME,LOCK_TYPE,LOCK_MODE,LOCK_STATUS,LOCK_DATA FROM performance_schema.data_locks; +-----------------------+-------------+------------+-----------+--------------------+-------------+------------------------+ | ENGINE_TRANSACTION_ID | OBJECT_NAME | INDEX_NAME | LOCK_TYPE | LOCK_MODE | LOCK_STATUS | LOCK_DATA | +-----------------------+-------------+------------+-----------+--------------------+-------------+------------------------+ | 2179 | products | NULL | TABLE | IX | GRANTED | NULL | | 2179 | products | PRIMARY | RECORD | X,INSERT_INTENTION | WAITING | supremum pseudo-record | | 2178 | products | NULL | TABLE | IX | GRANTED | NULL | | 2178 | products | sku | RECORD | S | GRANTED | 'sku1', 1, 100 | | 2178 | products | PRIMARY | RECORD | X | GRANTED | supremum pseudo-record | +-----------------------+-------------+------------+-----------+--------------------+-------------+------------------------+ 5 rows in set (0.00 sec) We see that the second transaction is on Waiting state to acquire the lock ENGINE_TRANSACTION_ID | OBJECT_NAME | INDEX_NAME | LOCK_TYPE | LOCK_MODE | LOCK_STATUS | LOCK_DATA | +-----------------------+-------------+------------+-----------+--------------------+-------------+------------------------+ | 2179 | products | NULL | TABLE | IX | GRANTED | NULL | | 2179 | products | PRIMARY | RECORD | X,INSERT_INTENTION | WAITING | supremum pseudo-record |
[23 Oct 13:02]
MySQL Verification Team
Hi Mr. Kumar, These are not duplicate unique indices. These are just several locks on the single row , including gap locks. Not a bug.
[23 Oct 13:03]
Kishan Kumar
Thanks Mysql Team for the quick response. We would like to know some more insights into this change since its a drastic change which we are seeing post migration in our Production databases. Can we have some documentation around what change was done and what was the issue which was resolved using this fix. We would also like to know some information on lock changes. Is there any ,mysql documentation link which can be provided for further analysis
[23 Oct 13:04]
Kishan Kumar
Also please let us know if there is any flag to turn off this behaviour.
[23 Oct 13:26]
MySQL Verification Team
Hi Mr. Kumar, First of all, InnoDB is a transactional storage engine and there is no flag by which you can turn it into something else, like non-transactional SE. Second, changes that were made to InnoDB were due to the bugs. Some of the crashing bugs and data corruption bugs have occurred due to the inadequate locking. Fixing those bugs required improving locking. Hence, what you observe is a positive change, which avoids data corruption or crashing in many cases. All of those bug fixes represent a major improvement for InnoDB storage engine. We do not group those bug fixes in a separate category. You can look through our changelogs and count a number of crashing and data corruption bugs in InnoDB. Our ChangeLogs are here: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/ Not a bug.