File: table_encrypt_debug.inc

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (227 lines) | stat: -rw-r--r-- 8,774 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#------------------------------------------------------------------------------
# InnoDB transparent tablespace data encryption
# This test case will test basic recovery from known DBUG_SUICIDE point .
#  - ib_crash_during_rotation_for_encryption (assert during key rotation)
#  - ib_crash_during_create_for_encryption (assert during create)
#  - ib_crash_during_decrypt_page (assert during page decryption)
#------------------------------------------------------------------------------







--disable_query_log
call mtr.add_suppression("Error generating data for Data ID:");
--enable_query_log
let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err;
let $MYSQLD_DATADIR = `SELECT @@datadir`;
let $innodb_file_per_table = `SELECT @@innodb_file_per_table`;

SET GLOBAL innodb_file_per_table = 1;
SELECT @@innodb_file_per_table;

--disable_warnings
DROP DATABASE IF EXISTS tde_db;
CREATE DATABASE tde_db;
USE tde_db;
--enable_warnings

--echo #
--echo # Set encryption ON for table `mysql`
--echo #
ALTER TABLESPACE mysql ENCRYPTION='Y';
SET debug='+d,skip_dd_table_access_check';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE OPTIONS LIKE '%encryption=Y%';
SET debug='-d,skip_dd_table_access_check';

--echo #
--echo # Test crash point `ib_crash_during_rotation_for_encryption`
--echo #
SET SESSION DEBUG="+d,ib_encryption_rotate_crash";

CREATE TABLE tde_db.t1(c1 INT, c2 char(20)) ENCRYPTION="Y" ENGINE = InnoDB;
SET debug='+d,skip_dd_table_access_check';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE OPTIONS LIKE '%encryption=Y%';
SET debug='-d,skip_dd_table_access_check';
SHOW CREATE TABLE tde_db.t1;
INSERT INTO tde_db.t1 VALUES(0, "aaaaa");
INSERT INTO tde_db.t1 VALUES(1, "bbbbb");
INSERT INTO tde_db.t1 VALUES(2, "ccccc");
INSERT INTO tde_db.t1 VALUES(3, "ddddd");

--echo # Execute the statement that causes the crash
# Write file to make mysql-test-run.pl start up the server again
--exec echo "restart: $PLUGIN_DIR_OPT" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--error 2013
ALTER INSTANCE ROTATE INNODB MASTER KEY;
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_reconnect
SET SESSION DEBUG="-d,ib_encryption_rotate_crash";
let SEARCH_PATTERN = ib_encryption_rotate_crash;
--source include/search_pattern.inc

--echo # Show that encryption is OK
SET debug='+d,skip_dd_table_access_check';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE OPTIONS LIKE '%encryption=Y%';
SET debug='-d,skip_dd_table_access_check';
INSERT INTO tde_db.t1 VALUES(4, "eeeee");
SELECT * FROM tde_db.t1 ORDER BY c1;

--echo # Create a second table with encryption
CREATE TABLE tde_db.t2(c1 INT, c2 char(20)) ENCRYPTION="Y" ENGINE = InnoDB;
SHOW CREATE TABLE tde_db.t2;
SET debug='+d,skip_dd_table_access_check';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE OPTIONS LIKE '%encryption=Y%';
SET debug='-d,skip_dd_table_access_check';
INSERT INTO tde_db.t2 VALUES(0, "aaaaa");
INSERT INTO tde_db.t2 VALUES(1, "bbbbb");

--echo # Remove the current auto.cnf file to make sure a new server uuid is
--echo # generated at restart.
--remove_file $MYSQLD_DATADIR/auto.cnf

--echo # Execute the statement that causes the crash
# Write file to make mysql-test-run.pl start up the server again
--exec echo "restart: $PLUGIN_DIR_OPT" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
SET SESSION DEBUG="+d,ib_encryption_rotate_crash";
--error 2013
ALTER INSTANCE ROTATE INNODB MASTER KEY;
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_reconnect
SET SESSION DEBUG="-d,ib_encryption_rotate_crash";
let SEARCH_PATTERN = ib_encryption_rotate_crash;
--source include/search_pattern.inc

--echo # Show that encryption is OK
SET debug='+d,skip_dd_table_access_check';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE OPTIONS LIKE '%encryption=Y%';
SET debug='-d,skip_dd_table_access_check';
INSERT INTO tde_db.t1 VALUES(5, "fffff");
SELECT * FROM tde_db.t1 ORDER BY c1;
SELECT * FROM tde_db.t2 ORDER BY c1;

--echo # Rotate Encryption again without the Crash
ALTER INSTANCE ROTATE INNODB MASTER KEY;
SELECT * FROM tde_db.t1 ORDER BY c1 ;

--echo # Show that encryption is OK
SET debug='+d,skip_dd_table_access_check';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE OPTIONS LIKE '%encryption=Y%';
SET debug='-d,skip_dd_table_access_check';
SELECT * FROM tde_db.t1 ORDER BY c1 ;
SELECT * FROM tde_db.t2 ORDER BY c1 ;

DROP TABLE tde_db.t2;
ALTER TABLESPACE mysql ENCRYPTION='N';
SET debug='+d,skip_dd_table_access_check';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE OPTIONS LIKE '%encryption=Y%';
SET debug='-d,skip_dd_table_access_check';

