[MDEV-27946] 'Data structure corruption' IMPORT TABLESPACE doesn't work Created: 2022-02-25  Updated: 2023-03-03

Status: Open
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.6, 10.7
Fix Version/s: 10.6

Type: Bug Priority: Major
Reporter: Pramod Mahto Assignee: Marko Mäkelä
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Following the steps provided here https://mariadb.com/kb/en/innodb-file-per-table-tablespaces/#copying-transportable-tablespaces for moving individual MariaDB tables to different disk/path lead to error :-

 
MariaDB [test]> ALTER TABLE test.t1 IMPORT TABLESPACE;
ERROR 1296 (HY000): Got error 38 'Data structure corruption' from /tmp/test/t1.ibd

Test case

 
Server version: 10.6.1-MariaDB MariaDB Server
 
MariaDB [(none)]> create database test;
Query OK, 1 row affected (0.000 sec)
 
MariaDB [(none)]> use test;
Database changed
 
 
 
MariaDB [test]>  CREATE TABLE test.t1 (
   id INT PRIMARY KEY AUTO_INCREMENT,
   name VARCHAR(50)
) ENGINE=InnoDB;
 
 
MariaDB [test]>  FLUSH TABLES test.t1 FOR EXPORT;
 
From another session 
 
[root@master_node_8 test]# cp /var/lib/mysql/test/t1.ibd /tmp/
[root@master_node_8 test]# cp /var/lib/mysql/test/t1.cfg /tmp/
 
 
MariaDB [test]>   UNLOCK TABLES;
 
MariaDB [test]>   drop table t1;
 
 
MMariaDB [test]>  CREATE TABLE test.t1 (
   id INT PRIMARY KEY AUTO_INCREMENT,
   name VARCHAR(50)
) ENGINE=InnoDB
DATA DIRECTORY = "/tmp/";
 
 
MariaDB [test]>   ALTER TABLE test.t1 DISCARD TABLESPACE;
 
[root@master_node_8 test]# cp /tmp/t1.ibd /tmp/test
[root@master_node_8 test]# cp /tmp/t1.cfg /tmp/test
 
 
[root@master_node_8 test]# chown -R mysql:mysql /tmp/test/
 
[root@master_node_8 tmp]# cd /tmp/test/
 
[root@master_node_8 test]# ls -ltrh
total 100K
-rw-r----- 1 mysql mysql 388 Feb 25 09:06 t1.cfg
-rw-r----- 1 mysql mysql 96K Feb 25 09:07 t1.ibd
 
 
[root@master_node_8 test]# chmod 660 /tmp/test/t1.*
 
[root@master_node_8 test]# ls -ltrh
total 100K
-rw-rw---- 1 mysql mysql 96K Feb 25 09:39 t1.ibd
-rw-rw---- 1 mysql mysql 388 Feb 25 09:39 t1.cfg
 
[root@master_node_8 test]# stat t1*
  File: t1.cfg
  Size: 388             Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d      Inode: 34507896    Links: 1
Access: (0660/-rw-rw----)  Uid: (   27/   mysql)   Gid: (   27/   mysql)
Access: 2022-02-25 09:39:03.349786167 +0530
Modify: 2022-02-25 09:39:03.349786167 +0530
Change: 2022-02-25 09:39:24.191711591 +0530
 Birth: -
  File: t1.ibd
  Size: 98304           Blocks: 192        IO Block: 4096   regular file
Device: 803h/2051d      Inode: 34507895    Links: 1
Access: (0660/-rw-rw----)  Uid: (   27/   mysql)   Gid: (   27/   mysql)
Access: 2022-02-25 09:39:02.466789327 +0530
Modify: 2022-02-25 09:39:02.466789327 +0530
Change: 2022-02-25 09:39:24.191711591 +0530
 Birth: -
 
 
 
MariaDB [test]> ALTER TABLE test.t1 IMPORT TABLESPACE;
ERROR 1296 (HY000): Got error 37 'Data structure corruption' from /tmp/test/t1.ibd
 
 



 Comments   
Comment by Elena Stepanova [ 2022-02-25 ]

Does it happen on anything more recent/stable than

Server version: 10.6.1-MariaDB MariaDB Server

?

Comment by Pramod Mahto [ 2022-02-25 ]

elenst Yes Tested with below version as well.

Server version: 10.6.7-MariaDB MariaDB Server --> Affected

Server version: 10.7.3-MariaDB MariaDB Server --> Affected

Comment by Marko Mäkelä [ 2022-02-28 ]

pramod.mahto@mariadb.com, can you provide a copy of the files that fail to import? How and with which version of MariaDB were those files created in the first place?

Does the table import with MariaDB Server 10.4.24 or 10.5.15?

Comment by Pramod Mahto [ 2022-02-28 ]

marko I just simply created one table with in same version of MariaDB 10.6.X or 10.7.X and after discarding the tablespace , drop table , created same table with different path for tablespace and tried to import the tablespace to new location and it failed. Above test case represent the same.

 
1. CREATE TABLE test.t1 ... 
2. FLUSH TABLES test.t1 FOR EXPORT;
3. COPIED TO SAFE LOCATION 
 
cp /var/lib/mysql/test/t1.ibd /tmp/
cp /var/lib/mysql/test/t1.cfg /tmp/
 
4. UNLOCK TABLES;
5. DROP TABLE t1;
6. CREATE TABLE test.t1 ..... DATA DIRECTORY = "/tmp/";
7. ALTER TABLE test.t1 DISCARD TABLESPACE;
8. COPIED BACK TO NEW DATA DIR LOCATION
 
cp /tmp/t1.ibd /tmp/test
cp /tmp/t1.cfg /tmp/test
 
8. ALTER TABLE test.t1 IMPORT TABLESPACE;
 
 
 
ERROR 1296 (HY000): Got error 37 'Data structure corruption' from /tmp/test/t1.ibd

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