| 1 |
######################################################################### |
| 2 |
# START : WITHOUT KEYRING PLUGIN |
| 3 |
######################################################################### |
| 4 |
|
| 5 |
######### |
| 6 |
# SETUP # |
| 7 |
######### |
| 8 |
CREATE TABLESPACE encrypt_ts ADD DATAFILE 'encrypt_ts.ibd' |
| 9 |
ENGINE=InnoDB ENCRYPTION="N"; |
| 10 |
CREATE TABLE t1(c1 char(100)) ENGINE=InnoDB TABLESPACE encrypt_ts; |
| 11 |
set global innodb_buf_flush_list_now = 1; |
| 12 |
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES |
| 13 |
WHERE NAME='encrypt_ts'; |
| 14 |
NAME ENCRYPTION |
| 15 |
encrypt_ts N |
| 16 |
SELECT * FROM t1 LIMIT 10; |
| 17 |
c1 |
| 18 |
SOME VALUES |
| 19 |
SOME VALUES |
| 20 |
SOME VALUES |
| 21 |
SOME VALUES |
| 22 |
SOME VALUES |
| 23 |
SOME VALUES |
| 24 |
SOME VALUES |
| 25 |
SOME VALUES |
| 26 |
SOME VALUES |
| 27 |
SOME VALUES |
| 28 |
ALTER TABLESPACE encrypt_ts ENCRYPTION='Y'; |
| 29 |
ERROR HY000: Can't find master key from keyring, please check in the server log if a keyring is loaded and initialized successfully. |
| 30 |
######################################################################### |
| 31 |
# RESTART 1 : WITH KEYRING PLUGIN |
| 32 |
######################################################################### |
| 33 |
# Monitoring connection |
| 34 |
UPDATE performance_schema.setup_consumers SET ENABLED='YES'; |
| 35 |
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES |
| 36 |
WHERE NAME='encrypt_ts'; |
| 37 |
NAME ENCRYPTION |
| 38 |
encrypt_ts N |
| 39 |
SELECT * FROM performance_schema.setup_consumers |
| 40 |
WHERE NAME LIKE "%stages%"; |
| 41 |
NAME ENABLED |
| 42 |
events_stages_current YES |
| 43 |
events_stages_history YES |
| 44 |
events_stages_history_long YES |
| 45 |
SELECT * FROM performance_schema.setup_instruments |
| 46 |
WHERE NAME LIKE "%encryption%"; |
| 47 |
NAME ENABLED TIMED PROPERTIES FLAGS VOLATILITY DOCUMENTATION |
| 48 |
wait/synch/mutex/innodb/resume_encryption_cond_mutex YES YES NULL 0 NULL |
| 49 |
wait/synch/cond/innodb/resume_encryption_cond YES YES NULL 0 NULL |
| 50 |
stage/innodb/alter tablespace (encryption) YES YES progress NULL 0 NULL |
| 51 |
select count(*) from performance_schema.events_stages_current |
| 52 |
WHERE EVENT_NAME='stage/innodb/alter tablespace (encryption)'; |
| 53 |
count(*) |
| 54 |
0 |
| 55 |
# Default connection |
| 56 |
############################################################ |
| 57 |
# ALTER TABLESPACE 1 : Unencrypted => Encrypted # |
| 58 |
############################################################ |
| 59 |
|
| 60 |
# Set Encryption process to wait after page 5 so that we can monitor |
| 61 |
# progress in performance_schema table |
| 62 |
SET DEBUG_SYNC = 'alter_encrypt_tablespace_wait_after_page5 SIGNAL s1 WAIT_FOR s2'; |
| 63 |
ALTER TABLESPACE encrypt_ts ENCRYPTION='Y'; |
| 64 |
# Monitoring connection |
| 65 |
SET DEBUG_SYNC = 'now WAIT_FOR s1'; |
| 66 |
# Wait for Encryption progress monitoring to appear in PFS table |
| 67 |
# Wait for some progress to appear in PFS table |
| 68 |
select WORK_ESTIMATED > WORK_COMPLETED, WORK_COMPLETED |
| 69 |
FROM performance_schema.events_stages_current |
| 70 |
WHERE EVENT_NAME = 'stage/innodb/alter tablespace (encryption)'; |
| 71 |
WORK_ESTIMATED > WORK_COMPLETED WORK_COMPLETED |
| 72 |
1 5 |
| 73 |
SET DEBUG_SYNC = 'now SIGNAL s2'; |
| 74 |
# Default connection |
| 75 |
# Once done, select count from PFS tables |
| 76 |
SELECT COUNT(*) |
| 77 |
FROM performance_schema.events_stages_current |
| 78 |
WHERE EVENT_NAME='stage/innodb/alter tablespace (encryption)'; |
| 79 |
COUNT(*) |
| 80 |
0 |
| 81 |
SELECT COUNT(*) |
| 82 |
FROM performance_schema.events_stages_history |
| 83 |
WHERE EVENT_NAME='stage/innodb/alter tablespace (encryption)'; |
| 84 |
COUNT(*) |
| 85 |
1 |
| 86 |
SELECT COUNT(*) |
| 87 |
FROM performance_schema.events_stages_history_long |
| 88 |
WHERE EVENT_NAME='stage/innodb/alter tablespace (encryption)'; |
| 89 |
COUNT(*) |
| 90 |
1 |
| 91 |
SELECT COUNT(*) |
| 92 |
FROM performance_schema.events_stages_summary_global_by_event_name |
| 93 |
WHERE EVENT_NAME = 'stage/innodb/alter tablespace (encryption)' AND |
| 94 |
COUNT_STAR>0; |
| 95 |
COUNT(*) |
| 96 |
1 |
| 97 |
COUNT(*) |
| 98 |
1 |
| 99 |
SELECT COUNT(*) |
| 100 |
FROM performance_schema.events_stages_summary_by_user_by_event_name |
| 101 |
WHERE EVENT_NAME = 'stage/innodb/alter tablespace (encryption)' AND |
| 102 |
COUNT_STAR>0; |
| 103 |
COUNT(*) |
| 104 |
1 |
| 105 |
SELECT COUNT(*) |
| 106 |
FROM performance_schema.events_stages_summary_by_host_by_event_name |
| 107 |
WHERE EVENT_NAME = 'stage/innodb/alter tablespace (encryption)' AND |
| 108 |
COUNT_STAR>0; |
| 109 |
COUNT(*) |
| 110 |
1 |
| 111 |
SELECT COUNT(*) |
| 112 |
FROM performance_schema.events_stages_summary_by_account_by_event_name |
| 113 |
WHERE EVENT_NAME = 'stage/innodb/alter tablespace (encryption)' AND |
| 114 |
COUNT_STAR>0; |
| 115 |
COUNT(*) |
| 116 |
1 |
| 117 |
# Check that Encryption done successfully. |
| 118 |
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES |
| 119 |
WHERE NAME='encrypt_ts'; |
| 120 |
NAME ENCRYPTION |
| 121 |
encrypt_ts Y |
| 122 |
SELECT * FROM t1 LIMIT 10; |
| 123 |
c1 |
| 124 |
SOME VALUES |
| 125 |
SOME VALUES |
| 126 |
SOME VALUES |
| 127 |
SOME VALUES |
| 128 |
SOME VALUES |
| 129 |
SOME VALUES |
| 130 |
SOME VALUES |
| 131 |
SOME VALUES |
| 132 |
SOME VALUES |
| 133 |
SOME VALUES |
| 134 |
######################################################################### |
| 135 |
# RESTART 2 : WITHOUT KEYRING PLUGIN |
| 136 |
######################################################################### |
| 137 |
SELECT * FROM t1 LIMIT 10; |
| 138 |
ERROR HY000: Can't find master key from keyring, please check in the server log if a keyring is loaded and initialized successfully. |
| 139 |
######################################################################### |
| 140 |
# RESTART 3 : WITH KEYRING PLUGIN |
| 141 |
######################################################################### |
| 142 |
UPDATE performance_schema.setup_consumers SET ENABLED='NO'; |
| 143 |
ALTER TABLESPACE encrypt_ts ENCRYPTION='N'; |
| 144 |
########### |
| 145 |
# Cleanup # |
| 146 |
########### |
| 147 |
SELECT COUNT(*) FROM t1; |
| 148 |
COUNT(*) |
| 149 |
32 |
| 150 |
DROP TABLE t1; |
| 151 |
DROP TABLESPACE encrypt_ts; |
| 152 |
# restart: |