Bug #94148 | Unnecessary Shared lock on parent table During UPDATE on a child table | ||
---|---|---|---|
Submitted: | 31 Jan 2019 5:47 | Modified: | 1 Mar 2019 13:37 |
Reporter: | Uday Varagani | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Locking | Severity: | S2 (Serious) |
Version: | 5.7.24 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | foreign keys, innodb locks, Shared lock |
[31 Jan 2019 5:47]
Uday Varagani
[31 Jan 2019 13:37]
MySQL Verification Team
Hi, Thank you for your bug report. The row(s) on the parent table are locked because you have this index in the child table: key (parent_id,bs_column) Drop that index and try again. You should not get any locks on the parent table.
[31 Jan 2019 18:02]
Trey Raymond
So, "drop a necessary index" is not a good workaround for a bug. A slightly better one is "add a redundant index" as if you have one on (parent_id) as well as one on (parent_id,bs_column), it will avoid the lock, but then you're stuck with an extra index that incurs write load, wastes memory space (it is used by the fk, so will be in buffer pool, but useless to queries), wastes disk space and IO, and might mess up query optimization. Fixing the code to separate constraint columns from supporting-index columns is the only real solution.
[4 Feb 2019 11:07]
Sveta Smirnova
Sinisa, I agree that if the table has only one key (parent_id, not-related-field) which works together with the foreign key constraint - it is safer to set lock when updating such a key. However, I believe foreign key constraint processing could be rewritten in such a way that this limitation is be avoided. Please verify it as a feature request.
[4 Feb 2019 12:52]
MySQL Verification Team
Hi Sveta, When a segmented index exists which comprises a foreign key is included, then locks have to be put in place in order to avoid changing foreign key by concurrent transactions. You wrote: " I believe foreign key constraint processing could be rewritten in such a way that this limitation is be avoided. " I would be happy to accept this as a feature request, once when you explain the basics of such a new algorithm. Many thanks in advance.
[1 Mar 2019 1:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".