[MDEV-26137] ALTER TABLE IMPORT enhancement Created: 2021-07-13 Updated: 2024-01-12 Resolved: 2023-07-05 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Fix Version/s: | 11.2.1 |
| Type: | Task | Priority: | Critical |
| Reporter: | Eugene Kosov (Inactive) | Assignee: | Yuchen Pei |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | Preview_11.2 | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||
| Description |
|
The feature introduces simplified workflow:
Previously, CREATE TABLE and ALTER TABLE…DISCARD TABLESPACE had to be executed, and the exact table definition from an existing .frm file could not be reused. This simplification addresses ha_innodb::open() should check for .ibd and .cfg files before actually opening a table. |
| Comments |
| Comment by Sergei Golubchik [ 2021-07-14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Why
? I'd think InnoDB first try to do a normal open, and only if the table isn't found it should look for files and try to import. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-02-01 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
serg, you are right, it should be the other way around. I think that this will be needed for MDEV-11658. The added feature of MDEV-11658 would be that no .cfg file would be needed for .ibd files that are in a new format that includes a directory of secondary index root page numbers. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-02-07 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
mtr testcase / specification (based on similar feature of myisam):
P.S. The myisam example:
[1] Do we need UNLOCK TABLES;? The myisam does not require it, because it does not require FOR EXPORT in the FLUSH statement, but it seems as long as we need the .cfg files (its removal is part of MDEV-11658), we need the FOR EXPORT. Thus perhaps we need the UNLOCK statement, so that we don't get blocked in the sql layer (with the weird ER_TABLE_NOT_LOCKED error), before even attempting to open with the storage engine (open_table_from_share()). And for comparison, the current innodb import workflow:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-02-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
InnoDB does need explicit locking statements at the SQL level (FLUSH TABLES…FOR EXPORT to lock, and UNLOCK TABLES to unlock) in order to prevent the data file from being modified by the purge of committed transaction history, which is analogous to the Postgres VACUUM. Without such locking, it would be unsafe to copy the .ibd file while InnoDB is running. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-02-20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
New spec, based on discussions at #innodb:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-02-21 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi thiru, PTAL thanks https://github.com/MariaDB/server/commit/3d942ceb701cd9484c22ca34f58d2ebecf04e2ea | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Thirunarayanan Balathandayuthapani [ 2023-02-21 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-03-02 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
thiru as discussed at #innodb, please take a look at the general approach of getting the row format from ibd and cfg in the following patch, thank you https://github.com/MariaDB/server/commit/bee3d9ee39a86b65ca26da6e60069a8c6a0cef92 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-03-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
thiru Thanks for the comments. I've addressed all of them and other comments in #innodb discussions. PTAL thanks https://github.com/MariaDB/server/commit/da65c00ddea | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-03-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Fixed a typo, sorry about the problem. Updated patch: https://github.com/MariaDB/server/commit/937e042add5e64af4343ded0f6e07f3ede040d81 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-03-10 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the comments thiru - I have addressed all of them and the updated patch is available at https://github.com/MariaDB/server/commit/69e1a3bb8b5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-03-14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the comments thiru, PTAL thanks: https://github.com/MariaDB/server/commit/676038b1076756666e985aaa9d01641566584e8f squashed commit at https://github.com/MariaDB/server/commit/790e5ca64b2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Thirunarayanan Balathandayuthapani [ 2023-03-14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Gave few review comments. Please address them, Commit message could be more elaborate. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-03-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the comments thiru, especially finding a new failing testcase. Updated (and squashed) commit at [1], and individual commits in the branch at [2]. Would you like to take another look? [1] https://github.com/MariaDB/server/commit/5f8f9de5c6e308239c5e99147304742e69c54ef1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-03-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Please address my comment regarding crash injection testing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-03-16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the comments marko thiru. All your comments are addressed, and the CI looks in a much better state now [1][2] Please find the updated commit at https://github.com/MariaDB/server/commit/653e4905904, thank you. [1] https://buildbot.mariadb.org/#/grid?branch=bb-11.1-mdev-26137 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Thirunarayanan Balathandayuthapani [ 2023-03-16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I have only one review comment. Don't have anything significant issue though. Approved from my side | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-03-16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
thiru Thanks for the review. I have addressed your comments, as well as comments about removing rdiffs - all rdiffs are gone now. Updated patch: https://github.com/MariaDB/server/commit/5d0cce962f3441f6061f1ef9c5608ad3f9475513 diff with previous commit: https://github.com/MariaDB/server/commit/605b8fd8462b17a5681e33a3691b8d4c7bf862a7 marko: Since thiru has approved the patch, would you like to take a look? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-03-20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Please try to minimize the changes to row0import.h. I think that we should try to keep as much of the low-level code related to IMPORT in row0import.cc as possible, and only export higher-level interfaces. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-03-21 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the comments marko - I have addressed all of them, and the updated patch can be found at https://github.com/MariaDB/server/commit/3e840a9a621 The diff from the previous one at | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-03-28 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Addressed some formatting and debug_sync comments at #innodb and pushed a small commit at https://github.com/MariaDB/server/commit/86d1d970961 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-03-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I posted some suggested cleanup to the tests and the code. If you agree with them, please squash and rebase everything to a single commit based on the latest 11.1. The next step would be some stress testing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-03-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks marko, I have adjusted the commits accordingly (https://github.com/MariaDB/server/commit/44558f70c7c) and pushed the squashed version rebased at 11.1 to https://github.com/MariaDB/server/commit/2d36352c138 I've changed the ticket status to request testing. Shall I re-assign it to mleich? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Matthias Leich [ 2023-04-05 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Matthias Leich [ 2023-06-12 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Matthias Leich [ 2023-06-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
origin/bb-11.1- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-06-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks mleich, is it ok for me to push the commit to 11.2? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Matthias Leich [ 2023-06-16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From my side yes | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-06-30 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There are some occasional failures of the added regression test innodb.import_recovery, where InnoDB would fail to start up. The test is intentionally corrupting some InnoDB data files. It may be necessary to force an InnoDB checkpoint or page flush before doing that, to get deterministic results on a subsequent server restart. The the test innodb.page_cleaner could be useful there. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-07-03 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the suggestion marko. I looked into | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-07-03 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Updated patch at https://github.com/MariaDB/server/commit/f3d86acf1fe, checking CI... | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-07-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Squashed the following 32bit fixup and import_recovery fixup commits
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-07-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thank you, this looks good to me. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-07-05 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Pushed 9b431d714fdf030e372ed6eeaec0619dcffdde6a to 11.2, closing |