[MDEV-11656] 'Data structure corruption' IMPORT TABLESPACE doesn't work for encrypted InnoDB tables if space_id changed Created: 2016-12-23  Updated: 2017-01-03  Resolved: 2017-01-03

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.1.19
Fix Version/s: 10.1.21

Type: Bug Priority: Major
Reporter: Andrii Nikitin (Inactive) Assignee: Jan Lindström (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Attachments: File innodb-discard-import-adv.test    
Sprint: 10.2.4-5

 Description   

So I do following actions on encrypted InnoDB :
[mysqld]
plugin_load=file_key_management.so
file_key_management_encryption_algorithm=aes_cbc
file_key_management_filename=/sec/keys.enc
file_key_management_filekey=secret
innodb-buffer-pool-size=128M
innodb-encrypt-log=ON
innodb-encryption-rotate-key-age=2
innodb-encryption-threads=4
innodb-tablespaces-encryption
innodb-encrypt-tables=FORCE

root@c480fbb475db:/test# mysql <<EOL
create database d1;
use d1;
create table t(a varchar(5)) encrypted=yes encryption_key_id=1;
EOL
root@c480fbb475db:/test# cp /dt/d1/t.ibd /t.ibd
root@c480fbb475db:/test# mysql d1 <<EOL
> drop table t;
> create table t(a varchar(5)) encrypted=yes encryption_key_id=1;
> alter table t discard tablespace;
> EOL
root@c480fbb475db:/test# cp /t.ibd /dt/d1/
root@c480fbb475db:/test# mysql -e "alter table d1.t import tablespace;"
ERROR 1296 (HY000) at line 1: Got error 39 'Data structure corruption' from ./d1/t.ibd

If I don't drop the table inbetween - it works.
Attached mtr test case shows the same error:

ALTER TABLE t1 IMPORT TABLESPACE;
encryption.innodb-discard-import-adv 'cbc,innodb_plugin' [ fail ]
Test ended at 2016-12-23 11:46:15

CURRENT_TEST: encryption.innodb-discard-import-adv
mysqltest: At line 134: query 'ALTER TABLE t1 IMPORT TABLESPACE' failed: 1296: Got error 39 'Data structure corruption' from ./test/t1.ibd



 Comments   
Comment by Andrii Nikitin (Inactive) [ 2016-12-23 ]

Error log:
2016-12-23 10:37:37 139667421829888 [Note] InnoDB: Sync to disk
2016-12-23 10:37:37 139667421829888 [Note] InnoDB: Sync to disk - done!
2016-12-23 10:37:37 139667421829888 [Note] InnoDB: Phase I - Update all pages
2016-12-23 10:37:37 139667421829888 [Note] InnoDB: Sync to disk
2016-12-23 10:37:37 139667421829888 [Note] InnoDB: Sync to disk - done!
2016-12-23 10:37:37 139667421829888 [ERROR] InnoDB: In file './d1/t.ibd', tablespace id and flags are 4 and 0, but in the InnoDB data dictionary they are 5 and 0. Have you moved InnoDB .ibd files around without using the commands DISCARD TABLESPACE and IMPORT TABLESPACE? Please refer to http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2016-12-23 10:37:37 7f06db109b00 InnoDB: Operating system error number 2 in a file operation.
InnoDB: The error means the system cannot find the path specified.
2016-12-23 10:37:37 139667421829888 [ERROR] InnoDB: Could not find a valid tablespace file for 'd1/t'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2016-12-23 10:37:37 139667421829888 [Note] InnoDB: Discarding tablespace of table "d1"."t": Data structure corruption

Comment by Jan Lindström (Inactive) [ 2016-12-27 ]

http://lists.askmonty.org/pipermail/commits/2016-December/010337.html

Comment by Marko Mäkelä [ 2016-12-28 ]

I would like some clarification when the copying is actually needed. There seem to be 3 different buffers at play, and some of them are only used when compression or encryption is involved.

Generated at Thu Feb 08 07:51:39 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.