Bug #106480 | ALGORITHM=INSTANT takes exclusive metadata lock on table | ||
---|---|---|---|
Submitted: | 17 Feb 2022 0:11 | Modified: | 13 May 2022 15:49 |
Reporter: | Jayden Navarro | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Documentation | Severity: | S3 (Non-critical) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[17 Feb 2022 0:11]
Jayden Navarro
[17 Feb 2022 13:53]
MySQL Verification Team
Hi Mr. Navarro, Thank you for your bug report. However, documentation is correct regarding the exclusive lock. This variant of DDL takes the share lock, except at the very end, where it takes exclusive lock for a very short time. You can check this by running read-only (SELECT with no locks) queries during this DDL. If our documentation, on dev.mysql.com, does not mention that exclusive lock is taken for a very short time, that can be amended if you agree to treat this report as a documentation request. We are waiting on your feedback.
[17 Feb 2022 14:30]
MySQL Verification Team
Hi, Another small addition ..... Waiting on the concurrent transaction to finish is expected behaviour. If you wish it to be documented better, just let us know .....
[17 Feb 2022 14:31]
MySQL Verification Team
What we wrote to you about concurrent read-only queries, it does not include open transactions !!! Just simple SELECTs .....
[17 Feb 2022 17:37]
Jayden Navarro
Yes, this can be treated as a documentation request. I believe these statements in the documentation are incorrect, specifically where they state "No metadata locks are taken on the table". This is false, as at some point during the query an exclusive metadata lock is taken on the table: > Instant operations only modify metadata in the data dictionary. No metadata locks are taken on the table, and table data is unaffected, making operations instantaneous. Concurrent DML is unaffected. - https://dev.mysql.com/doc/refman/8.0/en/innodb-online-ddl-performance.html > INSTANT: Operations only modify metadata in the data dictionary. No exclusive metadata locks are taken on the table during preparation and execution, and table data is unaffected, making operations instantaneous. Concurrent DML is permitted. - https://dev.mysql.com/doc/refman/8.0/en/alter-table.html
[18 Feb 2022 13:59]
MySQL Verification Team
Hi Mr. Navarro, It turns out that this particular feature is not documented sufficiently. Regarding waiting for pending transactions before starting the INSTANT DDL, that is expected behaviour. The explanation is simple ...... MySQL does not support having multiple versions of table in the data-dictionary and table definition/open tables caches at the same time, nor SE support this AFAIK. So ALTER TABLE needs to invalidate all these caches at some point and update them while ensuring that there is no concurrent statement are using them, for which we acquire exclusive lock. There are other solutions that are discussed strictly internally, but those are left for some distant future. This is a missing piece in our documentation. INSTANT method is ideal for the DDL that ou are attempting, since it will require only a change in the attributes. Regarding the exclusive lock, it will be taken only once for the table 'test' in this case, before calling storage engine's inplace or instant ALTER TABLE commit hook/invalidating caches and updating data dictionary. This should be also added to our documentation. Verified as a documentation request. This should
[13 May 2022 15:49]
Daniel Price
Posted by developer: The referenced documentation has been revised. The changes should appear online soon. Thank you for the bug report.