Skip to content

Commit faad7e0

Browse files
Jan Lindströmvuvova
authored andcommitted
Add test case for combination Google encryption and page compressed tables.
1 parent 21430e4 commit faad7e0

File tree

6 files changed

+145
-6
lines changed

6 files changed

+145
-6
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
--aria-encrypt-tables=ON
2+
--encryption-algorithm=aes_ctr
3+
--encrypt-tmp-disk-tables=ON
4+
--innodb-encrypt-tables=ON
5+
--innodb-encryption-rotate-key-age=15
6+
--innodb-encryption-threads=4
7+
--innodb-tablespaces-encryption
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
-- source include/have_innodb.inc
2+
-- source include/have_example_key_management_plugin.inc
3+
4+
# embedded does not support restart
5+
-- source include/not_embedded.inc
6+
7+
--disable_query_log
8+
let $innodb_compression_algorithm_orig=`SELECT @@innodb_compression_algorithm`;
9+
let $innodb_file_format_orig = `SELECT @@innodb_file_format`;
10+
let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`;
11+
--enable_query_log
12+
13+
SET GLOBAL innodb_file_format = `Barracuda`;
14+
SET GLOBAL innodb_file_per_table = ON;
15+
# zlib
16+
set global innodb_compression_algorithm = 1;
17+
18+
create table innodb_normal(c1 bigint not null, b char(200)) engine=innodb page_compressed=1;
19+
create table innodb_compact(c1 bigint not null, b char(200)) engine=innodb row_format=compact page_compressed=1;
20+
create table innodb_dynamic(c1 bigint not null, b char(200)) engine=innodb row_format=dynamic page_compressed=1;
21+
show warnings;
22+
23+
show create table innodb_normal;
24+
show create table innodb_compact;
25+
show create table innodb_dynamic;
26+
27+
delimiter //;
28+
create procedure innodb_insert_proc (repeat_count int)
29+
begin
30+
declare current_num int;
31+
set current_num = 0;
32+
while current_num < repeat_count do
33+
insert into innodb_normal values(current_num, substring(MD5(RAND()), -64));
34+
set current_num = current_num + 1;
35+
end while;
36+
end//
37+
delimiter ;//
38+
commit;
39+
40+
set autocommit=0;
41+
call innodb_insert_proc(5000);
42+
commit;
43+
set autocommit=1;
44+
45+
insert into innodb_compact select * from innodb_normal;
46+
insert into innodb_dynamic select * from innodb_normal;
47+
48+
update innodb_normal set c1 = c1 + 1;
49+
update innodb_compact set c1 = c1 + 1;
50+
update innodb_dynamic set c1 = c1 + 1;
51+
select count(*) from innodb_normal;
52+
select count(*) from innodb_compact where c1 < 1500000;
53+
select count(*) from innodb_dynamic where c1 < 1500000;
54+
55+
SELECT variable_value >= 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_encrypted';
56+
SELECT variable_value >= 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_decrypted';
57+
SELECT variable_value = 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_encryption_error';
58+
SELECT variable_value >= 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_compressed';
59+
SELECT variable_value >= 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_decompressed';
60+
61+
--source include/restart_mysqld.inc
62+
63+
SET GLOBAL innodb_file_format = `Barracuda`;
64+
SET GLOBAL innodb_file_per_table = ON;
65+
# zlib
66+
set global innodb_compression_algorithm = 1;
67+
68+
update innodb_normal set c1 = c1 + 1;
69+
update innodb_compact set c1 = c1 + 1;
70+
update innodb_dynamic set c1 = c1 + 1;
71+
select count(*) from innodb_normal;
72+
select count(*) from innodb_compact where c1 < 1500000;
73+
select count(*) from innodb_dynamic where c1 < 1500000;
74+
75+
SELECT variable_value >= 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_encrypted';
76+
SELECT variable_value >= 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_decrypted';
77+
SELECT variable_value = 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_encryption_error';
78+
SELECT variable_value > 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_compressed';
79+
SELECT variable_value > 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_decompressed';
80+
81+
alter table innodb_normal engine=innodb page_compressed=DEFAULT;
82+
show create table innodb_normal;
83+
alter table innodb_compact engine=innodb page_compressed=DEFAULT;
84+
show create table innodb_compact;
85+
alter table innodb_dynamic engine=innodb page_compressed=DEFAULT;
86+
show create table innodb_dynamic;
87+
88+
--source include/restart_mysqld.inc
89+
90+
SET GLOBAL innodb_file_format = `Barracuda`;
91+
SET GLOBAL innodb_file_per_table = ON;
92+
93+
show create table innodb_normal;
94+
show create table innodb_compact;
95+
show create table innodb_dynamic;
96+
97+
update innodb_normal set c1 = c1 + 1;
98+
update innodb_compact set c1 = c1 + 1;
99+
update innodb_dynamic set c1 = c1 + 1;
100+
select count(*) from innodb_normal;
101+
select count(*) from innodb_compact where c1 < 1500000;
102+
select count(*) from innodb_dynamic where c1 < 1500000;
103+
104+
SELECT variable_value = 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_encrypted';
105+
SELECT variable_value = 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_decrypted';
106+
SELECT variable_value = 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_encryption_error';
107+
SELECT variable_value = 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_compressed';
108+
SELECT variable_value = 0 FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_num_pages_page_decompressed';
109+
110+
drop procedure innodb_insert_proc;
111+
drop table innodb_normal;
112+
drop table innodb_compact;
113+
drop table innodb_dynamic;
114+
115+
# reset system
116+
--disable_query_log
117+
EVAL SET GLOBAL innodb_compression_algorithm = $innodb_compression_algorithm_orig;
118+
EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig;
119+
EVAL SET GLOBAL innodb_file_format = $innodb_file_format_orig;
120+
--enable_query_log

storage/innobase/buf/buf0dblwr.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,9 @@ buf_dblwr_write_block_to_datafile(
843843
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
844844
buf_dblwr_check_page_lsn(block->frame);
845845

846+
fprintf(stderr, "JAN: space %lu page_type %lu\n", buf_block_get_space(block),
847+
mach_read_from_2((byte *)frame+FIL_PAGE_TYPE));
848+
846849
fil_io(flags, sync, buf_block_get_space(block), 0,
847850
buf_block_get_page_no(block), 0, UNIV_PAGE_SIZE,
848851
frame, (void*) block, (ulint *)&bpage->write_size, bpage->newest_modification );

storage/innobase/fil/fil0pagecompress.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,20 @@ fil_compress_page(
281281
/* read original page type */
282282
orig_page_type = mach_read_from_2(buf + FIL_PAGE_TYPE);
283283

284+
ut_ad(orig_page_type != 0);
285+
284286
/* Let's not compress file space header or
285287
extent descriptor */
286-
if ((orig_page_type == FIL_PAGE_TYPE_FSP_HDR)
287-
|| (orig_page_type == FIL_PAGE_TYPE_XDES) ) {
288+
if (orig_page_type == FIL_PAGE_TYPE_FSP_HDR ||
289+
orig_page_type == FIL_PAGE_TYPE_XDES ||
290+
orig_page_type == FIL_PAGE_PAGE_COMPRESSED ||
291+
orig_page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) {
288292
*out_len = len;
289293
return (buf);
290294
}
291295

296+
fprintf(stderr, "JAN: orig_page_type %lu\n", orig_page_type);
297+
292298
level = compression_level;
293299
ut_ad(fil_space_is_page_compressed(space_id));
294300

storage/xtradb/fil/fil0crypt.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,10 +670,9 @@ fil_space_encrypt(ulint space, ulint offset, lsn_t lsn,
670670

671671
ibool page_compressed = (mach_read_from_2(src_frame+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED);
672672
ibool page_encrypted = fil_space_is_page_encrypted(space);
673-
674673
ulint compression_alg = mach_read_from_8(src_frame+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION);
675-
676674
ulint orig_page_type = mach_read_from_2(src_frame+FIL_PAGE_TYPE);
675+
677676
if (orig_page_type==FIL_PAGE_TYPE_FSP_HDR
678677
|| orig_page_type==FIL_PAGE_TYPE_XDES
679678
|| orig_page_type== FIL_PAGE_PAGE_ENCRYPTED

storage/xtradb/fil/fil0pagecompress.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,16 @@ fil_compress_page(
283283

284284
/* Let's not compress file space header or
285285
extent descriptor */
286-
if ((orig_page_type == FIL_PAGE_TYPE_FSP_HDR)
287-
|| (orig_page_type == FIL_PAGE_TYPE_XDES) ) {
286+
if (orig_page_type == FIL_PAGE_TYPE_FSP_HDR ||
287+
orig_page_type == FIL_PAGE_TYPE_XDES ||
288+
orig_page_type == FIL_PAGE_PAGE_COMPRESSED ||
289+
orig_page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) {
288290
*out_len = len;
289291
return (buf);
290292
}
291293

294+
fprintf(stderr, "JAN: orig_page_type %lu\n", orig_page_type);
295+
292296
level = compression_level;
293297
ut_ad(fil_space_is_page_compressed(space_id));
294298

0 commit comments

Comments
 (0)