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
{"report":{"fcp":1355.0999994277954,"ttfb":423,"pageVisibility":"visible","entityId":59490,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":32,"apdex":0.5,"journeyId":"ca621ac8-1238-45de-a339-2791174157be","navigationType":0,"readyForUser":1446.6999998092651,"redirectCount":0,"resourceLoadedEnd":1203.0999994277954,"resourceLoadedStart":428.5999994277954,"resourceTiming":[{"duration":356.80000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":428.5999994277954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":428.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":785.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":357.3999996185303,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":428.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":428.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":786.1999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":545.0999994277954,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":429,"connectEnd":429,"connectStart":429,"domainLookupEnd":429,"domainLookupStart":429,"fetchStart":429,"redirectEnd":0,"redirectStart":0,"requestStart":790.5999994277954,"responseEnd":974.0999994277954,"responseStart":822.5999994277954,"secureConnectionStart":429},{"duration":656.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":429.19999980926514,"connectEnd":429.19999980926514,"connectStart":429.19999980926514,"domainLookupEnd":429.19999980926514,"domainLookupStart":429.19999980926514,"fetchStart":429.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":790.3999996185303,"responseEnd":1085.5,"responseStart":851.1999998092651,"secureConnectionStart":429.19999980926514},{"duration":401.1000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":429.3999996185303,"connectEnd":429.3999996185303,"connectStart":429.3999996185303,"domainLookupEnd":429.3999996185303,"domainLookupStart":429.3999996185303,"fetchStart":429.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":791.5,"responseEnd":830.5,"responseStart":825.8000001907349,"secureConnectionStart":429.3999996185303},{"duration":400.6000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":429.5999994277954,"connectEnd":429.5999994277954,"connectStart":429.5999994277954,"domainLookupEnd":429.5999994277954,"domainLookupStart":429.5999994277954,"fetchStart":429.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":791.8000001907349,"responseEnd":830.1999998092651,"responseStart":824.6999998092651,"secureConnectionStart":429.5999994277954},{"duration":401,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":429.80000019073486,"connectEnd":429.80000019073486,"connectStart":429.80000019073486,"domainLookupEnd":429.80000019073486,"domainLookupStart":429.80000019073486,"fetchStart":429.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":792.1999998092651,"responseEnd":830.8000001907349,"responseStart":827,"secureConnectionStart":429.80000019073486},{"duration":361.30000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":430,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":430,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":791.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":400.8999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":430.19999980926514,"connectEnd":430.19999980926514,"connectStart":430.19999980926514,"domainLookupEnd":430.19999980926514,"domainLookupStart":430.19999980926514,"fetchStart":430.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":796.8999996185303,"responseEnd":831.0999994277954,"responseStart":827.8999996185303,"secureConnectionStart":430.19999980926514},{"duration":362,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":430.3999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":430.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":792.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":401,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":430.5,"connectEnd":430.5,"connectStart":430.5,"domainLookupEnd":430.5,"domainLookupStart":430.5,"fetchStart":430.5,"redirectEnd":0,"redirectStart":0,"requestStart":798.6999998092651,"responseEnd":831.5,"responseStart":829.3000001907349,"secureConnectionStart":430.5},{"duration":643.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":436,"connectEnd":436,"connectStart":436,"domainLookupEnd":436,"domainLookupStart":436,"fetchStart":436,"redirectEnd":0,"redirectStart":0,"requestStart":1025.3999996185303,"responseEnd":1079.3000001907349,"responseStart":1076.8999996185303,"secureConnectionStart":436},{"duration":767.0999994277954,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":436,"connectEnd":436,"connectStart":436,"domainLookupEnd":436,"domainLookupStart":436,"fetchStart":436,"redirectEnd":0,"redirectStart":0,"requestStart":1189.5999994277954,"responseEnd":1203.0999994277954,"responseStart":1202,"secureConnectionStart":436},{"duration":180.70000076293945,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1106.0999994277954,"connectEnd":1106.0999994277954,"connectStart":1106.0999994277954,"domainLookupEnd":1106.0999994277954,"domainLookupStart":1106.0999994277954,"fetchStart":1106.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":1205.8999996185303,"responseEnd":1286.8000001907349,"responseStart":1286.0999994277954,"secureConnectionStart":1106.0999994277954}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":198,"responseStart":423,"responseEnd":430,"domLoading":427,"domInteractive":1543,"domContentLoadedEventStart":1544,"domContentLoadedEventEnd":1590,"domComplete":2451,"loadEventStart":2452,"loadEventEnd":2452,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1521.6999998092651},{"name":"bigPipe.sidebar-id.end","time":1522.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":1522.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.end","time":1524},{"name":"activityTabFullyLoaded","time":1608}],"measures":[],"correlationId":"1523b4b0252d66","effectiveType":"4g","downlink":9.5,"rtt":0,"serverDuration":143,"dbReadsTimeInMs":22,"dbConnsTimeInMs":47,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
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