Debian Codegraph @

mysql-test/suite/innodb/t/tablespace_encrypt_7.test

raw
1 ################################################################################
2 # InnoDB transparent tablespace data encryption for general shared tablespace.
3 # This test case will test
4 # - Test 0 : Crash just after inserting DDL Log
5 # - Test 1
6 # - 1.1 : Crash just before flushing page 0 at the end of (un)encryption
7 # - 1.2 : Crash just after flushing page 0 at the end of (un)encryption
8 # - Test 2
9 # - 2.1 : Crash just before updating tablespace flags on page 0
10 # - 2.2 : Crash just before resetting progress on page 0
11 # - Test 3
12 # - A scneario in which tablespace key found during REDO log scan is
13 # old whereas tablespace key on disk is new. Here, REDO log scan key
14 # should be discarded and new tablespace key should be used instead.
15 ################################################################################
16
17 --source include/big_test.inc
18 --source include/have_debug.inc
19 # --source include/no_valgrind_without_big.inc
20 # Disable in valgrind because of timeout, cf. Bug#22760145
21 --source include/not_valgrind.inc
22 # Waiting time when (re)starting the server
23 --let $explicit_default_wait_counter=10000
24
25 --disable_query_log
26 call mtr.add_suppression("ibd can't be decrypted, please confirm the keyring is loaded.");
27 call mtr.add_suppression("\\[ERROR\\] \\[[^]]*\\] \\[[^]]*\\] Encryption can't find master key, please check the keyring is loaded.");
28 call mtr.add_suppression("\\[ERROR\\] \\[[^]]*\\] \\[[^]]*\\] Check keyring fail, please check the keyring is loaded.");
29 call mtr.add_suppression("\\[ERROR\\] \\[[^]]*\\] \\[[^]]*\\] Failed to decrypt encryption information, found unexpected version of it!");
30 call mtr.add_suppression("\\[Warning\\] \\[MY-013675\\] \\[InnoDB\\] Encryption key missing: space_id=");
31 call mtr.add_suppression("\\[Warning\\] \\[MY-013674\\] \\[InnoDB\\] Decrypting a page in doublewrite file failed: space_id=");
32 call mtr.add_suppression("\\[ERROR\\] \\[[^]]*\\] \\[[^]]*\\] Encryption information in datafile: .* can't be decrypted, please confirm that keyring is loaded.");
33 --enable_query_log
34
35 --echo #########################################################################
36 --echo # START : WITHOUT KEYRING PLUGIN
37 --echo #########################################################################
38 --echo
39 --echo #########
40 --echo # SETUP #
41 --echo #########
42
43 # Create an Unencrypted tablespace
44 CREATE TABLESPACE encrypt_ts ADD DATAFILE 'encrypt_ts.ibd' ENGINE=InnoDB ENCRYPTION="N";
45 # Create an unencrypted table in tablespace
46 CREATE TABLE t1(c1 char(100)) ENGINE=InnoDB TABLESPACE encrypt_ts;
47 # Insert few rows in table
48 --disable_query_log
49 INSERT INTO t1 VALUES ("SOME VALUES");
50 let $counter=12;
51 while ($counter>0)
52 {
53 INSERT INTO test.t1 SELECT * FROM test.t1;
54 dec $counter;
55 }
56 --enable_query_log
57
58 # Make sure ts file is updated with new records in table
59 set global innodb_buf_flush_list_now = 1;
60
61 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
62 SELECT * FROM t1 LIMIT 10;
63
64 # Try to alter tablespace to be encrypted. Should fail as keyring is not laoded.
65 --error ER_CANNOT_FIND_KEY_IN_KEYRING
66 ALTER TABLESPACE encrypt_ts ENCRYPTION='Y';
67
68 --let $rc=1
69 --echo #-------------------------- TEST 0 -------------------------------------#
70
71 --echo #########################################################################
72 --echo # RESTART $rc : WITH KEYRING PLUGIN
73 --echo #########################################################################
74 let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
75 --source include/restart_mysqld_no_echo.inc
76 --inc $rc
77
78 --echo ########################################################################
79 --echo # ALTER TABLESPACE 1 : Unencrypted => Encrypted #
80 --echo # crash just before flushing page 0 at the end #
81 --echo ########################################################################
82 --echo # Set process to crash just before flushing page 0 at the end
83 SET SESSION debug= '+d,alter_encrypt_tablespace_crash_after_ddl_entry';
84
85 --echo # Encrypt the tablespace. It will cause crash.
86 --source include/expect_crash.inc
87 --error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
88 ALTER TABLESPACE encrypt_ts ENCRYPTION='Y';
89
90 --echo #########################################################################
91 --echo # RESTART $rc : WITH KEYRING PLUGIN after crash
92 --echo #########################################################################
93 let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
94 --source include/start_mysqld_no_echo.inc
95 --inc $rc
96
97 --echo # Wait for Encryption processing to finish in background thread
98 let $wait_condition = SELECT ENCRYPTION = 'Y'
99 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
100 WHERE NAME='encrypt_ts';
101 --source include/wait_condition.inc
102
103 # Make sure ts file is updated with new records in table
104 set global innodb_buf_flush_list_now = 1;
105
106 --echo # After restart/recovery, check that Encryption was roll-forward
107 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
108 SELECT * FROM t1 LIMIT 10;
109
110 --echo #########################################################################
111 --echo # RESTART $rc : WITHOUT KEYRING PLUGIN
112 --echo #########################################################################
113 let $restart_parameters = restart:;
114 --source include/restart_mysqld_no_echo.inc
115 --inc $rc
116
117 # We shouldn't be able to read t1 records as it is encrypted now and keyring
118 # plugin is not loaded.
119 --error ER_CANNOT_FIND_KEY_IN_KEYRING
120 SELECT * FROM t1 LIMIT 10;
121
122 --echo #########################################################################
123 --echo # RESTART $rc : WITH KEYRING PLUGIN
124 --echo #########################################################################
125 let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
126 --source include/restart_mysqld_no_echo.inc
127 --inc $rc
128
129 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
130 SELECT * FROM t1 LIMIT 10;
131
132 --echo ########################################################################
133 --echo # ALTER TABLESPACE 2 : Encrypted => Unencrypted #
134 --echo # crash just before flushing page 0 at the end #
135 --echo ########################################################################
136 --echo # Set process to crash just before flushing page 0 at the end
137 SET SESSION debug= '+d,alter_encrypt_tablespace_crash_after_ddl_entry';
138
139 --echo # Unencrypt the tablespace. It will cause crash.
140 --source include/expect_crash.inc
141 --error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
142 ALTER TABLESPACE encrypt_ts ENCRYPTION='N';
143
144 --echo #########################################################################
145 --echo # RESTART $rc : WITH KEYRING PLUGIN after crash
146 --echo #########################################################################
147 #let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT --debug=+d,DDL_Log_remove_inject_startup_error_2;
148 let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
149 --source include/start_mysqld_no_echo.inc
150 --inc $rc
151
152 --echo # Wait for Unencryption processing to finish in background thread
153 let $wait_condition = SELECT ENCRYPTION = 'N'
154 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
155 WHERE NAME='encrypt_ts';
156 --source include/wait_condition.inc
157
158 # Make sure ts file is updated with new records in table
159 set global innodb_buf_flush_list_now = 1;
160
161 --echo # After restart/recovery, check that Unencryption was roll-forward
162 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
163 SELECT * FROM t1 LIMIT 10;
164
165 --echo #########################################################################
166 --echo # RESTART $rc : WITHOUT KEYRING PLUGIN
167 --echo #########################################################################
168 let $restart_parameters = restart:;
169 --source include/restart_mysqld_no_echo.inc
170 --inc $rc
171
172 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
173 # We should be able to read t1 records even without keyring plugin as it should
174 # be unencrypted now.
175 SELECT * FROM t1 LIMIT 10;
176
177 # --echo #-------------------------- TEST 1 -------------------------------------#
178
179 --echo #########################################################################
180 --echo # RESTART $rc : WITH KEYRING PLUGIN
181 --echo #########################################################################
182 let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
183 --source include/restart_mysqld_no_echo.inc
184 --inc $rc
185
186 --echo ########################################################################
187 --echo # ALTER TABLESPACE 1 : Unencrypted => Encrypted #
188 --echo # crash just before flushing page 0 at the end #
189 --echo ########################################################################
190 --echo # Set process to crash just before flushing page 0 at the end
191 SET SESSION debug= '+d,alter_encrypt_tablespace_crash_before_flushing_page_0';
192
193 --echo # Encrypt the tablespace. It will cause crash.
194 --source include/expect_crash.inc
195 --error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
196 ALTER TABLESPACE encrypt_ts ENCRYPTION='Y';
197
198 --echo #########################################################################
199 --echo # RESTART $rc : WITH KEYRING PLUGIN after crash
200 --echo #########################################################################
201 #let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT --debug=+d,DDL_Log_remove_inject_startup_error_1;
202 let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
203 --source include/start_mysqld_no_echo.inc
204 --inc $rc
205
206 --echo # Wait for Encryption processing to finish in background thread
207 let $wait_condition = SELECT ENCRYPTION = 'Y'
208 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
209 WHERE NAME='encrypt_ts';
210 --source include/wait_condition.inc
211
212 # Make sure ts file is updated with new records in table
213 set global innodb_buf_flush_list_now = 1;
214
215 --echo # After restart/recovery, check that Encryption was roll-forward
216 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
217 SELECT * FROM t1 LIMIT 10;
218
219 --echo #########################################################################
220 --echo # RESTART $rc : WITHOUT KEYRING PLUGIN
221 --echo #########################################################################
222 let $restart_parameters = restart:;
223 --source include/restart_mysqld_no_echo.inc
224 --inc $rc
225
226 # We shouldn't be able to read t1 records as it is encrypted now and keyring
227 # plugin is not loaded.
228 --error ER_CANNOT_FIND_KEY_IN_KEYRING
229 SELECT * FROM t1 LIMIT 10;
230
231 --echo #########################################################################
232 --echo # RESTART $rc : WITH KEYRING PLUGIN
233 --echo #########################################################################
234 let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
235 --source include/restart_mysqld_no_echo.inc
236 --inc $rc
237
238 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
239 SELECT * FROM t1 LIMIT 10;
240
241 --echo ########################################################################
242 --echo # ALTER TABLESPACE 2 : Encrypted => Unencrypted #
243 --echo # crash just before flushing page 0 at the end #
244 --echo ########################################################################
245 --echo # Set process to crash just before flushing page 0 at the end
246 SET SESSION debug= '+d,alter_encrypt_tablespace_crash_before_flushing_page_0';
247
248 --echo # Unencrypt the tablespace. It will cause crash.
249 --source include/expect_crash.inc
250 --error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
251 ALTER TABLESPACE encrypt_ts ENCRYPTION='N';
252
253 --echo #########################################################################
254 --echo # RESTART $rc : WITH KEYRING PLUGIN after crash
255 --echo #########################################################################
256 #let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT --debug=+d,DDL_Log_remove_inject_startup_error_2;
257 let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
258 --source include/start_mysqld_no_echo.inc
259 --inc $rc
260
261 --echo # Wait for Unencryption processing to finish in background thread
262 let $wait_condition = SELECT ENCRYPTION = 'N'
263 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
264 WHERE NAME='encrypt_ts';
265 --source include/wait_condition.inc
266
267 # Make sure ts file is updated with new records in table
268 set global innodb_buf_flush_list_now = 1;
269
270 --echo # After restart/recovery, check that Unencryption was roll-forward
271 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
272 SELECT * FROM t1 LIMIT 10;
273
274 --echo #########################################################################
275 --echo # RESTART $rc : WITHOUT KEYRING PLUGIN
276 --echo #########################################################################
277 let $restart_parameters = restart:;
278 --source include/restart_mysqld_no_echo.inc
279 --inc $rc
280
281 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
282 # We should be able to read t1 records even without keyring plugin as it should
283 # be unencrypted now.
284 SELECT * FROM t1 LIMIT 10;
285
286 --echo #########################################################################
287 --echo # RESTART $rc : WITH KEYRING PLUGIN
288 --echo #########################################################################
289 let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
290 --source include/restart_mysqld_no_echo.inc
291 --inc $rc
292
293 --echo ########################################################################
294 --echo # ALTER TABLESPACE 3 : Unencrypted => Encrypted #
295 --echo # crash just after flushing page 0 at the end #
296 --echo ########################################################################
297 --echo # Set process to crash just after flushing page 0 at the end
298 SET SESSION debug= '+d,alter_encrypt_tablespace_crash_after_flushing_page_0';
299
300 --echo # Encrypt the tablespace. It will cause crash.
301 --source include/expect_crash.inc
302 --error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
303 ALTER TABLESPACE encrypt_ts ENCRYPTION='Y';
304
305 --echo #########################################################################
306 --echo # RESTART $rc : WITH KEYRING PLUGIN after crash
307 --echo #########################################################################
308 --source include/start_mysqld_no_echo.inc
309 --inc $rc
310
311 --echo # Wait for Encryption processing to finish in background thread
312 let $wait_condition = SELECT ENCRYPTION = 'Y'
313 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
314 WHERE NAME='encrypt_ts';
315 --source include/wait_condition.inc
316
317 # Make sure ts file is updated with new records in table
318 set global innodb_buf_flush_list_now = 1;
319
320 --echo # After restart/recovery, check that Encryption was roll-forward
321 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
322 SELECT * FROM t1 LIMIT 10;
323
324 --echo #########################################################################
325 --echo # RESTART $rc : WITHOUT KEYRING PLUGIN
326 --echo #########################################################################
327 let $restart_parameters = restart:;
328 --source include/restart_mysqld_no_echo.inc
329 --inc $rc
330
331 # We shouldn't be able to read t1 records as it is encrypted now and keyring
332 # plugin is not loaded.
333 --error ER_CANNOT_FIND_KEY_IN_KEYRING
334 SELECT * FROM t1 LIMIT 10;
335
336 --echo #########################################################################
337 --echo # RESTART $rc : WITH KEYRING PLUGIN
338 --echo #########################################################################
339 let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
340 --source include/restart_mysqld_no_echo.inc
341 --inc $rc
342
343 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
344 SELECT * FROM t1 LIMIT 10;
345
346 --echo ########################################################################
347 --echo # ALTER TABLESPACE 4 : Encrypted => Unencrypted #
348 --echo # crash just after flushing page 0 at the end #
349 --echo ########################################################################
350 --echo # Set process to crash just after flushing page 0 at the end
351 SET SESSION debug= '+d,alter_encrypt_tablespace_crash_after_flushing_page_0';
352
353 --echo # Unencrypt the tablespace. It will cause crash.
354 --source include/expect_crash.inc
355 --error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
356 ALTER TABLESPACE encrypt_ts ENCRYPTION='N';
357
358 --echo #########################################################################
359 --echo # RESTART $rc : WITH KEYRING PLUGIN after crash
360 --echo #########################################################################
361 --source include/start_mysqld_no_echo.inc
362 --inc $rc
363
364 --echo # Wait for Unencryption processing to finish in background thread
365 let $wait_condition = SELECT ENCRYPTION = 'N'
366 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
367 WHERE NAME='encrypt_ts';
368 --source include/wait_condition.inc
369
370 # Make sure ts file is updated with new records in table
371 set global innodb_buf_flush_list_now = 1;
372
373 --echo # After restart/recovery, check that Unencryption was roll-forward
374 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
375 SELECT * FROM t1 LIMIT 10;
376
377 --echo #########################################################################
378 --echo # RESTART $rc : WITHOUT KEYRING PLUGIN
379 --echo #########################################################################
380 let $restart_parameters = restart:;
381 --source include/restart_mysqld_no_echo.inc
382 --inc $rc
383
384 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
385 # We should be able to read t1 records even without keyring plugin as it should
386 # be unencrypted now.
387 SELECT * FROM t1 LIMIT 10;
388
389 --echo #-------------------------- TEST 2 -------------------------------------#
390
391 --echo #########################################################################
392 --echo # RESTART $rc : WITH KEYRING PLUGIN
393 --echo # and INJECT error TOO_MANY_CONCURRENT_TXNS in startup location #3
394 --echo #########################################################################
395 #let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT --debug=+d,DDL_Log_remove_inject_startup_error_3;
396 let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
397 --source include/restart_mysqld_no_echo.inc
398 --inc $rc
399
400 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
401 SELECT * FROM t1 LIMIT 10;
402
403 --echo ########################################################################
404 --echo # ALTER TABLESPACE 5 : Encrypted => unencrypted #
405 --echo # crash just before updating ts flags on page0 #
406 --echo ########################################################################
407 ALTER TABLESPACE encrypt_ts ENCRYPTION='Y';
408 --echo # Set process to crash just after flushing page 0 at the end
409 SET SESSION debug= '+d,alter_encrypt_tablespace_crash_before_updating_flags';
410
411 --echo # Unencrypt the tablespace. It will cause crash.
412 --source include/expect_crash.inc
413 --error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
414 ALTER TABLESPACE encrypt_ts ENCRYPTION='N';
415
416 --echo #########################################################################
417 --echo # RESTART $rc : WITH KEYRING PLUGIN after crash
418 --echo #########################################################################
419 --source include/start_mysqld_no_echo.inc
420 --inc $rc
421
422 --echo # Wait for Unencryption processing to finish in background thread
423 let $wait_condition = SELECT ENCRYPTION = 'N'
424 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
425 WHERE NAME='encrypt_ts';
426 --source include/wait_condition.inc
427
428 # Make sure ts file is updated with new records in table
429 set global innodb_buf_flush_list_now = 1;
430
431 --echo # After restart/recovery, check that Unencryption was roll-forward
432 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
433 SELECT * FROM t1 LIMIT 10;
434
435 --echo #########################################################################
436 --echo # RESTART $rc : WITHOUT KEYRING PLUGIN
437 --echo #########################################################################
438 let $restart_parameters = restart:;
439 --source include/restart_mysqld_no_echo.inc
440 --inc $rc
441
442 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
443 # We should be able to read t1 records even without keyring plugin as it should
444 # be unencrypted now.
445 SELECT * FROM t1 LIMIT 10;
446
447 --echo #########################################################################
448 --echo # RESTART $rc : WITH KEYRING PLUGIN
449 --echo #########################################################################
450 let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
451 --source include/restart_mysqld_no_echo.inc
452 --inc $rc
453
454 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
455 SELECT * FROM t1 LIMIT 10;
456
457 --echo ########################################################################
458 --echo # ALTER TABLESPACE 6 : Encrypted => unencrypted #
459 --echo # crash just before resetting progress onpage 0 #
460 --echo ########################################################################
461 ALTER TABLESPACE encrypt_ts ENCRYPTION='Y';
462 --echo # Set process to crash just after flushing page 0 at the end
463 SET SESSION debug= '+d,alter_encrypt_tablespace_crash_before_resetting_progress';
464
465 --echo # Unencrypt the tablespace. It will cause crash.
466 --source include/expect_crash.inc
467 --error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
468 ALTER TABLESPACE encrypt_ts ENCRYPTION='N';
469
470 --echo #########################################################################
471 --echo # RESTART $rc : WITH KEYRING PLUGIN after crash
472 --echo #########################################################################
473 --source include/start_mysqld_no_echo.inc
474 --inc $rc
475
476 --echo # Wait for Unencryption processing to finish in background thread
477 let $wait_condition = SELECT ENCRYPTION = 'N'
478 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
479 WHERE NAME='encrypt_ts';
480 --source include/wait_condition.inc
481
482 # Make sure ts file is updated with new records in table
483 set global innodb_buf_flush_list_now = 1;
484
485 --echo # After restart/recovery, check that Unencryption was roll-forward
486 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
487 SELECT * FROM t1 LIMIT 10;
488
489 --echo #########################################################################
490 --echo # RESTART $rc: WITHOUT KEYRING PLUGIN
491 --echo #########################################################################
492 let $restart_parameters = restart:;
493 --source include/restart_mysqld_no_echo.inc
494 --inc $rc
495
496 SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
497 # We should be able to read t1 records even without keyring plugin as it should
498 # be unencrypted now.
499 SELECT * FROM t1 LIMIT 10;
500
501 --echo #-------------------------- TEST 3 -------------------------------------#
502
503 --echo #########################################################################
504 --echo # RESTART $rc : WITH KEYRING PLUGIN
505 --echo #########################################################################
506 let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT --innodb_doublewrite=0;
507 --source include/restart_mysqld_no_echo.inc
508 --inc $rc
509
510 DROP TABLE t1;
511 DROP TABLESPACE encrypt_ts;
512 CREATE TABLESPACE encrypt_ts ADD DATAFILE 'encrypt_ts.ibd';
513 CREATE TABLE t1 (C CHAR(10)) TABLESPACE=encrypt_ts;
514 SET GLOBAL innodb_limit_optimistic_insert_debug=2;
515 INSERT INTO t1 VALUES("SOMEVALUE");
516 INSERT INTO t1 VALUES("SOMEVALUE");
517 INSERT INTO t1 VALUES("SOMEVALUE");
518 INSERT INTO t1 VALUES("SOMEVALUE");
519 INSERT INTO t1 VALUES("SOMEVALUE");
520 INSERT INTO t1 VALUES("SOMEVALUE");
521 INSERT INTO t1 VALUES("SOMEVALUE");
522
523 --echo # Make sure checkpoint is not moved
524 SET GLOBAL innodb_log_checkpoint_now = ON;
525 SET GLOBAL innodb_page_cleaner_disabled_debug = 1;
526 SET GLOBAL innodb_dict_stats_disabled_debug = 1;
527 SET GLOBAL innodb_master_thread_disabled_debug = 1;
528
529 --echo # Following encryption will create a new tablespace key (KEY1)
530 --echo # KEY1 will be written on REDO log
531 ALTER TABLESPACE encrypt_ts encryption='Y';
532
533 --echo # Following unencryption will remove tablespace key
534 ALTER TABLESPACE encrypt_ts encryption='N';
535
536 # Force encryption to crash after page 6 is encrypted
537 SET SESSION debug= '+d,alter_encrypt_tablespace_page_6';
538 # Force every page to be flushed after its dirtied
539 SET SESSION debug= '+d,flush_each_dirtied_page';
540
541 --echo # Following encryption will create a new tablespace key (KEY2)
542 --echo # KEY2 will be written on REDO log
543 --echo # Flush dirtied pages encrypted with KEY2 before crash
544 --source include/expect_crash.inc
545 --error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR
546 ALTER TABLESPACE encrypt_ts encryption='Y';
547
548 --echo #########################################################################
549 --echo # RESTART $rc: WITH KEYRING PLUGIN after crash
550 --echo #########################################################################
551 # Without fix, following restart would crash reporting page corruption
552 let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT --innodb_doublewrite=0 --debug=d,dont_update_key_found_during_REDO_scan;
553 --source include/start_mysqld_no_echo.inc
554 --inc $rc
555
556 --echo ###########
557 --echo # Cleanup #
558 --echo ###########
559 DROP TABLE t1;
560 DROP TABLESPACE encrypt_ts;
561
562 --echo #########################################################################
563 --echo # RESTART $rc : final
564 --echo #########################################################################
565 let $restart_parameters = restart:;
566 --source include/restart_mysqld_no_echo.inc
567 remove_file $MYSQL_TMP_DIR/mysecret_keyring;