1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
|
################################################################################
# InnoDB transparent tablespace data encryption for mysql tablespace.
# For mysql tablespace, this test will test
# 1 - Normal alter encryption
# - encryption='y' to encryption='n'
# - encryption='n' to encryption='y'
# 2 - Crash during altering mysql tablespace encryption
# - encryption='y' to encryption='n'
# - encryption='n' to encryption='y'
# 3 - Crash
# - just before encryption processing starts
# - just after encryption processing finishes
# 4 - Crash during master key rotation
# 5 - Privilege check
################################################################################
--source include/big_test.inc
--source include/have_debug.inc
# Disable in valgrind because of timeout, cf. Bug#22760145
--source include/not_valgrind.inc
# Waiting time when (re)starting the server
--let $explicit_default_wait_counter=10000
--disable_query_log
call mtr.add_suppression("\\[Warning\\] \\[MY-013674\\] \\[InnoDB\\] Decrypting a page in doublewrite file failed: space_id=");
call mtr.add_suppression("\\[Warning\\] \\[MY-013675\\] \\[InnoDB\\] Encryption key missing: space_id=");
--enable_query_log
--echo
--echo #############################################################
--echo # TEST 1 : NORMAL ALTER ENCRYPT mysql TABLESPACE.
--echo #############################################################
--echo
--echo #########################################################################
--echo # RESTART 1 : WITH KEYRING PLUGIN
--echo #########################################################################
let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
--source include/restart_mysqld_no_echo.inc
SET debug='+d,skip_dd_table_access_check';
--echo # Initially, mysql should be unencrypted by default
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='mysql';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
ALTER TABLESPACE mysql ENCRYPTION='Y';
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='mysql';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
ALTER TABLESPACE mysql ENCRYPTION='N';
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='mysql';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
--echo
--echo #############################################################
--echo # TEST 2 : CRASH DURING ALTER ENCRYPT mysql TABLESPACE.
--echo #############################################################
--echo
--echo ############################################################
--echo # ALTER TABLESPACE 1 : Unencrypted => Encrypted #
--echo # (crash at page 10) #
--echo ############################################################
--echo # Set Encryption process to crash at page 10
SET SESSION debug= '+d,alter_encrypt_tablespace_page_10';
--echo # Encrypt the tablespace. It will cause crash.
--source include/expect_crash.inc
--error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
ALTER TABLESPACE mysql ENCRYPTION='Y';
--echo # Restart after crash
--source include/start_mysqld_no_echo.inc
SET debug='+d,skip_dd_table_access_check';
--echo # Wait for Encryption processing to finish in background thread
let $wait_condition = SELECT ENCRYPTION = 'Y'
FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
WHERE NAME='mysql';
--source include/wait_condition.inc
# Make sure ts file is updated with new records in table
set global innodb_buf_flush_list_now = 1;
--echo # After restart/recovery, check that Encryption was roll-forward
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='mysql';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
# Try to do encryption one more time (dummy). Should not do anything.
ALTER TABLESPACE mysql ENCRYPTION='Y';
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='mysql';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
--echo #########################################################################
--echo # RESTART 2 : WITH KEYRING PLUGIN
--echo #########################################################################
let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
--source include/restart_mysqld_no_echo.inc
SET debug='+d,skip_dd_table_access_check';
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='mysql';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
--echo ############################################################
--echo # ALTER TABLESPACE 2 : Encrypted => Unencrypted #
--echo # (crash at page 10) #
--echo ############################################################
--echo # Set Unencryption process to crash at page 10
SET SESSION debug= '+d,alter_encrypt_tablespace_page_10';
--echo # Unencrypt the tablespace. It will cause crash.
--source include/expect_crash.inc
--error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
ALTER TABLESPACE mysql ENCRYPTION='N';
--echo # Restart after crash
--source include/start_mysqld_no_echo.inc
SET debug='+d,skip_dd_table_access_check';
--echo # Wait for Unencryption processing to finish in background thread
let $wait_condition = SELECT ENCRYPTION = 'N'
FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
WHERE NAME='mysql';
--source include/wait_condition.inc
# Make sure ts file is updated with new records in table
set global innodb_buf_flush_list_now = 1;
--echo # After restart/recovery, check that Unencryption was roll-forward
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='mysql';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
# Try to do unencryption one more time (dummy). Should not do anything.
ALTER TABLESPACE mysql ENCRYPTION='N';
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='mysql';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
--echo #########################################################################
--echo # RESTART 3 : WITHOUT KEYRING PLUGIN
--echo #########################################################################
let $restart_parameters = restart:;
--source include/restart_mysqld_no_echo.inc
SET debug='+d,skip_dd_table_access_check';
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='mysql';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
--echo #############################################################
--echo # TEST 3 : CRASH BEFORE/AFTER ENCRYPTION PROCESSING.
--echo #############################################################
--echo
--echo #########################################################################
--echo # RESTART 4 : WITH KEYRING PLUGIN
--echo #########################################################################
let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
--source include/restart_mysqld_no_echo.inc
SET debug='+d,skip_dd_table_access_check';
# Encrypt tablespace
ALTER TABLESPACE mysql ENCRYPTION='Y';
# Read rows from table
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
--echo # Set server to crash just before encryption processing starts
SET SESSION debug="+d,alter_encrypt_tablespace_crash_before_processing";
--echo # Unencrypt the tablespace. It will cause crash.
--source include/expect_crash.inc
--error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
ALTER TABLESPACE mysql ENCRYPTION='N';
--echo # Restart after crash
--source include/start_mysqld_no_echo.inc
SET debug='+d,skip_dd_table_access_check';
--echo # Wait for Unencryption processing to finish in background thread
let $wait_condition = select count(*) = 0
from performance_schema.events_stages_current
where EVENT_NAME='stage/innodb/alter tablespace (encryption)';
--source include/wait_condition.inc
# Encrytion property of tablespace shouldn't have changed i.e. it should still
# be encrypted.
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='mysql';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
--echo # Set server to crash just after encryption processing finishes
SET SESSION debug="-d,alter_encrypt_tablespace_crash_before_processing";
SET SESSION debug="+d,alter_encrypt_tablespace_crash_after_processing";
--echo # Unencrypt the tablespace. It will cause crash.
--source include/expect_crash.inc
--error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
ALTER TABLESPACE mysql ENCRYPTION='N';
--echo # Restart after crash
--source include/start_mysqld_no_echo.inc
SET debug='+d,skip_dd_table_access_check';
--echo # Wait for Unencryption processing to finish in background thread
let $wait_condition = select count(*) = 0
from performance_schema.events_stages_current
where EVENT_NAME='stage/innodb/alter tablespace (encryption)';
--source include/wait_condition.inc
# Encrytion property of tablespace should have changed i.e. it should be
# unencrypted now.
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='mysql';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
--echo #############################################################
--echo # TEST 4 : CRASH DURING KEY ROTATION.
--echo #############################################################
--echo
--echo #########################################################################
--echo # RESTART 5 : WITH KEYRING PLUGIN
--echo #########################################################################
let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
--source include/restart_mysqld_no_echo.inc
SET debug='+d,skip_dd_table_access_check';
# Encrypt tablespace
ALTER TABLESPACE mysql ENCRYPTION='Y';
# Read rows from table
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
--echo # Set server to crash while rotating encryption
SET SESSION debug="+d,ib_crash_during_rotation_for_encryption";
# Rotate the key. It will cause server to crash.
--source include/expect_crash.inc
--error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
ALTER INSTANCE ROTATE INNODB MASTER KEY;
--echo # Restart after crash
--source include/start_mysqld_no_echo.inc
SET debug='+d,skip_dd_table_access_check';
# Read rows from table
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
# Rotate the key.
SET SESSION debug="-d,ib_crash_during_rotation_for_encryption";
ALTER INSTANCE ROTATE INNODB MASTER KEY;
# Read rows from table
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
--echo #############################################################
--echo # TEST 5 : PRIVILEGE CHECK.
--echo #############################################################
--echo
CREATE DATABASE priv_test;
CREATE USER myuser@'localhost';
GRANT ALL ON priv_test.* TO myuser@'localhost';
--echo #connection con1
--connect(con1,localhost,myuser,,priv_test)
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
ALTER TABLESPACE mysql ENCRYPTION='Y';
--disconnect con1
--source include/wait_until_disconnected.inc
--echo #connection default
--connection default
--error ER_WRONG_USAGE
GRANT CREATE TABLESPACE ON mysql.* TO myuser@'localhost';
GRANT CREATE TABLESPACE ON *.* TO myuser@'localhost';
--echo #connection con1
--connect(con1,localhost,myuser,,priv_test)
ALTER TABLESPACE mysql ENCRYPTION='N';
--echo #connection default
--connection default
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
--echo #connection con1
--connection con1
ALTER TABLESPACE mysql ENCRYPTION='Y';
--echo #connection default
--connection default
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
--disconnect con1
DROP DATABASE priv_test;
DROP USER myuser@localhost;
--echo ###########
--echo # Cleanup #
--echo ###########
# Unencrypt tablespace
ALTER TABLESPACE mysql ENCRYPTION='N';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE NAME='mysql';
remove_file $MYSQL_TMP_DIR/mysecret_keyring;
--echo #########################################################################
--echo # RESTART 6 : WITHOUT KEYRING PLUGIN
--echo #########################################################################
let $restart_parameters = restart: ;
--source include/restart_mysqld.inc
|