Skip to content

Commit 2330107

Browse files
author
Jan Lindström
committed
MDEV-7572: InnoDB: Assertion failure in log_init_crypt_key if
file_key_management_plugin is used Fixed error handling and added disabling InnoDB redo log encryption if encryption key management plugin is not there.
1 parent da181fe commit 2330107

File tree

8 files changed

+467
-25
lines changed

8 files changed

+467
-25
lines changed

include/my_aes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ typedef int Crypt_result;
3333
#define AES_KEY_CREATION_FAILED -10
3434

3535
#define CRYPT_KEY_OK 0
36-
#define CRYPT_BUFFER_TO_SMALL -11;
37-
#define CRYPT_KEY_UNKNOWN -48;
36+
#define CRYPT_BUFFER_TO_SMALL -11
37+
#define CRYPT_KEY_UNKNOWN -48
3838

3939
/* The max block sizes of all supported algorithms */
4040
#define MY_AES_BLOCK_SIZE 16

include/mysql/plugin_encryption_key_management.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#define MariaDB_ENCRYPTION_KEY_MANAGEMENT_INTERFACE_VERSION 0x0100
3131

32-
#define BAD_ENCRYPTION_KEY_VERSION (~0U)
32+
#define BAD_ENCRYPTION_KEY_VERSION (UINT_MAX32)
3333

