mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
eca238aea7
Fixes also MDEV-13488: InnoDB writes CRYPT_INFO even though encryption is not enabled. Fixes also MDEV-13093: Leak of Datafile::m_crypt_info on shutdown after failed startup. Problem was that we created encryption metadata (crypt_data) for system tablespace even when no encryption was enabled and too early. System tablespace can be encrypted only using key rotation. Test innodb-key-rotation-disable, innodb_encryption, innodb_lotoftables require adjustment because INFORMATION_SCHEMA INNODB_TABLESPACES_ENCRYPTION contain row only if tablespace really has encryption metadata. xb_load_single_table_tablespace(): Do not call fil_space_destroy_crypt_data() any more, because Datafile::m_crypt_data has been removed. fil_crypt_realloc_iops(): Avoid divide by zero. fil_crypt_set_thread_cnt(): Set fil_crypt_threads_event if encryption threads exist. This is required to find tablespaces requiring key rotation if no other changes happen. fil_crypt_find_space_to_rotate(): Decrease the amount of time waiting when nothing happens to better enable key rotation on startup. fil_ibd_open(), fil_ibd_load(): Load possible crypt_data from first page. class Datafile, class SysTablespace : remove m_crypt_info field. Datafile::get_first_page(): Return a pointer to first page buffer. fsp_header_init(): Write encryption metadata to page 0 only if tablespace is encrypted or encryption is disabled by table option. i_s_dict_fill_tablespaces_encryption(): Skip tablespaces that do not contain encryption metadata. This is required to avoid too early wait condition trigger in encrypted -> unencrypted state transfer.
62 lines
2.9 KiB
Text
62 lines
2.9 KiB
Text
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
|
|
NAME
|
|
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
|
|
NAME
|
|
create database enctests;
|
|
use enctests;
|
|
create table t1(a int not null primary key, b char(200)) engine=innodb;
|
|
create table t2(a int not null primary key, b char(200)) engine=innodb row_format=compressed;
|
|
create table t3(a int not null primary key, b char(200)) engine=innodb page_compressed=yes;
|
|
create table t4(a int not null primary key, b char(200)) engine=innodb encrypted=yes;
|
|
create table t5(a int not null primary key, b char(200)) engine=innodb encrypted=yes row_format=compressed;
|
|
create table t6(a int not null primary key, b char(200)) engine=innodb encrypted=yes page_compressed=yes;
|
|
create table t7(a int not null primary key, b char(200)) engine=innodb encrypted=no;
|
|
create table t8(a int not null primary key, b char(200)) engine=innodb encrypted=no row_format=compressed;
|
|
create table t9(a int not null primary key, b char(200)) engine=innodb encrypted=no page_compressed=yes;
|
|
insert into t1 values (1, 'secredmessage');
|
|
insert into t2 values (1, 'secredmessage');
|
|
insert into t3 values (1, 'secredmessagecompressedaaaaaaaaabbbbbbbbbbbbbbccccccccccccccc');
|
|
insert into t4 values (1, 'secredmessage');
|
|
insert into t5 values (1, 'secredmessage');
|
|
insert into t6 values (1, 'secredmessagecompressedaaaaaaaaabbbbbbbbbbbbbbccccccccccccccc');
|
|
insert into t7 values (1, 'publicmessage');
|
|
insert into t8 values (1, 'publicmessage');
|
|
insert into t9 values (1, 'pugliccompressedaaaaaaaaabbbbbbbbbbbbbbccccccccccccccc');
|
|
# should list tables t1-t6
|
|
SELECT NAME,ENCRYPTION_SCHEME,CURRENT_KEY_ID FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'enctests%';
|
|
NAME ENCRYPTION_SCHEME CURRENT_KEY_ID
|
|
enctests/t1 1 1
|
|
enctests/t2 1 1
|
|
enctests/t3 1 1
|
|
enctests/t4 1 1
|
|
enctests/t5 1 1
|
|
enctests/t6 1 1
|
|
# should list tables t7-t9
|
|
SELECT NAME,ENCRYPTION_SCHEME,CURRENT_KEY_ID FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 and NAME LIKE 'enctests%';
|
|
NAME ENCRYPTION_SCHEME CURRENT_KEY_ID
|
|
enctests/t7 0 1
|
|
enctests/t8 0 1
|
|
enctests/t9 0 1
|
|
SET GLOBAL innodb_encrypt_tables=OFF;
|
|
ERROR 42000: Variable 'innodb_encrypt_tables' can't be set to the value of 'OFF'
|
|
SET GLOBAL innodb_encrypt_tables=ON;
|
|
ERROR 42000: Variable 'innodb_encrypt_tables' can't be set to the value of 'ON'
|
|
# t1 default on expecting NOT FOUND
|
|
NOT FOUND /secred/ in t1.ibd
|
|
# t2 default on expecting NOT FOUND
|
|
NOT FOUND /secred/ in t2.ibd
|
|
# t3 default on expecting NOT FOUND
|
|
NOT FOUND /secred/ in t3.ibd
|
|
# t4 on expecting NOT FOUND
|
|
NOT FOUND /secred/ in t4.ibd
|
|
# t5 on expecting NOT FOUND
|
|
NOT FOUND /secred/ in t5.ibd
|
|
# t6 on expecting NOT FOUND
|
|
NOT FOUND /secred/ in t6.ibd
|
|
# t7 off expecting FOUND
|
|
FOUND 1 /public/ in t7.ibd
|
|
# t8 row compressed expecting NOT FOUND
|
|
FOUND 1 /public/ in t8.ibd
|
|
# t9 page compressed expecting NOT FOUND
|
|
NOT FOUND /public/ in t9.ibd
|
|
drop database enctests;
|