1# Test tries restart after redo log encryption is enabled
2# - Error   :restart without keyring plugin
3# - Pass    :restart without keyring plugin and --innodb_force_recovery=6
4# - Pass    :remove redo files,restart without keyring plugin
5
6--source include/no_valgrind_without_big.inc
7--source include/have_innodb.inc
8--source include/not_embedded.inc
9
10--disable_query_log
11call mtr.add_suppression("keyring_file initialization failure. Please check if the keyring_file_data points to readable keyring file or keyring file can be created in the specified location. The keyring_file will stay unusable until correct path to the keyring file gets provided");
12call mtr.add_suppression("Error while loading keyring content. The keyring might be malformed");
13call mtr.add_suppression("\\[Error\\] InnoDB: Encryption can't find masterkey, please check the keyring plugin is loaded.");
14call mtr.add_suppression("\\[ERROR\\] InnoDB: Failed to find tablespace for table `\.\.*`\.`\.\.*` in the cache.");
15call mtr.add_suppression("\\[ERROR\\] InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them.");
16call mtr.add_suppression ("InnoDB: New log files created");
17--enable_query_log
18
19let $old_innodb_file_per_table = `SELECT @@innodb_file_per_table`;
20let $old_innodb_redo_log_encrypt = `SELECT @@innodb_redo_log_encrypt`;
21let $START_PAGE_SIZE= `select @@innodb_page_size`;
22let $LOG_FILE_SIZE= `select @@innodb_log_file_size`;
23let $MYSQLD_BASEDIR= `select @@basedir`;
24
25--mkdir $MYSQL_TMP_DIR/log_encrypt_dir1_$redo_log_mode
26
27let $MYSQLD_DATADIR1 = $MYSQL_TMP_DIR/log_encrypt_dir1_$redo_log_mode;
28
29let BOOTSTRAP_SQL=$MYSQL_TMP_DIR/boot.sql;
30
31--echo # create bootstrap file
32write_file $BOOTSTRAP_SQL;
33CREATE DATABASE test;
34EOF
35--echo # Stop the MTR default DB server
36--source include/shutdown_mysqld.inc
37
38let NEW_CMD = $MYSQLD --no-defaults --initialize-insecure --innodb_log_file_size=$LOG_FILE_SIZE --innodb_page_size=$START_PAGE_SIZE --basedir=$MYSQLD_BASEDIR --datadir=$MYSQLD_DATADIR1 --init-file=$BOOTSTRAP_SQL --secure-file-priv="" --innodb_redo_log_encrypt=$redo_log_encrypt_mode --innodb_undo_tablespaces=2 --early-plugin-load="keyring_file=$KEYRING_PLUGIN" --keyring_file_data=$MYSQL_TMP_DIR/my_key_redo4 $KEYRING_PLUGIN_OPT </dev/null>>$MYSQL_TMP_DIR/bootstrap1.log 2>&1;
39
40--echo # Run the bootstrap command of datadir1
41--exec $NEW_CMD
42
43--echo # Start the DB server with datadir1
44--replace_result $MYSQL_TMP_DIR TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH $MYSQLD_DATADIR1 DATADIR1 $START_PAGE_SIZE PAGE_SIZE $LOG_FILE_SIZE LOG_FILE_SIZE
45--let $restart_parameters="restart: --early-plugin-load="keyring_file=$KEYRING_PLUGIN" $KEYRING_PLUGIN_OPT --keyring_file_data=$MYSQL_TMP_DIR/my_key_redo4 --innodb_redo_log_encrypt=$redo_log_encrypt_mode --innodb_undo_tablespaces=2 --datadir=$MYSQLD_DATADIR1 --innodb_page_size=$START_PAGE_SIZE --innodb_log_file_size=$LOG_FILE_SIZE"
46--replace_regex /\.dll/.so/
47--source include/start_mysqld_no_echo.inc
48
49CREATE DATABASE tde_db;
50USE tde_db;
51
52eval SET GLOBAL innodb_redo_log_encrypt = $redo_log_encrypt_mode;
53SELECT @@global.innodb_redo_log_encrypt ;
54
55SELECT @@global.innodb_redo_log_encrypt ;
56CREATE TABLE tde_db.t1 (a BIGINT PRIMARY KEY, b LONGBLOB) ENGINE=InnoDB;
57INSERT INTO t1 (a, b) VALUES (1, REPEAT('a', 6*512*512));
58SELECT a,LEFT(b,10) FROM tde_db.t1;
59CREATE TABLE tde_db.t2 (a BIGINT PRIMARY KEY, b LONGBLOB)
60			ENCRYPTION='Y' ENGINE=InnoDB;
61INSERT INTO t2 (a, b) VALUES (1, REPEAT('a', 6*512*512));
62SELECT a,LEFT(b,10) FROM tde_db.t2;
63SELECT @@global.innodb_redo_log_encrypt ;
64CREATE TABLE tde_db.t3 (a BIGINT PRIMARY KEY, b LONGBLOB) ENGINE=InnoDB;
65INSERT INTO t3 (a, b) VALUES (1, REPEAT('a', 6*512*512));
66SELECT a,LEFT(b,10) FROM tde_db.t3;
67CREATE TABLE tde_db.t4 (a BIGINT PRIMARY KEY, b LONGBLOB)
68			ENCRYPTION='Y' ENGINE=InnoDB;
69INSERT INTO t4 (a, b) VALUES (1, REPEAT('a', 6*512*512));
70SELECT a,LEFT(b,10) FROM tde_db.t4;
71
72SELECT @@global.innodb_redo_log_encrypt ;
73CREATE TABLE tde_db.t5 (a BIGINT PRIMARY KEY, b LONGBLOB) ENGINE=InnoDB;
74INSERT INTO t5 (a, b) VALUES (1, REPEAT('a', 6*512*512));
75SELECT a,LEFT(b,10) FROM tde_db.t5;
76CREATE TABLE tde_db.t6 (a BIGINT PRIMARY KEY, b LONGBLOB)
77			ENCRYPTION='Y' ENGINE=InnoDB;
78INSERT INTO t6 (a, b) VALUES (1, REPEAT('a', 6*512*512));
79SELECT a,LEFT(b,10) FROM tde_db.t6;
80
81UNINSTALL PLUGIN keyring_file;
82DROP DATABASE tde_db;
83
84# shutdown server
85--let $_server_id= `SELECT @@server_id`
86--source include/shutdown_mysqld.inc
87
88--echo # Try starting without keyring : Error
89let NEW_CMD = $MYSQLD --no-defaults --innodb_undo_tablespaces=2 --innodb_page_size=$START_PAGE_SIZE --innodb_log_file_size=$LOG_FILE_SIZE --basedir=$MYSQLD_BASEDIR --datadir=$MYSQLD_DATADIR1  --secure-file-priv="" --console </dev/null>>$MYSQL_TMP_DIR/wl9290.err 2>&1;
90--error 1
91--exec $NEW_CMD
92
93--echo # Search for error message
94let SEARCH_FILE= $MYSQL_TMP_DIR/wl9290.err;
95let SEARCH_PATTERN= InnoDB: Redo log was encrypted, but keyring plugin is not loaded;
96--source include/search_pattern.inc
97
98--echo # Restart without keyring plugin possible if redo files removed
99--remove_file $MYSQLD_DATADIR1/ib_logfile0
100--remove_file $MYSQLD_DATADIR1/ib_logfile1
101
102--echo # Start the DB server with datadir1
103--replace_result $MYSQL_TMP_DIR TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH $MYSQLD_DATADIR1 DATADIR1 $START_PAGE_SIZE PAGE_SIZE $LOG_FILE_SIZE LOG_FILE_SIZE
104--let $restart_parameters="restart: --innodb_undo_tablespaces=2 --datadir=$MYSQLD_DATADIR1 --innodb_page_size=$START_PAGE_SIZE --innodb_log_file_size=$LOG_FILE_SIZE"
105--replace_regex /\.dll/.so/
106--source include/start_mysqld_no_echo.inc
107
108# shutdown server
109--let $_server_id= `SELECT @@server_id`
110--source include/shutdown_mysqld.inc
111
112--echo # Try starting without keyring and  --innodb_force_recovery=SRV_FORCE_NO_LOG_REDO.
113--echo # Start the DB server with datadir1
114--replace_result $MYSQL_TMP_DIR TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH $MYSQLD_DATADIR1 DATADIR1 $START_PAGE_SIZE PAGE_SIZE $LOG_FILE_SIZE LOG_FILE_SIZE
115--let $restart_parameters="restart: --innodb_undo_tablespaces=2 --datadir=$MYSQLD_DATADIR1 --innodb_page_size=$START_PAGE_SIZE --innodb_log_file_size=$LOG_FILE_SIZE --innodb_force_recovery=6 --no-console --log-error=$MYSQL_TMP_DIR/wl9290_2.err"
116--replace_regex /\.dll/.so/
117--source include/start_mysqld_no_echo.inc
118SELECT 1;
119
120# shutdown server
121--let $_server_id= `SELECT @@server_id`
122--source include/shutdown_mysqld.inc
123
124# restart the server with MTR default
125--let $restart_parameters=
126--source include/start_mysqld.inc
127
128--remove_file $BOOTSTRAP_SQL
129--remove_file $MYSQL_TMP_DIR/my_key_redo4
130--remove_file $MYSQL_TMP_DIR/wl9290.err
131--remove_file $MYSQL_TMP_DIR/wl9290_2.err
132
133# Remove residue files
134--force-rmdir $MYSQLD_DATADIR1
135