Commit ffb38c97 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-8139 Fix scrubbing tests

encryption.innodb_scrub: Clean up. Make it also cover ROW_FORMAT=COMPRESSED,
removing the need for encryption.innodb_scrub_compressed.
Add a FIXME comment saying that we should create a secondary index, to
demonstrate that also undo log pages get scrubbed. Currently that is
not working!

Also clean up encryption.innodb_scrub_background, but keep it disabled,
because the background scrubbing does not work reliably.

Fix both tests so that if something is not scrubbed, the test will be
aborted, so that the data files will be preserved. Allow the tests to
run on Windows as well.
parent 719321e7
......@@ -82,8 +82,14 @@ perl;
}
$ENV{'SEARCH_FILE'} =~ s{^.*?([^/\\]+)$}{$1};
if ($content =~ m{$search_pattern}) {
die "FOUND /$search_pattern/ in $ENV{'SEARCH_FILE'}\n"
if $ENV{SEARCH_ABORT} eq 'FOUND';
print "FOUND /$search_pattern/ in $ENV{'SEARCH_FILE'}\n"
unless defined $ENV{SEARCH_ABORT};
} else {
die "NOT FOUND /$search_pattern/ in $ENV{'SEARCH_FILE'}\n"
if $ENV{SEARCH_ABORT} eq 'NOT FOUND';
print "NOT FOUND /$search_pattern/ in $ENV{'SEARCH_FILE'}\n"
unless defined $ENV{SEARCH_ABORT};
}
EOF
......@@ -10,8 +10,4 @@
#
##############################################################################
innodb_scrub : MDEV-8139
innodb_scrub_compressed : MDEV-8139
innodb_scrub_background : MDEV-8139
innodb_encryption-page-compression : Fails with lost connection at line 156
innodb_scrub_background : MDEV-8139 background scrubbing does not work reliably
create table snapshot_status engine = myisam
select * from information_schema.global_status
where variable_name like 'innodb_scrub%';
#
# Test delete of records
#
create table t1 (
# MDEV-8139 Fix scrubbing tests
# FIXME: Add index(b) to each table; ensure that undo logs are scrubbed.
create table delete_3 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
delete from delete_3;
create table delete_rollback_delete_3 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
begin;
delete from delete_rollback_delete_3;
rollback;
delete from delete_rollback_delete_3;
create table insert_rollback_3 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
begin;
rollback;
create table delete_2 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compact;
# Populate table with rows
delete from t1;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# compact: delete from: grep -c bicycle t1.ibd
0
# compact: delete from: grep -c bicycle ibdata1
0
# compact: delete from: grep -c repairman t1.ibd
0
# compact: delete from: grep -c repairman ibdata1
0
drop table t1;
#
# Test delete+rollback+delete
#
create table t1 (
delete from delete_2;
create table delete_rollback_delete_2 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compact;
# Populate table with rows
begin;
delete from t1;
delete from delete_rollback_delete_2;
rollback;
delete from t1;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# compact: delete rollback: grep -c bicycle t1.ibd
0
# compact: delete rollback: grep -c bicycle ibdata1
0
# compact: delete rollback: grep -c repairman t1.ibd
0
# compact: delete rollback: grep -c repairman ibdata1
0
drop table t1;
#
# Test insert+rollback
#
create table t1 (
delete from delete_rollback_delete_2;
create table insert_rollback_2 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compact;
# Populate table with rows
begin;
rollback;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# compact: insert rollback: grep -c bicycle t1.ibd
0
# compact: insert rollback: grep -c bicycle ibdata1
0
# compact: insert rollback: grep -c repairman t1.ibd
0
# compact: insert rollback: grep -c repairman ibdata1
0
drop table t1;
#
# Test delete of records
#
create table t1 (
create table delete_1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=redundant;
# Populate table with rows
delete from t1;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# redundant: delete from: grep -c bicycle t1.ibd
0
# redundant: delete from: grep -c bicycle ibdata1
0
# redundant: delete from: grep -c repairman t1.ibd
0
# redundant: delete from: grep -c repairman ibdata1
0
drop table t1;
#
# Test delete+rollback+delete
#
create table t1 (
delete from delete_1;
create table delete_rollback_delete_1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=redundant;
# Populate table with rows
begin;
delete from t1;
delete from delete_rollback_delete_1;
rollback;
delete from t1;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# redundant: delete rollback: grep -c bicycle t1.ibd
0
# redundant: delete rollback: grep -c bicycle ibdata1
0
# redundant: delete rollback: grep -c repairman t1.ibd
0
# redundant: delete rollback: grep -c repairman ibdata1
0
drop table t1;
#
# Test insert+rollback
#
create table t1 (
delete from delete_rollback_delete_1;
create table insert_rollback_1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=redundant;
# Populate table with rows
begin;
rollback;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# redundant: insert rollback: grep -c bicycle t1.ibd
0
# redundant: insert rollback: grep -c bicycle ibdata1
0
# redundant: insert rollback: grep -c repairman t1.ibd
0
# redundant: insert rollback: grep -c repairman ibdata1
0
drop table t1;
#
# Test delete of records
#
create table t1 (
create table delete_0 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=dynamic;
# Populate table with rows
delete from t1;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# dynamic: delete from: grep -c bicycle t1.ibd
0
# dynamic: delete from: grep -c bicycle ibdata1
0
# dynamic: delete from: grep -c repairman t1.ibd
0
# dynamic: delete from: grep -c repairman ibdata1
0
drop table t1;
#
# Test delete+rollback+delete
#
create table t1 (
delete from delete_0;
create table delete_rollback_delete_0 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=dynamic;
# Populate table with rows
begin;
delete from t1;
delete from delete_rollback_delete_0;
rollback;
delete from t1;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# dynamic: delete rollback: grep -c bicycle t1.ibd
0
# dynamic: delete rollback: grep -c bicycle ibdata1
0
# dynamic: delete rollback: grep -c repairman t1.ibd
0
# dynamic: delete rollback: grep -c repairman ibdata1
0
drop table t1;
#
# Test insert+rollback
#
create table t1 (
delete from delete_rollback_delete_0;
create table insert_rollback_0 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=dynamic;
# Populate table with rows
begin;
rollback;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# dynamic: insert rollback: grep -c bicycle t1.ibd
0
# dynamic: insert rollback: grep -c bicycle ibdata1
0
# dynamic: insert rollback: grep -c repairman t1.ibd
0
# dynamic: insert rollback: grep -c repairman ibdata1
0
drop table t1;
SET GLOBAL innodb_fast_shutdown=0;
# delete_3.ibd
# delete_rollback_delete_3.ibd
# insert_rollback_3.ibd
# delete_2.ibd
# delete_rollback_delete_2.ibd
# insert_rollback_2.ibd
# delete_1.ibd
# delete_rollback_delete_1.ibd
# insert_rollback_1.ibd
# delete_0.ibd
# delete_rollback_delete_0.ibd
# insert_rollback_0.ibd
check table delete_3, delete_rollback_delete_3, insert_rollback_3;
Table Op Msg_type Msg_text
test.delete_3 check status OK
test.delete_rollback_delete_3 check status OK
test.insert_rollback_3 check status OK
drop table delete_3, delete_rollback_delete_3, insert_rollback_3;
check table delete_2, delete_rollback_delete_2, insert_rollback_2;
Table Op Msg_type Msg_text
test.delete_2 check status OK
test.delete_rollback_delete_2 check status OK
test.insert_rollback_2 check status OK
drop table delete_2, delete_rollback_delete_2, insert_rollback_2;
check table delete_1, delete_rollback_delete_1, insert_rollback_1;
Table Op Msg_type Msg_text
test.delete_1 check status OK
test.delete_rollback_delete_1 check status OK
test.insert_rollback_1 check status OK
drop table delete_1, delete_rollback_delete_1, insert_rollback_1;
check table delete_0, delete_rollback_delete_0, insert_rollback_0;
Table Op Msg_type Msg_text
test.delete_0 check status OK
test.delete_rollback_delete_0 check status OK
test.insert_rollback_0 check status OK
drop table delete_0, delete_rollback_delete_0, insert_rollback_0;
show variables like 'innodb_%scrub_data%';
Variable_name Value
innodb_background_scrub_data_check_interval 3600
......
......@@ -11,66 +11,146 @@ innodb_background_scrub_data_uncompressed ON
innodb_immediate_scrub_data_uncompressed OFF
# make sure spaces are checked quickly
SET GLOBAL innodb_background_scrub_data_check_interval=1;
create table snapshot_status engine = myisam
select * from information_schema.global_status
where variable_name like 'innodb_scrub%';
truncate table snapshot_status;
insert into snapshot_status
select * from information_schema.global_status
where variable_name like 'innodb_scrub%';
#
# Test delete of records
#
create table t1 (
create table delete_3 (
a int auto_increment primary key,
b varchar(256),
c text, index(b)) engine = innodb row_format=dynamic;
c text,
index(b)) engine = innodb row_format=compressed;
# Populate table with rows
delete from t1;
#
# Test delete+rollback+delete
#
create table t2 (
delete from delete_3;
create table delete_rollback_delete_3 (
a int auto_increment primary key,
b varchar(256),
c text, index(b)) engine = innodb row_format=dynamic;
c text,
index(b)) engine = innodb row_format=compressed;
# Populate table with rows
begin;
delete from t2;
delete from delete_rollback_delete_3;
rollback;
delete from t2;
#
# Test insert+rollback
#
create table t3 (
delete from delete_rollback_delete_3;
create table insert_rollback_3 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=compressed;
# Populate table with rows
begin;
rollback;
create table delete_2 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=compact;
# Populate table with rows
delete from delete_2;
create table delete_rollback_delete_2 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=compact;
# Populate table with rows
begin;
delete from delete_rollback_delete_2;
rollback;
delete from delete_rollback_delete_2;
create table insert_rollback_2 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=compact;
# Populate table with rows
begin;
rollback;
create table delete_1 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=redundant;
# Populate table with rows
delete from delete_1;
create table delete_rollback_delete_1 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=redundant;
# Populate table with rows
begin;
delete from delete_rollback_delete_1;
rollback;
delete from delete_rollback_delete_1;
create table insert_rollback_1 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=redundant;
# Populate table with rows
begin;
rollback;
create table delete_0 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=dynamic;
# Populate table with rows
delete from delete_0;
create table delete_rollback_delete_0 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=dynamic;
# Populate table with rows
begin;
delete from delete_rollback_delete_0;
rollback;
delete from delete_rollback_delete_0;
create table insert_rollback_0 (
a int auto_increment primary key,
b varchar(256),
c text, index(b)) engine = innodb row_format=dynamic;
c text,
index(b)) engine = innodb row_format=dynamic;
# Populate table with rows
begin;
rollback;
# start scrubbing threads
SET GLOBAL innodb_encryption_threads=5;
# Wait max 10 min for scrubbing
# Success!
# stop scrubbing threads
SET GLOBAL innodb_encryption_threads=0;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# dynamic: delete: grep -c bicycle t1.ibd
0
# dynamic: delete: grep -c repairman t1.ibd
0
# dynamic: delete rollback: grep -c bicycle t2.ibd
0
# dynamic: delete rollback: grep -c repairman t2.ibd
0
# dynamic: insert rollback: grep -c bicycle t3.ibd
0
# dynamic: insert rollback: grep -c repairman t3.ibd
0
drop table t1, t2, t3;
SET GLOBAL innodb_fast_shutdown=0;
# delete_3.ibd
# delete_rollback_delete_3.ibd
# insert_rollback_3.ibd
# delete_2.ibd
# delete_rollback_delete_2.ibd
# insert_rollback_2.ibd
# delete_1.ibd
# delete_rollback_delete_1.ibd
# insert_rollback_1.ibd
# delete_0.ibd
# delete_rollback_delete_0.ibd
# insert_rollback_0.ibd
check table delete_3, delete_rollback_delete_3, insert_rollback_3;
Table Op Msg_type Msg_text
test.delete_3 check status OK
test.delete_rollback_delete_3 check status OK
test.insert_rollback_3 check status OK
drop table delete_3, delete_rollback_delete_3, insert_rollback_3;
check table delete_2, delete_rollback_delete_2, insert_rollback_2;
Table Op Msg_type Msg_text
test.delete_2 check status OK
test.delete_rollback_delete_2 check status OK
test.insert_rollback_2 check status OK
drop table delete_2, delete_rollback_delete_2, insert_rollback_2;
check table delete_1, delete_rollback_delete_1, insert_rollback_1;
Table Op Msg_type Msg_text
test.delete_1 check status OK
test.delete_rollback_delete_1 check status OK
test.insert_rollback_1 check status OK
drop table delete_1, delete_rollback_delete_1, insert_rollback_1;
check table delete_0, delete_rollback_delete_0, insert_rollback_0;
Table Op Msg_type Msg_text
test.delete_0 check status OK
test.delete_rollback_delete_0 check status OK
test.insert_rollback_0 check status OK
drop table delete_0, delete_rollback_delete_0, insert_rollback_0;
show variables like 'innodb_%scrub_data%';
Variable_name Value
innodb_background_scrub_data_check_interval 3600
......@@ -78,4 +158,3 @@ innodb_background_scrub_data_compressed ON
innodb_background_scrub_data_interval 604800
innodb_background_scrub_data_uncompressed ON
innodb_immediate_scrub_data_uncompressed OFF
drop table snapshot_status;
# make sure spaces are checked quickly
SET GLOBAL innodb_background_scrub_data_check_interval=1;
#
# Test delete of records
#
create table t1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
# Populate table with rows
delete from t1;
#
# Test delete+rollback+delete
#
create table t2 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
# Populate table with rows
begin;
delete from t2;
rollback;
delete from t2;
#
# Test insert+rollback
#
create table t3 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
# Populate table with rows
begin;
rollback;
# start scrubbing threads
SET GLOBAL innodb_encryption_threads=5;
# Wait max 10 min for scrubbing of this table
# Success!
# stop scrubbing threads
SET GLOBAL innodb_encryption_threads=0;
# Now there should be background scrubs
# restart mysqld so that all pages are flushed (encryption off)
# so that grep will find stuff
# read all rows from table
select * from t1;
select * from t2;
select * from t3;
# grep -c bicycle t1.ibd
0
# grep -c bicycle ibdata1
0
# grep -c repairman t1.ibd
0
# grep -c repairman ibdata1
0
# grep -c boondoggle t2.ibd
0
# grep -c boondoggle ibdata1
0
# grep -c waste t2.ibd
0
# grep -c waste ibdata1
0
# grep -c keso t3.ibd
0
# grep -c keso ibdata1
0
# grep -c kent t3.ibd
0
# grep -c kent ibdata1
0
drop table t1, t2, t3;
-- source include/have_innodb.inc
-- source include/not_embedded.inc
-- source include/have_example_key_management_plugin.inc
-- source include/not_windows.inc
let $MYSQLD_DATADIR=`select @@datadir`;
let ib1_IBD = $MYSQLD_DATADIR/ibdata1;
let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd;
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%';
let $rowcount=500;
let $formatno = 3;
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 1 then 'dynamic'
when 2 then 'redundant'
when 3 then 'compact'
when 0 then 'dynamic'
when 1 then 'redundant'
when 2 then 'compact'
when 3 then 'compressed'
end`;
dec $formatno;
-- echo #
-- echo # Test delete of records
-- echo #
eval create table t1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=$format;
let $t= delete_$formatno;
eval create table $t $tableformat=$format;
let $numinserts = $rowcount;
-- echo # Populate table with rows
--disable_query_log
begin;
while ($numinserts)
{
dec $numinserts;
insert into t1(b,c) values ('bicycle', repeat('repairman', 1000));
eval insert into $t(b,c) values ('repairman', repeat('unicycle', 1000));
}
commit;
--enable_query_log
delete from t1;
eval delete from $t;
-- echo # restart mysqld so that all pages are flushed
-- source include/restart_mysqld.inc
-- echo # read all rows from table
-- disable_result_log
select * from t1;
-- enable_result_log
-- echo # $format: delete from: grep -c bicycle t1.ibd
-- exec grep -c bicycle $t1_IBD || true
-- echo # $format: delete from: grep -c bicycle ibdata1
-- exec grep -c bicycle $ib1_IBD || true
-- echo # $format: delete from: grep -c repairman t1.ibd
-- exec grep -c repairman $t1_IBD || true
-- echo # $format: delete from: grep -c repairman ibdata1
-- exec grep -c repairman $ib1_IBD || true
drop table t1;
-- echo #
-- echo # Test delete+rollback+delete
-- echo #
eval create table t1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=$format;
let $t= delete_rollback_delete_$formatno;
eval create table $t $tableformat=$format;
let $numinserts = $rowcount;
-- echo # Populate table with rows
--disable_query_log
begin;
while ($numinserts)
{
dec $numinserts;
insert into t1(b,c) values ('bicycle', repeat('repairman', 1000));
eval insert into $t(b,c) values ('breakhuman', repeat('bicycle', 1000));
}
commit;
--enable_query_log
begin;
delete from t1;
eval delete from $t;
rollback;
delete from t1;
-- echo # restart mysqld so that all pages are flushed
-- source include/restart_mysqld.inc
-- echo # read all rows from table
-- disable_result_log
select * from t1;
-- enable_result_log
-- echo # $format: delete rollback: grep -c bicycle t1.ibd
-- exec grep -c bicycle $t1_IBD || true
-- echo # $format: delete rollback: grep -c bicycle ibdata1
-- exec grep -c bicycle $ib1_IBD || true
-- echo # $format: delete rollback: grep -c repairman t1.ibd
-- exec grep -c repairman $t1_IBD || true
-- echo # $format: delete rollback: grep -c repairman ibdata1
-- exec grep -c repairman $ib1_IBD || true
drop table t1;
-- echo #
-- echo # Test insert+rollback
-- echo #
eval create table t1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=$format;
eval delete from $t;
let $t= insert_rollback_$formatno;
eval create table $t $tableformat=$format;
let $numinserts = $rowcount;
-- echo # Populate table with rows
begin;
--disable_query_log
while ($numinserts)
{
dec $numinserts;
insert into t1(b,c) values ('bicycle', repeat('repairman', 1000));
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;
-- echo # restart mysqld so that all pages are flushed
-- source include/restart_mysqld.inc
-- echo # read all rows from table
-- disable_result_log
select * from t1;
-- enable_result_log
-- echo # $format: insert rollback: grep -c bicycle t1.ibd
-- exec grep -c bicycle $t1_IBD || true
-- echo # $format: insert rollback: grep -c bicycle ibdata1
-- exec grep -c bicycle $ib1_IBD || true
-- echo # $format: insert rollback: grep -c repairman t1.ibd
-- exec grep -c repairman $t1_IBD || true
-- echo # $format: insert rollback: grep -c repairman ibdata1
-- exec grep -c repairman $ib1_IBD || true
drop table t1;
eval check table $t;
eval drop table $t;
}
show variables like 'innodb_%scrub_data%';
......
-- source include/have_innodb.inc
-- source include/not_embedded.inc
-- source include/have_example_key_management_plugin.inc
-- source include/not_windows.inc
let $MYSQLD_DATADIR=`select @@datadir`;
let ib1_IBD = $MYSQLD_DATADIR/ibdata1;
let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd;
let t2_IBD = $MYSQLD_DATADIR/test/t2.ibd;
let t3_IBD = $MYSQLD_DATADIR/test/t3.ibd;
let INNODB_PAGE_SIZE= `select @@innodb_page_size`;
--echo #
--echo # immediate scrubbing is off
......@@ -18,80 +14,67 @@ show variables like 'innodb_%scrub_data%';
-- echo # make sure spaces are checked quickly
SET GLOBAL innodb_background_scrub_data_check_interval=1;
create table snapshot_status engine = myisam
select * from information_schema.global_status
where variable_name like 'innodb_scrub%';
let $rowcount=500;
let $formatno = 1;
let $maxformatno= 4;
let $formatno= $maxformatno;
let $tableformat= (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format;
while ($formatno)
{
dec $formatno;
let $format = `select case $formatno
when 1 then 'dynamic'
when 2 then 'redundant'
when 3 then 'compact'
when 4 then 'compressed'
when 0 then 'dynamic'
when 1 then 'redundant'
when 2 then 'compact'
when 3 then 'compressed'
end`;
dec $formatno;
truncate table snapshot_status;
insert into snapshot_status
select * from information_schema.global_status
where variable_name like 'innodb_scrub%';
-- echo #
-- echo # Test delete of records
-- echo #
eval create table t1 (
a int auto_increment primary key,
b varchar(256),
c text, index(b)) engine = innodb row_format=$format;
let $t= delete_$formatno;
eval create table $t $tableformat=$format;
let $numinserts = $rowcount;
-- echo # Populate table with rows
--disable_query_log
begin;
while ($numinserts)
{
dec $numinserts;
insert into t1(b,c) values ('bicycle', repeat('repairman', 1000));
eval insert into $t(b,c) values ('unicycle', repeat('wonderwoman', 1000));
}
commit;
--enable_query_log
delete from t1;
eval delete from $t;
-- echo #
-- echo # Test delete+rollback+delete
-- echo #
let $t= delete_rollback_delete_$formatno;
eval create table t2 (
a int auto_increment primary key,
b varchar(256),
c text, index(b)) engine = innodb row_format=$format;
eval create table $t $tableformat=$format;
let $numinserts = $rowcount;
-- echo # Populate table with rows
--disable_query_log
begin;
while ($numinserts)
{
dec $numinserts;
insert into t2(b,c) values ('bicycle', repeat('repairman', 1000));
eval insert into $t(b,c) values ('bicycle', repeat('repairman', 1000));
}
commit;
--enable_query_log
begin;
delete from t2;
eval delete from $t;
rollback;
delete from t2;
eval delete from $t;
-- echo #
-- echo # Test insert+rollback
-- echo #
let $t= insert_rollback_$formatno;
eval create table t3 (
a int auto_increment primary key,
b varchar(256),
c text, index(b)) engine = innodb row_format=$format;
eval create table $t $tableformat=$format;
let $numinserts = $rowcount;
-- echo # Populate table with rows
......@@ -100,11 +83,12 @@ begin;
while ($numinserts)
{
dec $numinserts;
insert into t3(b,c) values ('bicycle', repeat('repairman', 1000));
eval insert into $t(b,c) values ('tricycle', repeat('superhuman', 1000));
}
--enable_query_log
rollback;
}
-- echo # start scrubbing threads
SET GLOBAL innodb_encryption_threads=5;
......@@ -130,35 +114,57 @@ if (!$success)
-- die Timeout waiting for background threads
}
-- echo # Success!
-- echo # stop scrubbing threads
SET GLOBAL innodb_encryption_threads=0;
-- echo # restart mysqld so that all pages are flushed
-- source include/restart_mysqld.inc
-- echo # read all rows from table
-- disable_result_log
select * from t1;
-- enable_result_log
-- echo # $format: delete: grep -c bicycle t1.ibd
-- exec grep -c bicycle $t1_IBD || true
-- echo # $format: delete: grep -c repairman t1.ibd
-- exec grep -c repairman $t1_IBD || true
-- echo # $format: delete rollback: grep -c bicycle t2.ibd
-- exec grep -c bicycle $t2_IBD || true
-- echo # $format: delete rollback: grep -c repairman t2.ibd
-- exec grep -c repairman $t2_IBD || true
-- echo # $format: insert rollback: grep -c bicycle t3.ibd
-- exec grep -c bicycle $t3_IBD || true
-- echo # $format: insert rollback: grep -c repairman t3.ibd
-- exec grep -c repairman $t3_IBD || true
drop table t1, t2, t3;
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
}
show variables like 'innodb_%scrub_data%';
-- source include/start_mysqld.inc
drop table snapshot_status;
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%';
--innodb-file-per-table=1
--innodb-file-format=Barracuda
--innodb-immediate-scrub-data-uncompressed=ON
--innodb-background-scrub-data-uncompressed=ON
--innodb-background-scrub-data-compressed=ON
--loose-innodb-debug-force-scrubbing=ON
--innodb-encrypt-tables=OFF
--innodb-encrypt-log=OFF
--innodb-tablespaces-scrubbing
-- source include/have_innodb.inc
-- source include/not_embedded.inc
-- source include/have_example_key_management_plugin.inc
-- source include/not_windows.inc
let $MYSQLD_DATADIR=`select @@datadir`;
let ib1_IBD = $MYSQLD_DATADIR/ibdata1;
let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd;
let t2_IBD = $MYSQLD_DATADIR/test/t2.ibd;
let t3_IBD = $MYSQLD_DATADIR/test/t3.ibd;
let $rowcount=500;
-- echo # make sure spaces are checked quickly
SET GLOBAL innodb_background_scrub_data_check_interval=1;
-- echo #
-- echo # Test delete of records
-- echo #
eval create table t1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
let $numinserts = $rowcount;
-- echo # Populate table with rows
--disable_query_log
while ($numinserts)
{
dec $numinserts;
insert into t1(b,c) values ('bicycle', repeat('repairman', 1000));
}
--enable_query_log
delete from t1;
-- echo #
-- echo # Test delete+rollback+delete
-- echo #
eval create table t2 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
let $numinserts = $rowcount;
-- echo # Populate table with rows
--disable_query_log
while ($numinserts)
{
dec $numinserts;
insert into t2(b,c) values ('boondoggle', repeat('waste of time', 1000));
}
--enable_query_log
begin;
delete from t2;
rollback;
delete from t2;
-- echo #
-- echo # Test insert+rollback
-- echo #
eval create table t3 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
let $numinserts = $rowcount;
-- echo # Populate table with rows
begin;
--disable_query_log
while ($numinserts)
{
dec $numinserts;
insert into t3(b,c) values ('keso', repeat('kent', 1000));
}
--enable_query_log
rollback;
-- echo # start scrubbing threads
SET GLOBAL innodb_encryption_threads=5;
-- echo # Wait max 10 min for scrubbing of this table
let $cnt=600;
while ($cnt)
{
let $success=`SELECT COUNT(*) = 0
FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_SCRUBBING
WHERE LAST_SCRUB_COMPLETED IS NULL AND ( NAME like 'test/%' OR SPACE = 0 )`;
if ($success)
{
let $cnt=0;
}
if (!$success)
{
real_sleep 1;
dec $cnt;
}
}
if (!$success)
{
SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_SCRUBBING;
SHOW STATUS LIKE 'innodb_%scrub%';
-- die Timeout waiting for background threads
}
-- echo # Success!
-- echo # stop scrubbing threads
SET GLOBAL innodb_encryption_threads=0;
--echo # Now there should be background scrubs
let $success=`select sum(variable_value) > 0
from information_schema.global_status
where variable_name in ('innodb_scrub_background_page_reorganizations',
'innodb_scrub_background_page_splits')`;
if (!$success) {
show status like 'innodb_scrub%';
}
-- echo # restart mysqld so that all pages are flushed (encryption off)
-- echo # so that grep will find stuff
-- source include/restart_mysqld.inc
-- echo # read all rows from table
-- disable_result_log
select * from t1;
select * from t2;
select * from t3;
-- enable_result_log
-- echo # grep -c bicycle t1.ibd
-- exec grep -c bicycle $t1_IBD || true
-- echo # grep -c bicycle ibdata1
-- exec grep -c bicycle $ib1_IBD || true
-- echo # grep -c repairman t1.ibd
-- exec grep -c repairman $t1_IBD || true
-- echo # grep -c repairman ibdata1
-- exec grep -c repairman $ib1_IBD || true
-- echo # grep -c boondoggle t2.ibd
-- exec grep -c boondoggle $t2_IBD || true
-- echo # grep -c boondoggle ibdata1
-- exec grep -c boondoggle $ib1_IBD || true
-- echo # grep -c waste t2.ibd
-- exec grep -c waste $t2_IBD || true
-- echo # grep -c waste ibdata1
-- exec grep -c waste $ib1_IBD || true
-- echo # grep -c keso t3.ibd
-- exec grep -c keso $t3_IBD || true
-- echo # grep -c keso ibdata1
-- exec grep -c keso $ib1_IBD || true
-- echo # grep -c kent t3.ibd
-- exec grep -c kent $t3_IBD || true
-- echo # grep -c kent ibdata1
-- exec grep -c kent $ib1_IBD || true
drop table t1, t2, t3;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment