| Bug #106609 | For EXCHANGE PARTITION, make partition table writable while validation | ||
|---|---|---|---|
| Submitted: | 1 Mar 2022 8:11 | Modified: | 1 Mar 2022 10:43 |
| Reporter: | Hope Lee (OCA) | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: Partitions | Severity: | S3 (Non-critical) |
| Version: | 8.0.27, 5.7 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | Contribution | ||
[1 Mar 2022 10:43]
MySQL Verification Team
Hello Hope Lee, Thank you for the report and feedback. Please ensure to re-send the patch via "contribution" tab. Otherwise we would not be able to accept it. Thank you! regards, Umesh
[2 Mar 2022 1:55]
Hope Lee
Bugfix For EXCHANGE PARTITION, make partition table writable while validation (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: 0001-Bugfix-For-EXCHANGE-PARTITION-make-partition-table-w.patch (application/octet-stream, text), 1.44 KiB.

Description: In the process of DDL `ALTER TABLE EXCHANGE PARTITION`, the partition table is only readable but not writable. Actually, we can make the partition table writable during validation of the swap table. How to repeat: Look at function Sql_cmd_alter_table_exchange_partition::exchange_partition, around line 344 in file sql/sql_partition_admin.cc. We set MDL type for the partition table MDL_SHARED_NO_WRITE, which forbids concurrent modifications. We can safely keep it with the original MDL type MDL_SHARED_UPGRADABLE, which allows concurrent both reads and writes. Suggested fix: diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index 0f6535669bf..3ec7d0b0806 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -325,23 +325,11 @@ bool Sql_cmd_alter_table_exchange_partition::exchange_partition( return true; } - /* - Currently no MDL lock that allows both read and write and is upgradeable - to exclusive, so leave the lock type to TL_WRITE_ALLOW_READ also on the - partitioned table. - - TODO: add MDL lock that allows both read and write and is upgradable to - exclusive lock. This would allow to continue using the partitioned table - also with update/insert/delete while the verification of the swap table - is running. - */ - /* NOTE: It is not possible to exchange a crashed partition/table since we need some info from the engine, which we can only access after open, to be able to verify the structure/metadata. */ - table_list->mdl_request.set_type(MDL_SHARED_NO_WRITE); if (open_tables(thd, &table_list, &table_counter, 0, &alter_prelocking_strategy)) return true;