| 1 |
--source include/have_innodb.inc |
| 2 |
# Test uses restart |
| 3 |
--source include/not_embedded.inc |
| 4 |
--source filekeys_plugin.inc |
| 5 |
--source include/innodb_undo_tablespaces.inc |
| 6 |
|
| 7 |
# |
| 8 |
# MDEV-15566: System tablespace does not easily key rotate to unencrypted |
| 9 |
# |
| 10 |
|
| 11 |
set global innodb_file_per_table=OFF; |
| 12 |
|
| 13 |
call mtr.add_suppression("(mysqld|mariadbd).*: file-key-management-filename is not set"); |
| 14 |
call mtr.add_suppression("Plugin 'file_key_management' init function returned error."); |
| 15 |
call mtr.add_suppression("Plugin 'file_key_management' registration as a ENCRYPTION failed."); |
| 16 |
flush tables; |
| 17 |
|
| 18 |
create table t1(a int not null primary key, b char(200)) engine=innodb; |
| 19 |
|
| 20 |
--echo |
| 21 |
--echo # Restart server with encryption |
| 22 |
-- let $restart_parameters=--plugin-load-add=file_key_management --loose-file-key-management --loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys.txt --file-key-management-encryption-algorithm=aes_cbc --innodb-encrypt-tables=ON --innodb-encryption-threads=4 --innodb-tablespaces-encryption --innodb-encryption-rotate-key-age=15 |
| 23 |
-- source include/restart_mysqld.inc |
| 24 |
|
| 25 |
--echo # Wait until encryption threads have encrypted all tablespaces |
| 26 |
|
| 27 |
--let $tables_count= `select count(*) + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'` |
| 28 |
--let $wait_timeout= 600 |
| 29 |
--let $wait_condition=SELECT COUNT(*) = $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND ROTATING_OR_FLUSHING = 0; |
| 30 |
--source include/wait_condition.inc |
| 31 |
|
| 32 |
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; |
| 33 |
--sorted_result |
| 34 |
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; |
| 35 |
|
| 36 |
--echo # Success! |
| 37 |
|
| 38 |
SELECT * from t1; |
| 39 |
|
| 40 |
--echo # Now turn off encryption and wait for threads to decrypt all tablespaces |
| 41 |
SET GLOBAL innodb_encrypt_tables = off; |
| 42 |
|
| 43 |
--let $wait_condition=SELECT COUNT(*) = $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND ROTATING_OR_FLUSHING = 0; |
| 44 |
--source include/wait_condition.inc |
| 45 |
|
| 46 |
--sorted_result |
| 47 |
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; |
| 48 |
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; |
| 49 |
|
| 50 |
--echo # Success! |
| 51 |
|
| 52 |
--echo |
| 53 |
--echo # Restart server with no encryption setup, there should be no crashes |
| 54 |
--let $restart_parameters=--skip-file-key-management --innodb-encrypt-tables=OFF --innodb-encryption-threads=0 --innodb-tablespaces-encryption |
| 55 |
-- source include/restart_mysqld.inc |
| 56 |
|
| 57 |
--sorted_result |
| 58 |
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; |
| 59 |
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; |
| 60 |
|
| 61 |
SELECT * from t1; |
| 62 |
DROP TABLE t1; |
| 63 |
|