3434
/**
3535
Encryption key management plugin descriptor
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
call mtr.add_suppression("KeyID 0 not found or with error. Check the key and the log file*");
2+
call mtr.add_suppression("Disabling redo log encryption");
3+
SET GLOBAL innodb_file_format = `Barracuda`;
4+
SET GLOBAL innodb_file_per_table = ON;
5+
create table innodb_normal(c1 bigint not null, b char(200)) engine=innodb;
6+
create table innodb_compact(c1 bigint not null, b char(200)) engine=innodb row_format=compact page_encryption=1 page_encryption_key=1;
7+
create table innodb_compressed(c1 bigint not null, b char(200)) engine=innodb row_format=compressed page_encryption=1 page_encryption_key=2;
8+
create table innodb_dynamic(c1 bigint not null, b char(200)) engine=innodb row_format=dynamic page_encryption=1 page_encryption_key=3;
9+
create table innodb_redundant(c1 bigint not null, b char(200)) engine=innodb row_format=redundant page_encryption=1 page_encryption_key=4;
10+
show create table innodb_compact;
11+
Table Create Table
12+
innodb_compact CREATE TABLE `innodb_compact` (
13+
`c1` bigint(20) NOT NULL,
14+
`b` char(200) DEFAULT NULL
15+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT `page_encryption`=1 `page_encryption_key`=1
16+
show create table innodb_compressed;
17+
Table Create Table
18+
innodb_compressed CREATE TABLE `innodb_compressed` (
19+
`c1` bigint(20) NOT NULL,
20+
`b` char(200) DEFAULT NULL
21+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED `page_encryption`=1 `page_encryption_key`=2
22+
show create table innodb_dynamic;
23+
Table Create Table
24+
innodb_dynamic CREATE TABLE `innodb_dynamic` (
25+
`c1` bigint(20) NOT NULL,
26+
`b` char(200) DEFAULT NULL
27+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC `page_encryption`=1 `page_encryption_key`=3
28+
show create table innodb_redundant;
29+
Table Create Table
30+
innodb_redundant CREATE TABLE `innodb_redundant` (
31+
`c1` bigint(20) NOT NULL,
32+
`b` char(200) DEFAULT NULL
33+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT `page_encryption`=1 `page_encryption_key`=4
34+
create procedure innodb_insert_proc (repeat_count int)
35+
begin
36+
declare current_num int;
37+
set current_num = 0;
38+
while current_num < repeat_count do
39+
insert into innodb_normal values(current_num, substring(MD5(RAND()), -64));
40+
set current_num = current_num + 1;
41+
end while;
42+
end//
43+
commit;
44+
set autocommit=0;
45+
call innodb_insert_proc(2000);
46+
commit;
47+
set autocommit=1;
48+
insert into innodb_compact select * from innodb_normal;
49+
insert into innodb_compressed select * from innodb_normal;
50+
insert into innodb_dynamic select * from innodb_normal;
51+
insert into innodb_redundant select * from innodb_normal;
52+
update innodb_normal set c1 = c1 +1;
53+
update innodb_compact set c1 = c1 + 1;
54+
update innodb_compressed set c1 = c1 + 1;
55+
update innodb_dynamic set c1 = c1 + 1;
56+
update innodb_redundant set c1 = c1 + 1;
57+
select count(*) from innodb_compact where c1 < 1500000;
58+
count(*)
59+
2000
60+
select count(*) from innodb_compressed where c1 < 1500000;
61+
count(*)
62+
2000
63+
select count(*) from innodb_dynamic where c1 < 1500000;
64+
count(*)
65+
2000
66+
select count(*) from innodb_redundant where c1 < 1500000;
67+
count(*)
68+
2000
69+
select count(*) from innodb_compact t1, innodb_normal t2 where
70+
t1.c1 = t2.c1 and t1.b = t2.b;
71+
count(*)
72+
2000
73+
select count(*) from innodb_dynamic t1, innodb_normal t2 where
74+
t1.c1 = t2.c1 and t1.b = t2.b;
75+
count(*)
76+
2000
77+
select count(*) from innodb_compressed t1, innodb_normal t2 where
78+
t1.c1 = t2.c1 and t1.b = t2.b;
79+
count(*)
80+
2000
81+
select count(*) from innodb_redundant t1, innodb_normal t2 where
82+
t1.c1 = t2.c1 and t1.b = t2.b;
83+
count(*)
84+
2000
85+
SELECT variable_value >= 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_encrypted';
86+
variable_value >= 0
87+
1
88+
SELECT variable_value >= 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_decrypted';
89+
variable_value >= 0
90+
1
91+
SELECT variable_value = 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_encryption_error';
92+
variable_value = 0
93+
1
94+
SET GLOBAL innodb_file_format = `Barracuda`;
95+
SET GLOBAL innodb_file_per_table = ON;
96+
update innodb_normal set c1 = c1 +1;
97+
update innodb_compact set c1 = c1 + 1;
98+
update innodb_compressed set c1 = c1 + 1;
99+
update innodb_dynamic set c1 = c1 + 1;
100+
update innodb_redundant set c1 = c1 + 1;
101+
select count(*) from innodb_compact where c1 < 1500000;
102+
count(*)
103+
2000
104+
select count(*) from innodb_compressed where c1 < 1500000;
105+
count(*)
106+
2000
107+
select count(*) from innodb_dynamic where c1 < 1500000;
108+
count(*)
109+
2000
110+
select count(*) from innodb_redundant where c1 < 1500000;
111+
count(*)
112+
2000
113+
select count(*) from innodb_compact t1, innodb_normal t2 where
114+
t1.c1 = t2.c1 and t1.b = t2.b;
115+
count(*)
116+
2000
117+
select count(*) from innodb_dynamic t1, innodb_normal t2 where
118+
t1.c1 = t2.c1 and t1.b = t2.b;
119+
count(*)
120+
2000
121+
select count(*) from innodb_compressed t1, innodb_normal t2 where
122+
t1.c1 = t2.c1 and t1.b = t2.b;
123+
count(*)
124+
2000
125+
select count(*) from innodb_redundant t1, innodb_normal t2 where
126+
t1.c1 = t2.c1 and t1.b = t2.b;
127+
count(*)
128+
2000
129+
SELECT variable_value >= 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_encrypted';
130+
variable_value >= 0
131+
1
132+
SELECT variable_value >= 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_decrypted';
133+
variable_value >= 0
134+
1
135+
SELECT variable_value = 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_encryption_error';
136+
variable_value = 0
137+
1
138+
alter table innodb_compact engine=innodb page_encryption=DEFAULT page_encryption_key=DEFAULT;
139+
show create table innodb_compact;
140+
Table Create Table
141+
innodb_compact CREATE TABLE `innodb_compact` (
142+
`c1` bigint(20) NOT NULL,
143+
`b` char(200) DEFAULT NULL
144+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
145+
alter table innodb_compressed engine=innodb page_encryption=DEFAULT page_encryption_key=DEFAULT;
146+
show create table innodb_compressed;
147+
Table Create Table
148+
innodb_compressed CREATE TABLE `innodb_compressed` (
149+
`c1` bigint(20) NOT NULL,
150+
`b` char(200) DEFAULT NULL
151+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED
152+
alter table innodb_dynamic engine=innodb page_encryption=DEFAULT page_encryption_key=DEFAULT;
153+
show create table innodb_dynamic;
154+
Table Create Table
155+
innodb_dynamic CREATE TABLE `innodb_dynamic` (
156+
`c1` bigint(20) NOT NULL,
157+
`b` char(200) DEFAULT NULL
158+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
159+
alter table innodb_redundant engine=innodb page_encryption=DEFAULT page_encryption_key=DEFAULT;
160+
show create table innodb_redundant;
161+
Table Create Table
162+
innodb_redundant CREATE TABLE `innodb_redundant` (
163+
`c1` bigint(20) NOT NULL,
164+
`b` char(200) DEFAULT NULL
165+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT
166+
SET GLOBAL innodb_file_format = `Barracuda`;
167+
SET GLOBAL innodb_file_per_table = ON;
168+
show create table innodb_compact;
169+
Table Create Table
170+
innodb_compact CREATE TABLE `innodb_compact` (
171+
`c1` bigint(20) NOT NULL,
172+
`b` char(200) DEFAULT NULL
173+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
174+
show create table innodb_compressed;
175+
Table Create Table
176+
innodb_compressed CREATE TABLE `innodb_compressed` (
177+
`c1` bigint(20) NOT NULL,
178+
`b` char(200) DEFAULT NULL
179+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED
180+
show create table innodb_dynamic;
181+
Table Create Table
182+
innodb_dynamic CREATE TABLE `innodb_dynamic` (
183+
`c1` bigint(20) NOT NULL,
184+
`b` char(200) DEFAULT NULL
185+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
186+
show create table innodb_redundant;
187+
Table Create Table
188+
innodb_redundant CREATE TABLE `innodb_redundant` (
189+
`c1` bigint(20) NOT NULL,
190+
`b` char(200) DEFAULT NULL
191+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT
192+
update innodb_normal set c1 = c1 +1;
193+
update innodb_compact set c1 = c1 + 1;
194+
update innodb_compressed set c1 = c1 + 1;
195+
update innodb_dynamic set c1 = c1 + 1;
196+
update innodb_redundant set c1 = c1 + 1;
197+
select count(*) from innodb_compact where c1 < 1500000;
198+
count(*)
199+
2000
200+
select count(*) from innodb_compressed where c1 < 1500000;
201+
count(*)
202+
2000
203+
select count(*) from innodb_dynamic where c1 < 1500000;
204+
count(*)
205+
2000
206+
select count(*) from innodb_redundant where c1 < 1500000;
207+
count(*)
208+
2000
209+
select count(*) from innodb_compact t1, innodb_normal t2 where
210+
t1.c1 = t2.c1 and t1.b = t2.b;
211+
count(*)
212+
2000
213+
select count(*) from innodb_dynamic t1, innodb_normal t2 where
214+
t1.c1 = t2.c1 and t1.b = t2.b;
215+
count(*)
216+
2000
217+
select count(*) from innodb_compressed t1, innodb_normal t2 where
218+
t1.c1 = t2.c1 and t1.b = t2.b;
219+
count(*)
220+
2000
221+
select count(*) from innodb_redundant t1, innodb_normal t2 where
222+
t1.c1 = t2.c1 and t1.b = t2.b;
223+
count(*)
224+
2000
225+
SELECT variable_value = 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_encrypted';
226+
variable_value = 0
227+
1
228+
SELECT variable_value = 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_decrypted';
229+
variable_value = 0
230+
1
231+
SELECT variable_value = 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_encryption_error';
232+
variable_value = 0
233+
1
234+
drop procedure innodb_insert_proc;
235+
drop table innodb_normal;
236+
drop table innodb_compact;
237+
drop table innodb_compressed;
238+
drop table innodb_dynamic;
239+
drop table innodb_redundant;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--encryption-algorithm=aes_ctr
2+
--innodb-encrypt-log

0 commit comments

Comments
 (0)