--echo #
--echo # Test crash point `ib_crash_during_create_for_encryption` during a CREATE TABLE
--echo #
# Write file to make mysql-test-run.pl start up the server again
--exec echo "restart: $PLUGIN_DIR_OPT" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
SET SESSION DEBUG="+d,ib_crash_during_create_for_encryption";

--echo # Execute the statement that causes the crash
--error 2013
CREATE TABLE tde_db.t2(c1 INT, c2 char(20)) ENCRYPTION="Y" ENGINE = InnoDB;
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_reconnect
SET SESSION DEBUG="-d,ib_crash_during_create_for_encryption";

--echo # Show encrypted tables.
SET debug='+d,skip_dd_table_access_check';
SELECT NAME,OPTIONS FROM mysql.tablespaces WHERE OPTIONS LIKE '%encryption=Y%';
SET debug='-d,skip_dd_table_access_check';
SELECT * FROM tde_db.t1 ORDER BY c1 LIMIT 5;
INSERT INTO tde_db.t1 VALUES(6, "ggggg");
SELECT * FROM tde_db.t1 ORDER BY c1 ;
--error 1146
SELECT * FROM tde_db.t2;

--echo #
--echo # Test crash point `ib_crash_during_decrypt_page` during an IMPORT TABLESPACE
--echo #
# Write file to make mysql-test-run.pl start up the server again
--exec echo "restart: $PLUGIN_DIR_OPT" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect

FLUSH TABLE tde_db.t1 FOR EXPORT;
--copy_file $MYSQLD_DATADIR/tde_db/t1.cfg $MYSQLD_DATADIR/t1.cfg_back
--copy_file $MYSQLD_DATADIR/tde_db/t1.cfp $MYSQLD_DATADIR/t1.cfp_back
--copy_file $MYSQLD_DATADIR/tde_db/t1.ibd $MYSQLD_DATADIR/t1.ibd_back
UNLOCK TABLES;
ALTER TABLE tde_db.t1 DISCARD TABLESPACE;
--copy_file $MYSQLD_DATADIR/t1.cfg_back $MYSQLD_DATADIR/tde_db/t1.cfg
--copy_file $MYSQLD_DATADIR/t1.cfp_back $MYSQLD_DATADIR/tde_db/t1.cfp
--copy_file $MYSQLD_DATADIR/t1.ibd_back $MYSQLD_DATADIR/tde_db/t1.ibd

SET SESSION DEBUG="+d,ib_crash_during_decrypt_page";

--echo # Execute the statement that causes the crash
--error 2013
eval ALTER TABLE tde_db.t1 IMPORT TABLESPACE;
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_reconnect
SET SESSION DEBUG="-d,ib_crash_during_decrypt_page";

--error ER_TABLESPACE_DISCARDED
INSERT INTO tde_db.t1 VALUES(7, "hhhhh");
--error ER_TABLESPACE_DISCARDED
SELECT * FROM tde_db.t1 ORDER BY c1 ;
DROP TABLE tde_db.t1;

--exec echo "restart: $PLUGIN_DIR_OPT" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_reconnect

--remove_files_wildcard $MYSQLD_DATADIR/tde_db/ t1.*
DROP DATABASE tde_db;

--echo #
--echo # Bug #27307740 [ERROR] [MY-011066] INNODB: CORRUPT LOG RECORD FOUND
--echo # DURING CRASH RECOVERY
--echo #

CREATE DATABASE tde_db;

# Write file to make mysql-test-run.pl start up the server again
--exec echo "restart: $PLUGIN_DIR_OPT" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect

CREATE TABLE tde_db.test_tbl(c1 int) ENCRYPTION="Y" ENGINE=InnoDB;

# Crash the server while executing ALTER INSTANCE ROTATE
SET SESSION DEBUG="+d, keyring_generate_fail";
--error 2013
ALTER INSTANCE ROTATE INNODB MASTER KEY;
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_reconnect
SET SESSION debug="-d, keyring_generate_fail";
SELECT COUNT(*) FROM tde_db.test_tbl;

DROP TABLE tde_db.test_tbl;

# Cleanup
DROP DATABASE tde_db;
eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table;

--disable_query_log
call mtr.add_suppression("\\[Warning\\].* Decrypting a page in doublewrite file failed");
call mtr.add_suppression("\\[Warning\\].* Encryption key missing:");
call mtr.add_suppression("\\[Warning\\].* Cannot calculate statistics for table .* because the \.ibd file is missing");
call mtr.add_suppression("\\[Warning\\].* Database page corruption or a failed file read of page");
call mtr.add_suppression("\\[Warning\\].* does not exist in the InnoDB internal data dictionary though MySQL is trying to drop it");
call mtr.add_suppression("\\[Warning\\].* Tablespace .*, name '.*', file '.*' is missing");
call mtr.add_suppression("\\[Warning\\].* Tablespace for table `tde_db`.`t1` is set as discarded");
call mtr.add_suppression("\\[ERROR\\].* Encryption algorithm support missing:");
call mtr.add_suppression("\\[ERROR\\].* The table .* doesn't have a corresponding tablespace, it was discarded.");
--enable_query_log