[MDEV-24352] General error: 1808 Schema mismatch (Index field count XX doesn't match tablespace metadata file value YY) Created: 2020-12-04  Updated: 2022-01-06  Resolved: 2022-01-06

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.5.8, 10.4, 10.5
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Bernhard Pszola Assignee: Marko Mäkelä
Resolution: Incomplete Votes: 2
Labels: TABLESPACES
Environment:

Windows 10


Issue Links:
Blocks
is blocked by MDEV-18543 IMPORT TABLESPACE fails after instant... Closed
Relates
relates to MDEV-24515 ER_TABLE_SCHEMA_MISMATCH or Assertion... Closed
relates to MDEV-24516 DISCARD/IMPORT TABLESPACE does not wo... Open

 Description   

Copying Transportable Tablespaces for Non-partitioned Tables cannont be completed for tables with index.
Step 1: FLUSH TABLES t1 FOR EXPORT successful
Step 2: store result of SHOW CREATE TABLE t1
Step 3: copying t1.ibd and t1.cfg to saved-tablespaces-directoy successful
Step 4: UNLOCK TABLES successfull
Step 5: DROP TABLE t1 (on the same server) sucsessful
Step 6: CREATE TABLE t1 as stored in step 2 successful
Step 7: ALTER TABLE t1 DISCARD TABLESPACE successful
Step 8: move t1.ibd and t1.cfg to datadir (successful)
Step 9: ALTER TABLE t1 IMPORT TABLESPACE (fails for tables with autoincrement index)
Error Message is "General error: 1808 Schema mismatch (Index field count 39 doesn't match tablespace metadata file value 43) "

Due to this error, the data are not importetd into the table.
The problem does't occur for tables without index.

The storage formats for temporal columns and the ROW_FORMAT-values are identical.



 Comments   
Comment by Marko Mäkelä [ 2020-12-05 ]

Pszola, can you please provide the exact commands for repeating this error, starting from the initial CREATE TABLE before FLUSH TABLES?

Note: There is a known bug MDEV-18543, but your description sounds like the problem may be different.

Comment by Bernhard Pszola [ 2020-12-05 ]

Hello Marko Mäkela,
when trying to provide the exact commands to create a typical table (with WITH SYSTEM VERSIONING), I noticed that everything works as expected with a table created newly. After inserting some rows and updating these, I could copy the tablespace and recreate the table. Therefore, the detailed commands probably won't be helpful. But: I am not able to transfer the ORIGINAL table to a new server, as the IMPORT TABLE SPACE doesn't work. After recreating a table and inserting the rows via mariadump the historical data will be lost which cannot be accepted. So, to my conclusion there must be differences between the newly created tables and the original tables, but I have no idea how to figure that out.

Comment by Elena Stepanova [ 2021-01-02 ]

--source include/have_innodb.inc
 
CREATE TABLE t1 (pk INT, a INT, PRIMARY KEY(pk)) ENGINE=InnoDB;
ALTER TABLE t1 DROP a;
INSERT INTO t1 VALUES (1),(2); # Optional
 
--let $datadir= `select @@datadir`
FLUSH TABLES t1 FOR EXPORT;
--copy_file $datadir/test/t1.ibd $MYSQLTEST_VARDIR/t1.ibd
--copy_file $datadir/test/t1.cfg $MYSQLTEST_VARDIR/t1.cfg
UNLOCK TABLES;
 
DROP TABLE t1;
CREATE TABLE t1 (pk INT, PRIMARY KEY(pk)) ENGINE=InnoDB;
ALTER TABLE t1 DISCARD TABLESPACE;
--copy_file $MYSQLTEST_VARDIR/t1.ibd $datadir/test/t1.ibd
--copy_file $MYSQLTEST_VARDIR/t1.cfg $datadir/test/t1.cfg
ALTER TABLE t1 IMPORT TABLESPACE;
 
# Cleanup
DROP TABLE t1;

10.4 3454b5cf

 query 'ALTER TABLE t1 IMPORT TABLESPACE' failed: 1808: Schema mismatch (Index field count 3 doesn't match tablespace metadata file value 4)

Reproducible on 10.4, 10.5. INSERT in the test case is unimportant, I put it there to make the point that the table doesn't have to be empty to get the failure.

The problem appeared in 10.4 after this commit:

commit ea2b19dee6a6ed69faffa368c9b1ce9338556299
Author: Marko Mäkelä
Date:   Fri Sep 27 16:01:55 2019 +0300
 
    MDEV-20117: Fix another scenario

See also MDEV-24515.

Comment by Marko Mäkelä [ 2021-03-22 ]

elenst, thank you. Your test case looks like a duplicate of MDEV-18543.

Comment by Marko Mäkelä [ 2021-11-01 ]

Pszola, a new release where MDEV-18543 has been fixed is expected to be available in the next few days. Can you please test if 10.4.22, 10.5.13, or 10.6.5 will import the tablespace?

Generated at Thu Feb 08 09:29:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.