Bug #116289 | MySQL Online DDLs Cause Metadata Deadlocks on Active Transactions | ||
---|---|---|---|
Submitted: | 3 Oct 2024 12:06 | Modified: | 3 Oct 2024 16:04 |
Reporter: | Daniel Valchev | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: DDL | Severity: | S5 (Performance) |
Version: | 8.0.36, 9.0.1 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | DDL, deadlock, metadata deadlock, Online DDL |
[3 Oct 2024 12:06]
Daniel Valchev
[3 Oct 2024 12:38]
MySQL Verification Team
Hi Mr. Valchev, Thank you for your bug report. What you are reporting is expected behaviour. Let us inform your why have we introduced Metadata locks. Before MDL locks were introduced, because DDL operations on InnoDB caused very severe corruptions from the concurrent DML operations. There was a very large number of bugs because DDL operations were not protected, so that DML operations might cause crashes or very heavy corruption of data. Since we introduced MDLs, all those problems were solved. So, if you wish that we abolish MDLs , you should design a system that will prevent DMLs from corrupting InnoDB tables. We have also designed and implemented a number of different locks that enable parallel execution of DDLs and DMLs, but all those have certain restrictions, because restrictions are necessary for the safety of your data. You can read this entire chapter to learn more: https://dev.mysql.com/doc/refman/9.0/en/innodb-online-ddl.html Not a bug.
[3 Oct 2024 16:04]
Daniel Valchev
Hi! Thank you for your explanation regarding the purpose of MDLs and their role in preventing data corruption. I appreciate the steps taken to ensure data integrity. However, the issue at hand isn’t about the existence of MDLs but about their current implementation leading to application disruptions. I have reviewed the documentation at this link, but I did not find specific references or details that describe deadlocks occurring during online DDL operations. Could you please point me to the section that explains this behavior in more detail? While I understand that Online DDL has its limitations, the issue here is that there appears to be no alternative to safely alter the database schema without aborting active transactions. The need to abort transactions is disruptive, and in cases where schema changes are required (such as during migrations or upgrades), it becomes challenging to maintain service reliability. One possible solution, I imagine, could be to prioritize granting locks to DML operations in active transactions, allowing these transactions to finish before granting the exclusive lock required by DDL operations. This approach would let DDL statements wait for active transactions to complete, reducing the chances of transaction aborts and avoiding service disruptions. Can you suggest any alternative approaches using MySQL to alter the schema so that it does not lead to aborted transactions?
[4 Oct 2024 9:20]
MySQL Verification Team
Hi Mr. Valchev, Thank you for your e-mail ...... Unfortunately, we have tried various alternatives , but the current one is the only one that truly works and protects DDL operations ....... Regarding the various locking methods for DDL's, this is one of the chapters on the subject: https://dev.mysql.com/doc/refman/8.0/en/innodb-online-ddl-operations.html Also, it is supposed that a reporter reads all relevant sections of our Reference Manual, before a bug report is filed. Not a bug.