MDEV-30119 INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION.NAME is NULL for undo tablespaces

- Information_schema.innodb_tablespaces_encryption should print
undo tablespace name as innodb_undo001, innodb_undo002 and soon.

- Encryption test should include undo tablespaces count when
the tests are waiting for the condition to check whether all
tables are encrypted or decrypted.
parent c1de3776
--- encrypt_and_grep.result 2022-09-02 22:36:21.669650278 +0530
+++ encrypt_and_grep.reject 2022-11-29 19:01:22.080027528 +0530
@@ -14,6 +14,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
@@ -35,6 +38,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
@@ -62,6 +68,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
--- innodb-remove-encryption.result 2022-09-02 20:44:59.960430396 +0530
+++ innodb-remove-encryption,undo3.reject 2022-11-29 19:02:24.813094277 +0530
@@ -13,6 +13,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
@@ -24,6 +27,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
@@ -36,6 +42,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
--- innodb_encrypt_freed.result 2021-03-23 15:44:14.466377983 +0530
+++ innodb_encrypt_freed,undo3.reject 2022-11-29 19:04:24.987010571 +0530
@@ -14,6 +14,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
@@ -29,6 +32,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
@@ -40,6 +46,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
@@ -55,6 +64,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
@@ -70,6 +82,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
@@ -87,6 +102,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
--- innodb_encrypt_key_rotation_age.result 2022-06-02 16:15:08.395122720 +0530
+++ innodb_encrypt_key_rotation_age,undo3.reject 2022-11-29 19:06:07.964542115 +0530
@@ -12,6 +12,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
@@ -27,6 +30,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
@@ -39,6 +45,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
@@ -59,6 +68,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
@@ -71,6 +83,9 @@
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
innodb_system
+innodb_undo001
+innodb_undo002
+innodb_undo003
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
-- source include/have_innodb.inc
-- source include/have_debug.inc
-- source include/innodb_undo_tablespaces.inc
-- source include/not_embedded.inc
if (`select count(*) = 0 from information_schema.plugins
......@@ -13,7 +14,7 @@ create table t1(a serial) engine=innoDB;
set global innodb_encrypt_tables=ON;
show variables like 'innodb_encrypt%';
--let $tables_count= `select count(*) + 1 from information_schema.tables where engine = 'InnoDB'`
--let $tables_count= `select count(*) + 1 + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
let $wait_condition= select count(*) = $tables_count from information_schema.innodb_tablespaces_encryption where current_key_version=1;
--source include/wait_condition.inc
......
-- source include/have_innodb.inc
-- source include/innodb_undo_tablespaces.inc
-- source include/have_file_key_management_plugin.inc
#
......@@ -59,7 +60,8 @@ SET GLOBAL innodb_encrypt_tables = off;
--echo # Wait max 10 min for key encryption threads to decrypt all spaces
--let $wait_timeout= 600
--let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'`
--let $tables_count= `select count(*) + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--let $wait_condition=SELECT COUNT(*) = $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND CURRENT_KEY_VERSION = 0;
--source include/wait_condition.inc
......
......@@ -2,6 +2,7 @@
# Test uses restart
--source include/not_embedded.inc
--source filekeys_plugin.inc
--source include/innodb_undo_tablespaces.inc
#
# MDEV-15566: System tablespace does not easily key rotate to unencrypted
......@@ -23,7 +24,7 @@ create table t1(a int not null primary key, b char(200)) engine=innodb;
--echo # Wait until encryption threads have encrypted all tablespaces
--let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'`
--let $tables_count= `select count(*) + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) = $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND ROTATING_OR_FLUSHING = 0;
--source include/wait_condition.inc
......
......@@ -2,6 +2,7 @@
--source include/have_example_key_management_plugin.inc
--source include/have_debug.inc
--source include/not_embedded.inc
--source include/innodb_undo_tablespaces.inc
SHOW VARIABLES LIKE 'innodb_encrypt%';
......@@ -10,7 +11,7 @@ SET GLOBAL innodb_encrypt_tables = ON;
CREATE TABLE t1(f1 BIGINT PRIMARY KEY, f2 int not null,
f3 int not null, index(f1), index idx_1(f2),
index(f2, f3)) ENGINE=InnoDB;
--let $tables_count= `select count(*) + 1 from information_schema.tables where engine = 'InnoDB'`
--let $tables_count= `select count(*) + 1 + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--echo # Wait max 10 min for key encryption threads to encrypt all spaces
--let $wait_timeout= 600
......@@ -30,12 +31,12 @@ insert into t2 values(1);
connection default;
--let $tables_count= `select count(*) + 1 from information_schema.tables where engine = 'InnoDB'`
--let $tables_count= `select count(*) + 1 + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
set global innodb_encrypt_tables = OFF;
--echo # Wait max 10 min for key encryption threads to decrypt all spaces
--let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0
--source include/wait_condition.inc
--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
......@@ -63,7 +64,7 @@ drop table t1, t2;
CREATE TABLE t1(f1 BIGINT PRIMARY KEY, f2 int not null,
f3 int not null, index(f1), index idx_1(f2),
index(f2, f3)) ENGINE=InnoDB;
--let $tables_count= `select count(*) + 1 from information_schema.tables where engine = 'InnoDB'`
--let $tables_count= `select count(*) + 1 + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--echo # Wait max 10 min for key encryption threads to encrypt all spaces
--let $wait_timeout= 600
......@@ -82,7 +83,7 @@ insert into t2 values(1);
connection default;
--let $tables_count= `select count(*) + 1 from information_schema.tables where engine = 'InnoDB'`
--let $tables_count= `select count(*) + 1 + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
set global innodb_encrypt_tables = OFF;
--echo # Wait max 10 min for key encryption threads to decrypt all spaces
......
-- source include/have_innodb.inc
-- source include/not_embedded.inc
-- source include/have_example_key_management_plugin.inc
-- source include/innodb_undo_tablespaces.inc
CREATE TABLE t1 (f1 INT, f2 VARCHAR(256))engine=innodb;
INSERT INTO t1 VALUES(1, 'MariaDB'), (2, 'Robot'), (3, 'Science');
......@@ -20,7 +21,7 @@ let $restart_parameters= --innodb_encryption_threads=5 --innodb_encryption_rotat
--echo # Wait until encryption threads have encrypted all tablespaces
--let $tables_count= `select count(*) + 1 from information_schema.tables where engine = 'InnoDB'`
--let $tables_count= `select count(*) + 1 + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/wait_condition.inc
......@@ -39,7 +40,7 @@ create table t4 (f1 int not null)engine=innodb encrypted=NO;
--echo # Wait until encryption threads have encrypted all tablespaces
--let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'`
--let $tables_count= `select count(*) + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/wait_condition.inc
......@@ -54,7 +55,7 @@ set global innodb_encrypt_tables = OFF;
--echo # Wait until encryption threads to decrypt all unencrypted tablespaces
--let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'`
--let $tables_count= `select count(*) + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND ROTATING_OR_FLUSHING = 0;
--source include/wait_condition.inc
......@@ -69,7 +70,7 @@ set global innodb_encrypt_tables = ON;
--echo # Wait until encryption threads to encrypt all unencrypted tablespaces
--let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'`
--let $tables_count= `select count(*) + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/wait_condition.inc
......
......@@ -4,12 +4,14 @@
--source include/have_innodb.inc
--source include/have_file_key_management_plugin.inc
--source include/innodb_undo_tablespaces.inc
let $datadir=`select @@datadir`;
--source include/shutdown_mysqld.inc
--remove_file $datadir/ib_logfile0
--remove_file $datadir/ibdata1
--remove_files_wildcard $datadir undo*
--source include/start_mysqld.inc
......
......@@ -6632,7 +6632,6 @@ i_s_dict_fill_tablespaces_encryption(
{
Field** fields;
struct fil_space_crypt_status_t status;
DBUG_ENTER("i_s_dict_fill_tablespaces_encryption");
fields = table_to_fill->field;
......@@ -6654,6 +6653,14 @@ i_s_dict_fill_tablespaces_encryption(
name.data(), name.size(),
system_charset_info));
fields[TABLESPACES_ENCRYPTION_NAME]->set_notnull();
} else if (srv_is_undo_tablespace(space->id)) {
char undo_name[sizeof "innodb_undo000"];
snprintf(undo_name, sizeof(undo_name),
"innodb_undo%03zu",space->id);
OK(fields[TABLESPACES_ENCRYPTION_NAME]->store(
undo_name, strlen(undo_name),
system_charset_info));
fields[TABLESPACES_ENCRYPTION_NAME]->set_notnull();
} else {
fields[TABLESPACES_ENCRYPTION_NAME]->set_null();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment