| 1 |
######### |
| 2 |
# SETUP # |
| 3 |
######### |
| 4 |
|
| 5 |
######################################################################### |
| 6 |
# RESTART 1 : WITH KEYRING PLUGIN |
| 7 |
######################################################################### |
| 8 |
# Create a new 'unencrypted' tablespace 'encrypt_ts' |
| 9 |
SELECT NAME, FLAG, SPACE_TYPE FROM information_schema.INNODB_TABLESPACES |
| 10 |
where NAME="encrypt_ts"; |
| 11 |
NAME FLAG SPACE_TYPE |
| 12 |
create tablespace encrypt_ts add datafile 'encrypt_ts.ibd' |
| 13 |
engine=INNODB encryption='N'; |
| 14 |
SELECT NAME, FLAG, SPACE_TYPE FROM information_schema.INNODB_TABLESPACES |
| 15 |
where NAME="encrypt_ts"; |
| 16 |
NAME FLAG SPACE_TYPE |
| 17 |
encrypt_ts 18432 General |
| 18 |
# Create a table test.t1 in 'encrypt_ts' tablespace and insert some records. |
| 19 |
create table test.t1 (c char(20)) tablespace encrypt_ts; |
| 20 |
insert into test.t1 values ("samplerecord"); |
| 21 |
set global innodb_buf_flush_list_now = 1; |
| 22 |
############################################################# |
| 23 |
# INITIAL SETUP : Tablespace is created as unencrypted # |
| 24 |
# A table is created and rows are inserted # |
| 25 |
############################################################# |
| 26 |
# Check that tablespace file is not encrypted yet |
| 27 |
# Print result |
| 28 |
table space is Unencrypted. |
| 29 |
############################################################ |
| 30 |
# ALTER TABLESPACE 1 : Unencrypted => Encrypted # |
| 31 |
############################################################ |
| 32 |
ALTER TABLESPACE encrypt_ts ENCRYPTION='Y'; |
| 33 |
set global innodb_buf_flush_list_now = 1; |
| 34 |
# Check that tablespace file is encrypted now |
| 35 |
# Print result |
| 36 |
table space is Encrypted. |
| 37 |
############################################################ |
| 38 |
# ALTER TABLESPACE 2 : Encrypted => Unencrypted # |
| 39 |
############################################################ |
| 40 |
ALTER TABLESPACE encrypt_ts ENCRYPTION='N'; |
| 41 |
set global innodb_buf_flush_list_now = 1; |
| 42 |
# Check that tablespace file is not encrypted now |
| 43 |
# Print result |
| 44 |
table space is Unencrypted. |
| 45 |
|
| 46 |
################# CRASH/RECOVERY TESTING ################### |
| 47 |
|
| 48 |
############################################################ |
| 49 |
# ALTER TABLESPACE 3 : Unencrypted => Encrypted # |
| 50 |
# (crash at page 10) # |
| 51 |
############################################################ |
| 52 |
SELECT COUNT(*) FROM test.t1; |
| 53 |
COUNT(*) |
| 54 |
4096 |
| 55 |
set global innodb_buf_flush_list_now = 1; |
| 56 |
# Check that tablespace file is still unencrypted |
| 57 |
# Print result |
| 58 |
table space is Unencrypted. |
| 59 |
# Set Encryption process to crash at page 10 |
| 60 |
SET SESSION debug= '+d,alter_encrypt_tablespace_page_10'; |
| 61 |
ALTER TABLESPACE encrypt_ts ENCRYPTION='Y'; |
| 62 |
# Wait for Encryption processing to finish in background thread |
| 63 |
# After restart/recovery, check that Encryption was roll-forward and |
| 64 |
# tablespace file is encrypted now |
| 65 |
# Print result |
| 66 |
table space is Encrypted. |
| 67 |
############################################################ |
| 68 |
# ALTER TABLESPACE 4 : Encrypted => Unencrypted # |
| 69 |
# (crash at page 10) # |
| 70 |
############################################################ |
| 71 |
SELECT COUNT(*) FROM test.t1; |
| 72 |
COUNT(*) |
| 73 |
4096 |
| 74 |
# Check that tablespace file is Encrypted |
| 75 |
# Print result |
| 76 |
table space is Encrypted. |
| 77 |
# Set Encryption process to crash after page 10 |
| 78 |
SET SESSION debug= '+d,alter_encrypt_tablespace_page_10'; |
| 79 |
ALTER TABLESPACE encrypt_ts ENCRYPTION='N'; |
| 80 |
# Wait for Unencryption processing to finish in background thread |
| 81 |
# After restart/recovery, check that Unencryption was roll-forward and |
| 82 |
# tablespace file is Unencrypted now |
| 83 |
# Print result |
| 84 |
table space is Unencrypted. |
| 85 |
########### |
| 86 |
# CLEANUP # |
| 87 |
########### |
| 88 |
DROP TABLE test.t1; |
| 89 |
DROP TABLESPACE encrypt_ts; |
| 90 |
# Restarting server without keyring to restore server state |
| 91 |
# restart: |