[MDEV-18543] IMPORT TABLESPACE fails after instant DROP COLUMN Created: 2019-02-11 Updated: 2022-04-26 Resolved: 2021-10-26 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.4 |
| Fix Version/s: | 10.4.22, 10.5.13, 10.6.5 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Marko Mäkelä | Assignee: | Eugene Kosov (Inactive) |
| Resolution: | Fixed | Votes: | 6 |
| Labels: | instant, portability | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
After the The problem is demonstrated by this part of the test innodb.instant_alter_import:
The IMPORT TABLESPACE code should read the metadata record and the metadata BLOB early, to augment the metadata. Because the pages have not been adjusted yet, the buffer pool will have to be bypassed while reading the pages. |
| Comments |
| Comment by Marko Mäkelä [ 2019-03-07 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I think that it should be worth trying to use the buffer pool also for the first phase of IMPORT. This may be challenging, because:
If you manage to clean this up, it would pave the way for MDEV-11658 and to a future where we no longer need to write a tablespace ID to every page of the file. Else, we will have to jump through some hoops and duplicate some code so that we can access the metadata record and BLOB completely outside the buffer pool (performing a number of single-page reads, I suppose). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Juan Gabriel Covas [ 2019-08-22 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Under MariaDB 10.4.7, I want to report another "schema_mismatch" error on IMPORT TABLESPACE when an alter ADD column is applied (when is NOT added as the LAST column). Didn't want to open a new issue, you'll say.
ERROR 1808 (HY000): Schema mismatch (Index field name newcol doesn't match tablespace metadata field name name for field position 4) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-08-23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
jgcovas, thanks, your example should be due to this same bug. ADD COLUMN somewhere else as the last column will involve instantly changing the order of columns, and IMPORT TABLESPACE currently fails to read the mapping of clustered index fields to columns from the hidden metadata record. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Juan Gabriel Covas [ 2019-08-23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
No problem. For now, for some projects that we rely on partial backups from mariabackup to pull customer databases, and therefore IMPORT TABLESPACE is needed, we took care of rebuilding the problematic schemas metadata with
And enforcing ,ALGORITHM=copy or ,FORCE after ALTER statements from now on, (or setting alter_algorithm=copy) but is a bit annoying having to take care of this... I'm also thinking, what about people that will try to partially restore old backups? Is the solution a full restore to be able to recover the tables without IMPORT TABLESPACE? Thanks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2020-01-22 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
jgcovas, you seem to be requesting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Dave [ 2021-08-26 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I've just started hitting this error "ERROR 1808 (HY000): Schema mismatch (Index field name...". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Juan Gabriel Covas [ 2021-09-01 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hello. I'm not sure if the severity of this is correctly understood. If anyone rely on "mariabackup" for Solution before taking a partial mariabackup is doing "ALTER TABLE dbname.tablename FORCE;" on ALL tables before a daily backup for example, just in case some table got the metadata corrupted, but that's not reasonable for big setups / volumes of tables (the operation can take a quite long time). Edited: sorry, I didn't review | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Dave [ 2021-09-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I've tried the suggested `ALTER TABLE ... FORCE` before the backup being taken, but this still doesn't work for me. My backup solution uses a schema export which is imported into the destination database first, then the tables are copied over as per the advised process, but this error persists on some tables even after doing a force alter. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Eugene Kosov (Inactive) [ 2021-09-16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This bug might be a separate one but let it live in this issue for now.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Matthias Leich [ 2021-09-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-10-01 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
mleich, your scenario involves a race condition between any ALTER TABLE that is executed by ALGORITHM=COPY, and the DBA copying a data file by that name into the data directory, exactly between the 2 RENAME steps of ALTER TABLE. I have updated MDEV-11658 with a suggestion how to fix it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-10-01 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thank you. This looks mostly good. I posted a few review comments to the 10.4 version. Unfortunately, I think that it needs to be tested again after addressing those comments. |