Debian Codegraph @

mysql-test/suite/clone/t/local_encrypt.test

raw
1 # Test clone with different table types with debug sync
2
3 --source include/have_innodb_max_16k.inc
4 --source include/have_debug_sync.inc
5 --source include/count_sessions.inc
6
7 --let $CLONE_DATADIR = $MYSQL_TMP_DIR/data_new
8 --let $MYSQLD_DATADIR= `select @@datadir;`
9
10 --source ../include/encrypt_begin.inc
11
12 --echo ## Install plugin
13 --replace_result $CLONE_PLUGIN CLONE_PLUGIN
14 --eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'
15
16 ## Create test schema
17 --source ../include/create_schema.inc
18
19 if(!$page_compression) {
20 --echo # In connection default - starting clone
21 # Validate that redo and undo encryption can be set when clone in progress. */
22 SET DEBUG_SYNC = 'clone_file_copy SIGNAL set_encryption WAIT_FOR resume_clone';
23 --source ../include/clone_command_send.inc
24
25 connect (con1,localhost,root,,);
26 --echo # In connection con1 - Trying to set redo and undo encryption
27 SET DEBUG_SYNC = 'now WAIT_FOR set_encryption';
28
29 SHOW VARIABLES LIKE 'innodb_redo_log_encrypt';
30 SET GLOBAL innodb_redo_log_encrypt = ON;
31 SHOW VARIABLES LIKE 'innodb_redo_log_encrypt';
32
33 SHOW VARIABLES LIKE 'innodb_undo_log_encrypt';
34 SET GLOBAL innodb_undo_log_encrypt = ON;
35 SHOW VARIABLES LIKE 'innodb_undo_log_encrypt';
36
37 SET DEBUG_SYNC = 'now SIGNAL resume_clone';
38
39 connection default;
40 --echo # In connection default - finishing Clone
41 --reap
42 disconnect con1;
43 --force-rmdir $CLONE_DATADIR
44 SET GLOBAL innodb_redo_log_encrypt = OFF;
45 SET GLOBAL innodb_undo_log_encrypt = OFF;
46 }
47
48 # Modify the schema and add compressed table
49 DROP TABLE t1;
50 DROP TABLE t2;
51
52 if(!$page_compression) {
53 # Create table with encryption enabled */
54 CREATE TABLE t1(col1 INT PRIMARY KEY, col2 int, col3 varchar(64), col4 BLOB)
55 ROW_FORMAT = COMPRESSED ENCRYPTION = "Y";
56
57 # Create table in encrypted general tablespace
58 CREATE TABLESPACE tbs1 ADD DATAFILE 'tbs1_data1.ibd' ENCRYPTION="Y";
59 CREATE TABLE t2(col1 INT PRIMARY KEY, col2 int, col3 varchar(64), col4 BLOB)
60 ENCRYPTION="Y" TABLESPACE = tbs1;
61
62 SET GLOBAL innodb_redo_log_encrypt = ON;
63 SHOW VARIABLES LIKE 'innodb_redo_log_encrypt';
64
65 SET GLOBAL innodb_undo_log_encrypt = ON;
66 SHOW VARIABLES LIKE 'innodb_undo_log_encrypt';
67 }
68
69 if($page_compression) {
70 # Create table with encryption and compression enabled.
71 # Disable warning for platforms not supporting punch hole.
72 --disable_warnings
73 CREATE TABLE t1(col1 INT PRIMARY KEY, col2 int, col3 varchar(64), col4 BLOB)
74 COMPRESSION = "LZ4" ENCRYPTION = "Y";
75 --enable_warnings
76
77 # Create table in encrypted general tablespace
78 CREATE TABLESPACE tbs1 ADD DATAFILE 'tbs1_data1.ibd' ENCRYPTION="Y";
79
80 # Create table with ZLIB compression.
81 # Disable warning for platforms not supporting punch hole.
82 --disable_warnings
83 CREATE TABLE t2(col1 INT PRIMARY KEY, col2 int, col3 varchar(64), col4 BLOB)
84 COMPRESSION = "ZLIB";
85 --enable_warnings
86 }
87
88 ## Execute Clone while concurrent DMLs are in progress
89
90 # Insert 200 rows
91 call execute_dml(0, 0, 200, 200, 100, 0);
92
93 # Check base rows
94 SHOW CREATE TABLE t1;
95
96 SELECT count(*) from t1;
97 SELECT col1, col2, col3, SUBSTRING(col4, 1000, 32) FROM t1 ORDER BY col1 LIMIT 10;
98 SELECT col1, col2, col3, SUBSTRING(col4, 1000, 32) FROM t1 ORDER BY col1 DESC LIMIT 10;
99
100 SHOW CREATE TABLE t2;
101 SELECT count(*) from t2;
102 SELECT col1, col2, col3, SUBSTRING(col4, 1000, 32) FROM t2 ORDER BY col1 LIMIT 10;
103 SELECT col1, col2, col3, SUBSTRING(col4, 1000, 32) FROM t2 ORDER BY col1 DESC LIMIT 10;
104
105 ## Test-1: Clone with no redo log to copy.
106 SET GLOBAL innodb_buf_flush_list_now = 1;
107 --source ../include/clone_command.inc
108
109 --echo # Restart cloned database
110 --replace_result $KEYRING_PLUGIN KEYRING_PLUGIN $MYSQL_TMP_DIR MYSQL_TMP_DIR $CLONE_DATADIR CLONE_DATADIR
111 --let $restart_parameters=restart: --datadir=$CLONE_DATADIR --early-plugin-load="keyring_file=$KEYRING_PLUGIN" --keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring
112 --source include/restart_mysqld.inc
113
114 # Check table in cloned database
115 SHOW CREATE TABLE t1;
116 SELECT count(*) from t1;
117 SELECT col1, col3, SUBSTRING(col4, 1000, 32) FROM t1 ORDER BY col1 LIMIT 10;
118 SELECT col1, col3, SUBSTRING(col4, 1000, 32) FROM t1 ORDER BY col1 DESC LIMIT 10;
119
120 SHOW CREATE TABLE t2;
121 SELECT count(*) from t2;
122 SELECT col1, col3, SUBSTRING(col4, 1000, 32) FROM t2 ORDER BY col1 LIMIT 10;
123 SELECT col1, col3, SUBSTRING(col4, 1000, 32) FROM t2 ORDER BY col1 DESC LIMIT 10;
124
125 # Execute procedure to delete all rows and insert
126 call execute_dml(3, 0, 1, 1, 1, 0);
127 call execute_dml(0, 0, 200, 200, 100, 0);
128
129 SELECT col1, col2, col3, SUBSTRING(col4, 1000, 32) FROM t1 ORDER BY col1 LIMIT 10;
130 SELECT col1, col2, col3, SUBSTRING(col4, 1000, 32) FROM t1 ORDER BY col1 DESC LIMIT 10;
131
132 SELECT col1, col2, col3, SUBSTRING(col4, 1000, 32) FROM t2 ORDER BY col1 LIMIT 10;
133
134 --replace_result $KEYRING_PLUGIN KEYRING_PLUGIN $MYSQL_TMP_DIR MYSQL_TMP_DIR $ENCRYPT_DATADIR ENCRYPT_DATADIR
135 --let $restart_parameters=restart: --datadir=$ENCRYPT_DATADIR --early-plugin-load="keyring_file=$KEYRING_PLUGIN" --keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring
136 --source include/restart_mysqld.inc
137 --force-rmdir $CLONE_DATADIR
138
139 ## Test-2: Clone with dirty pages and redo log
140 SET GLOBAL innodb_redo_log_encrypt = ON;
141 SET GLOBAL innodb_undo_log_encrypt = ON;
142
143 --echo # In connection default - Cloning database
144 SET DEBUG_SYNC = 'clone_file_copy SIGNAL start_dml1 WAIT_FOR resume_clone1';
145 SET DEBUG_SYNC = 'clone_page_copy SIGNAL start_dml2 WAIT_FOR resume_clone2';
146 --source ../include/clone_command_send.inc
147
148 --echo # In connection con1 - Running Update Random [0 - 200 Key Range]
149 connect (con1,localhost,root,,);
150 SET DEBUG_SYNC = 'now WAIT_FOR start_dml1';
151 START TRANSACTION;
152 CALL execute_dml(1, 0, 200, 500, 100, 1);
153 COMMIT;
154 --echo # Flush all dirty buffers
155 SET GLOBAL innodb_buf_flush_list_now = 1;
156 SET DEBUG_SYNC = 'now SIGNAL resume_clone1';
157
158 SET DEBUG_SYNC = 'now WAIT_FOR start_dml2';
159 START TRANSACTION;
160 CALL execute_dml(1, 0, 200, 500, 100, 1);
161 COMMIT;
162 SET DEBUG_SYNC = 'now SIGNAL resume_clone2';
163
164 connection default;
165 --echo # In connection default - Cloning database
166 --reap
167
168 disconnect con1;
169 --source include/wait_until_count_sessions.inc
170
171 --echo # Restart cloned database
172 --replace_result $KEYRING_PLUGIN KEYRING_PLUGIN $MYSQL_TMP_DIR MYSQL_TMP_DIR $CLONE_DATADIR CLONE_DATADIR
173 --let $restart_parameters=restart: --datadir=$CLONE_DATADIR --early-plugin-load="keyring_file=$KEYRING_PLUGIN" --keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring
174 --source include/restart_mysqld.inc
175
176 # Check table in cloned database
177 SHOW CREATE TABLE t1;
178 SELECT count(*) from t1;
179 SELECT col1, col3, SUBSTRING(col4, 1000, 32) FROM t1 ORDER BY col1 LIMIT 10;
180 SELECT col1, col3, SUBSTRING(col4, 1000, 32) FROM t1 ORDER BY col1 DESC LIMIT 10;
181
182 SHOW CREATE TABLE t2;
183 SELECT count(*) from t2;
184 SELECT col1, col3, SUBSTRING(col4, 1000, 32) FROM t2 ORDER BY col1 LIMIT 10;
185 SELECT col1, col3, SUBSTRING(col4, 1000, 32) FROM t2 ORDER BY col1 DESC LIMIT 10;
186
187 # Execute procedure to delete all rows and insert
188 call execute_dml(3, 0, 1, 1, 1, 0);
189 call execute_dml(0, 0, 200, 200, 100, 0);
190
191 SELECT col1, col2, col3, SUBSTRING(col4, 1000, 32) FROM t1 ORDER BY col1 LIMIT 10;
192 SELECT col1, col2, col3, SUBSTRING(col4, 1000, 32) FROM t1 ORDER BY col1 DESC LIMIT 10;
193
194 SELECT col1, col2, col3, SUBSTRING(col4, 1000, 32) FROM t2 ORDER BY col1 LIMIT 10;
195 SELECT col1, col2, col3, SUBSTRING(col4, 1000, 32) FROM t2 ORDER BY col1 DESC LIMIT 10;
196
197 --replace_result $KEYRING_PLUGIN KEYRING_PLUGIN $MYSQL_TMP_DIR MYSQL_TMP_DIR $ENCRYPT_DATADIR ENCRYPT_DATADIR
198 --let $restart_parameters=restart: --datadir=$ENCRYPT_DATADIR --early-plugin-load="keyring_file=$KEYRING_PLUGIN" --keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring
199 --source include/restart_mysqld.inc
200 --force-rmdir $CLONE_DATADIR
201
202 # Cleanup
203 --source ../include/drop_schema.inc
204 DROP TABLESPACE tbs1;
205 UNINSTALL PLUGIN clone;
206 UNINSTALL PLUGIN keyring_file;
207 SET DEBUG_SYNC = 'RESET';
208
209 --source ../include/encrypt_end.inc