Bug #98537 inplace encryption resume thread doesn't update DD properly
Submitted: 10 Feb 13:56 Modified: 11 Feb 13:05
Reporter: Satya Bodapati (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: alter tablespace, encryption, innodb

[10 Feb 13:56] Satya Bodapati
Description:
Kill the server when ALTER TABLESPACE ENCRYPTION='Y'/'N' in progress.
Next startup doesn't update 'encrypt_type' in dd::Table::options.

Correct State:
--------------
REATE TABLESPACE encrypt_ts_2 ADD DATAFILE 'encrypt_ts_2.ibd' ENGINE=InnoDB ENCRYPTION="N";
CREATE TABLE t3(c1 char(100)) ENGINE=InnoDB TABLESPACE encrypt_ts_2;
CREATE TABLE t4(c1 char(100)) ENGINE=InnoDB TABLESPACE encrypt_ts_2;
# encrypt_type is correctly set as 'Y' when it doesn't crash
ALTER TABLESPACE encrypt_ts_2 ENCRYPTION='Y';
SELECT name,options FROM mysql.tables WHERE NAME='t3';;
name	t3
options	avg_row_length=0;encrypt_type=Y;explicit_tablespace=1;key_block_size=0;keys_disabled=0;pack_record=0;stats_auto_recalc=0;stats_sample_pages=0;
SELECT name,options FROM mysql.tables WHERE NAME='t4';;
name	t4
options	avg_row_length=0;encrypt_type=Y;explicit_tablespace=1;key_block_size=0;keys_disabled=0;pack_record=0;stats_auto_recalc=0;stats_sample_pages=0;
SELECT name,options FROM mysql.tablespaces WHERE NAME='encrypt_ts_2';;
name	encrypt_ts_2
options	encryption=Y;

Observe that "encrypt_type=Y" is set for both table options and in tablespace options as well

Incorrect State (after crash recovery):
----------------------------------------

ELECT name,options FROM mysql.tables WHERE NAME='t1';;
name	t1
options	avg_row_length=0;encrypt_type=N;explicit_tablespace=1;key_block_size=0;keys_disabled=0;pack_record=0;stats_auto_recalc=0;stats_sample_pages=0;
SELECT name,options FROM mysql.tables WHERE NAME='t2';;
name	t2
options	avg_row_length=0;encrypt_type=N;explicit_tablespace=1;key_block_size=0;keys_disabled=0;pack_record=0;stats_auto_recalc=0;stats_sample_pages=0;
SELECT name,options FROM mysql.tablespaces WHERE NAME='encrypt_ts';;
name	encrypt_ts
options	encryption=Y;

Observe that 'encrypt_type' is still 'N' even though the tablespace encrypted.

How to repeat:
See mtr testcase
[10 Feb 13:58] Satya Bodapati
mtr testcase

Attachment: tablespace_encrypt_2_dd.test (application/octet-stream, text), 4.10 KiB.

[10 Feb 14:02] Satya Bodapati
This looks even serious when compared to bug#98530
[11 Feb 13:05] Sinisa Milivojevic
Hi Satya,

Thank you for your bug report.

It looks both interesting and serious. I have  tested it and repeated the behaviour.

Verified as reported.

Thank you for your contribution.