summaryrefslogtreecommitdiff
path: root/mysql-test/suite/encryption/t/innodb_scrub.test
blob: 3288ae9ce1c89e64868b910c97351bb014790e7e (plain)
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
-- source include/have_innodb.inc
-- source include/not_embedded.inc
-- source include/have_example_key_management_plugin.inc

let $MYSQLD_DATADIR=`select @@datadir`;
let INNODB_PAGE_SIZE= `select @@innodb_page_size`;

create table snapshot_status engine = myisam
select * from information_schema.global_status
where variable_name like 'innodb_scrub_background%';

let $rowcount=500;
let $maxformatno= 4;
let $formatno= $maxformatno;

--echo # MDEV-8139 Fix scrubbing tests
--echo # FIXME: Add index(b) to each table; ensure that undo logs are scrubbed.
let $tableformat= (
  a int auto_increment primary key,
  b varchar(256),
  c text) engine = innodb row_format;

while ($formatno)
{
dec $formatno;
let $format = `select case $formatno
               when 0 then 'dynamic'
               when 1 then 'redundant'
               when 2 then 'compact'
	       when 3 then 'compressed'
               end`;

let $t= delete_$formatno;
eval create table $t $tableformat=$format;

let $numinserts = $rowcount;
--disable_query_log
begin;
while ($numinserts)
{
  dec $numinserts;
  eval insert into $t(b,c) values ('repairman', repeat('unicycle', 1000));
}
commit;
--enable_query_log

eval delete from $t;

let $t= delete_rollback_delete_$formatno;
eval create table $t $tableformat=$format;

let $numinserts = $rowcount;
--disable_query_log
begin;
while ($numinserts)
{
  dec $numinserts;
  eval insert into $t(b,c) values ('breakhuman', repeat('bicycle', 1000));
}
commit;
--enable_query_log

begin;
eval delete from $t;
rollback;
eval delete from $t;

let $t= insert_rollback_$formatno;

eval create table $t $tableformat=$format;

let $numinserts = $rowcount;
begin;
--disable_query_log
while ($numinserts)
{
  dec $numinserts;
  eval insert into $t(b,c) values ('wonderwoman', repeat('tricycle', 1000));
}
--enable_query_log

rollback;
}

SET GLOBAL innodb_fast_shutdown=0;
-- source include/shutdown_mysqld.inc

let SEARCH_ABORT= FOUND;
let SEARCH_PATTERN= (un|b|tr)icycle|(repair|breakhu|wonderwo)man;
let SEARCH_RANGE= 12582912;
let SEARCH_FILE= $MYSQLD_DATADIR/ibdata1;

# We may randomly find copies of unscrubbed pages in the doublewrite buffer.
# Let us scrub the doublewrite buffer ourselves.
perl;
use Fcntl 'SEEK_SET';
my $page_size = $ENV{INNODB_PAGE_SIZE};
open(FILE, "+<", "$ENV{SEARCH_FILE}") or die "cannot open: $!\n";
seek(FILE, $page_size * 64, SEEK_SET) or die "cannot seek: $!\n";
print(FILE chr(0) x ($page_size * 128)) or die "cannot write: $!\n";
close FILE or die "cannot close: $!\n";;
EOF

-- source include/search_pattern_in_file.inc

let $formatno= $maxformatno;
while ($formatno)
{
dec $formatno;

let $t= delete_$formatno.ibd;
let SEARCH_FILE= $MYSQLD_DATADIR/test/$t;
-- echo # $t
-- source include/search_pattern_in_file.inc
let $t= delete_rollback_delete_$formatno.ibd;
let SEARCH_FILE= $MYSQLD_DATADIR/test/$t;
-- echo # $t
-- source include/search_pattern_in_file.inc
let $t= insert_rollback_$formatno.ibd;
let SEARCH_FILE= $MYSQLD_DATADIR/test/$t;
-- echo # $t
-- source include/search_pattern_in_file.inc
}

-- source include/start_mysqld.inc

let $formatno= $maxformatno;
while ($formatno)
{
dec $formatno;

let $t= delete_$formatno, delete_rollback_delete_$formatno, insert_rollback_$formatno;

eval check table $t;
eval drop table $t;
}

show variables like 'innodb_%scrub_data%';

--echo # verify that this test have not caused any background scrubbing
--sorted_result
select ss.variable_name, gs.variable_value - ss.variable_value as variable_value
from snapshot_status ss,
     information_schema.global_status gs
where ss.variable_name = gs.variable_name;

drop table snapshot_status;