Bug #80708 Problem importing encrypted tablespace
Submitted: 11 Mar 2016 18:24 Modified: 7 Apr 2016 16:41
Reporter: Sergei Glushchenko Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:5.7.11 OS:Any
Assigned to: CPU Architecture:Any

[11 Mar 2016 18:24] Sergei Glushchenko
Description:
ALTER TABLE IMPORT IMPORT TABLESPACE work if issued from the same session as ALTER TABLE IMPORT DISCARD TABLESPACE before, but doesn't work from different session.

How to repeat:
Do the following:

mysql> create table t1 (a int) encryption='y';
Query OK, 0 rows affected (0.01 sec)

mysql> flush tables t1 for export;
Query OK, 0 rows affected (0.01 sec)

cp -av test/t1.* /tmp
test/t1.cfg -> /tmp/t1.cfg
test/t1.cfp -> /tmp/t1.cfp
test/t1.frm -> /tmp/t1.frm
test/t1.ibd -> /tmp/t1.ibd

mysql> unlock tables;
Query OK, 0 rows affected (0.00 sec)

mysql> alter table t1 discard tablespace;
Query OK, 0 rows affected (0.00 sec)

cp -av /tmp/t1.* test
/tmp/t1.cfg -> test/t1.cfg
/tmp/t1.cfp -> test/t1.cfp
overwrite test/t1.frm? (y/n [n]) y
/tmp/t1.frm -> test/t1.frm
/tmp/t1.ibd -> test/t1.ibd

mysql> alter table t1 import tablespace;
Query OK, 0 rows affected (0.01 sec)

Everything wored OK.

Now, try to reconnect after "alter table t1 discard tablespace;". Result will be as following:

mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> alter table t1 discard tablespace;
Query OK, 0 rows affected (0.00 sec)

cp -av /tmp/t1.* test
/tmp/t1.cfg -> test/t1.cfg
/tmp/t1.cfp -> test/t1.cfp
overwrite test/t1.frm? (y/n [n]) y
/tmp/t1.frm -> test/t1.frm
/tmp/t1.ibd -> test/t1.ibd

mysql> ^DBye

mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> alter table t1 import tablespace;
ERROR 3185 (HY000): Can't find master key from keyring, please check keyring plugin is loaded.

Suggested fix:
Make it work or document
[12 Mar 2016 5:26] MySQL Verification Team
Hello Sergei,

Thank you for the report and test case.

Thanks,
Umesh
[7 Apr 2016 16:41] Daniel Price
Posted by developer:
 
Fixed as of the upcoming 5.7.13 release, and here's the changelog entry:

An ALTER TABLE ... IMPORT TABLESPACE operation on file-per-table
tablespace containing an encrypted table failed when run in a different
session than the preceding ALTER TABLE ... DISCARD TABLESPACE operation.

Thank you for the bug report.