From 2dc5d8bb7e087a340edb989c045070b808e0da57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 12 Jan 2017 12:33:46 +0200 Subject: [PATCH] Improve an MDEV-9011 test of innodb_encrypt_log. Test crash recovery from an encrypted redo log with innodb_encrypt_log=0. Previously, we did a clean shutdown, so only the log checkpoint information would have been read from the redo log. With this change, we will be reading and applying encrypted redo log records. include/start_mysqld.inc: Observe $restart_parameters. encryption.innodb-log-encrypt: Remove some unnecessary statements, and instead of restarting the server and concurrently accessing the files while the server is running, kill the server, check the files, and finally start up the server. innodb.log_data_file_size: Use start_mysqld.inc with $restart_parameters. --- mysql-test/include/start_mysqld.inc | 9 ++++++- .../encryption/r/innodb-log-encrypt.result | 4 +-- .../encryption/t/innodb-log-encrypt.test | 25 +++---------------- .../suite/innodb/t/log_data_file_size.test | 11 +++----- 4 files changed, 18 insertions(+), 31 deletions(-) diff --git a/mysql-test/include/start_mysqld.inc b/mysql-test/include/start_mysqld.inc index 983c566821e..e31f26aad8c 100644 --- a/mysql-test/include/start_mysqld.inc +++ b/mysql-test/include/start_mysqld.inc @@ -1,7 +1,14 @@ # Include this script only after using shutdown_mysqld.inc # where $_expect_file_name was initialized. # Write file to make mysql-test-run.pl start up the server again ---exec echo "restart" > $_expect_file_name +if ($restart_parameters) +{ + --exec echo "restart: $restart_parameters" > $_expect_file_name +} +if (!$restart_parameters) +{ + --exec echo "restart" > $_expect_file_name +} # Turn on reconnect --enable_reconnect diff --git a/mysql-test/suite/encryption/r/innodb-log-encrypt.result b/mysql-test/suite/encryption/r/innodb-log-encrypt.result index 655e3023f7a..98fc277e513 100644 --- a/mysql-test/suite/encryption/r/innodb-log-encrypt.result +++ b/mysql-test/suite/encryption/r/innodb-log-encrypt.result @@ -13,14 +13,14 @@ set current_num = current_num + 1; end while; end// commit; -set autocommit=0; +begin; call innodb_insert_proc(2000); commit; -set autocommit=1; update t1 set c1 = c1 +1; select count(*) from t1; count(*) 2000 +# Kill the server # ibdata1 yes on expecting NOT FOUND NOT FOUND /privatejanprivate/ in ibdata1 # t1 yes on expecting NOT FOUND diff --git a/mysql-test/suite/encryption/t/innodb-log-encrypt.test b/mysql-test/suite/encryption/t/innodb-log-encrypt.test index 7c2e6f847b1..0555f9d49aa 100644 --- a/mysql-test/suite/encryption/t/innodb-log-encrypt.test +++ b/mysql-test/suite/encryption/t/innodb-log-encrypt.test @@ -6,16 +6,6 @@ # MDEV-9011: Redo log encryption does not work # ---disable_query_log -let $innodb_file_format_orig = `SELECT @@innodb_file_format`; -let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`; ---enable_query_log - ---disable_query_log -let $innodb_file_format_orig = `SELECT @@innodb_file_format`; -let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`; ---enable_query_log - SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; @@ -35,16 +25,13 @@ end// delimiter ;// commit; -set autocommit=0; +begin; call innodb_insert_proc(2000); commit; -set autocommit=1; update t1 set c1 = c1 +1; select count(*) from t1; --- source include/restart_mysqld.inc - --let $MYSQLD_DATADIR=`select @@datadir` --let ib1_IBD = $MYSQLD_DATADIR/ibdata1 --let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd @@ -53,6 +40,8 @@ select count(*) from t1; --let SEARCH_RANGE = 10000000 --let SEARCH_PATTERN=privatejanprivate +-- source include/kill_mysqld.inc + --echo # ibdata1 yes on expecting NOT FOUND -- let SEARCH_FILE=$ib1_IBD -- source include/search_pattern_in_file.inc @@ -68,7 +57,7 @@ select count(*) from t1; --echo # Restart mysqld --innodb_encrypt_log=0 -- let $restart_parameters=--innodb_encrypt_log=0 --- source include/restart_mysqld.inc +-- source include/start_mysqld.inc insert into t1 values(5000, substring(MD5(RAND()), -64), REPEAT('publicmessage',10)); insert into t1 values(5001, substring(MD5(RAND()), -64), REPEAT('publicmessage',10)); @@ -106,9 +95,3 @@ insert into t1 values(5004, substring(MD5(RAND()), -64), REPEAT('publicmessage', drop procedure innodb_insert_proc; drop table t1; - -# reset system ---disable_query_log -EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig; -EVAL SET GLOBAL innodb_file_format = $innodb_file_format_orig; ---enable_query_log diff --git a/mysql-test/suite/innodb/t/log_data_file_size.test b/mysql-test/suite/innodb/t/log_data_file_size.test index 23f1ede483f..9328f3bbe6d 100644 --- a/mysql-test/suite/innodb/t/log_data_file_size.test +++ b/mysql-test/suite/innodb/t/log_data_file_size.test @@ -23,7 +23,7 @@ perl; use Fcntl 'SEEK_CUR', 'SEEK_END'; my $page_size = $ENV{'INNODB_PAGE_SIZE'}; -my $restart = 'restart'; +my $restart; if ($ENV{'MYSQLD_IS_DEBUG'}) { # It is impractical to ensure that CREATE TABLE t will extend ibdata1. @@ -37,17 +37,14 @@ if ($ENV{'MYSQLD_IS_DEBUG'}) while() { unless (/\0*/gso) { $empty_tail= 0; last } } if ($empty_tail) { - $restart = 'restart: --innodb-data-file-size-debug=' . $size; + $restart = "--innodb-data-file-size-debug=$size"; truncate(FILE, $page_size * $root); } close FILE; } open(FILE, ">$ENV{MYSQLTEST_VARDIR}/log/start_mysqld.txt") || die; -print FILE '--exec echo "', $restart, '" > $_expect_file_name ---enable_reconnect ---source include/wait_until_connected_again.inc ---disable_reconnect -'; +print FILE "--let \$restart_parameters=$restart\n" if $restart; +print FILE "--source include/start_mysqld.inc\n"; close FILE; open(FILE, "+<", "$ENV{'MYSQLD_DATADIR'}test/ibd4.ibd") or die; truncate(FILE, $page_size * 4);