Bug #99095 | The n bits which transaction waiting for X lock is already locked by itself | ||
---|---|---|---|
Submitted: | 27 Mar 2020 5:39 | Modified: | 30 Mar 2020 23:41 |
Reporter: | lao wei lao | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 5.7.24-log | OS: | CentOS (7.4.1708) |
Assigned to: | CPU Architecture: | x86 | |
Tags: | deadlock select for update |
[27 Mar 2020 5:39]
lao wei lao
[27 Mar 2020 13:50]
MySQL Verification Team
Hi Mr. lao, Thank you for your bug report. However, this is not a bug. Simply, you do not have an index over all three columns involved in the WHERE clause, but only on the first column `seqno`. And , as you can see for yourself, the values of the columns in both queries are the same. Hence, this is not a question of the bits of index, but the entire index entry is locked. This is because MySQL has found a best possible path to execute this query, which is by using index. It is not scanning the rows of the table, which would be much slower. I need to inform you about another aspect. All transactional and ACID storage engines are designed to detect deadlocks. If a deadlock is reported that means that storage engine is working properly, as designed, and hence is not a bug. Not a bug.
[27 Mar 2020 15:43]
lao wei lao
I known that InnoDB will lock the index entry of seqno == '1', but it's so weird that TRANSACTIONS 2 us waiting for X locks which already holded by itself, InnoDB: *** (2) HOLDS THE LOCK(S): RECORDS LOCKS space id 828 page no 65 n bits 416 ... <= holded by itselft InnoDB: *** (2) WAITING FOR THIS LOCK TO BE GRANTED: RECORDS LOCKS space id 828 page no 65 n bits 416 ... <= why wait it?
[28 Mar 2020 16:38]
lao wei lao
I suggest that 'select for update' ignores index entry locks firstly,waiting for X locks only if the result matchs search condition.
[30 Mar 2020 12:32]
MySQL Verification Team
Hi, What you are asking for is already implemented in 8.0, with SKIP LOCKED directive. Not a bug.
[30 Mar 2020 23:41]
lao wei lao
if you mean 'select for update skip locked', i say no, i don't want skip locked records which matchs search conditions, i want skip locked records which do not match search conditions.
[31 Mar 2020 13:24]
MySQL Verification Team
Hi, The index entries that do not match are skipped already. In your case these are index entries that are skipped, because MySQL server was able to resolve the query with index usage only.
[31 Mar 2020 13:32]
MySQL Verification Team
HI, I have analysed your report in further detail. You have reported it as a bug, and it is not one. However, if you would agree to set severity to S4, then this could be a feature request. This would be a new feature which would force that entire record is checked before locking and not just the index by which it is searched. This would, however, carry with it a speed penalty. However, if it is fine with you this could be a new feature request.