# Stop the instance which was created by MTR
# create bootstrap file
# Bootstrap new instance with encrypted system tablespace
# Start the instance with encrypted system tablespace
# restart: --datadir=MYSQLD_DATADIR1 --innodb-sys-tablespace-encrypt=ON
# Test Doublewrite buffer of encrypted sys. To achieve this
# we have to make sure parallel doublewrite buffer is not
# used. This is achieved by disabling page cleaners and
# flush happens via FLUSH TABLE t1 FOR EXPORT. The only
# single page flush happens and only doublewrite in system
# tablespace is used.
create table t1 (f1 int primary key, f2 blob) engine=innodb;
SET GLOBAL innodb_page_cleaner_disabled_debug = true;
SET GLOBAL innodb_master_thread_disabled_debug=true;
start transaction;
insert into t1 values(1, repeat('#',12));
insert into t1 values(2, repeat('+',12));
insert into t1 values(3, repeat('/',12));
insert into t1 values(4, repeat('-',12));
insert into t1 values(5, repeat('.',12));
commit work;
select space from information_schema.innodb_sys_tables
where name = 'test/t1' into @space_id;
# Wait for purge to complete
# Ensure that dirty pages of table t1 is flushed.
flush tables t1 for export;
unlock tables;
begin;
insert into t1 values (6, repeat('%', 12));
# Make the first page dirty for table t1
set global innodb_saved_page_number_debug = 3;
set global innodb_fil_make_page_dirty_debug = @space_id;
# Kill the server
# Make the 3rd page of the user tablespace
# corrupted
# restart: --datadir=MYSQLD_DATADIR1 --innodb-sys-tablespace-encrypt=ON
check table t1;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
select f1, f2 from t1;
f1	f2
1	############
2	++++++++++++
3	////////////
4	------------
5	............
drop table t1;
#
# Test Encrypted Parallel Doublewrite buffer . To achieve this
# we have to make sure parallel doublewrite buffer only happens
# This is achieved by flushing via page cleaners.
# Single page flush happens via FLUSH TABLE t1 FOR EXPORT should
# avoided.
#
create table t1 (f1 int primary key, f2 blob) engine=innodb encryption='Y';
SET GLOBAL innodb_page_cleaner_disabled_debug = true;
SET GLOBAL innodb_master_thread_disabled_debug=true;
SET GLOBAL innodb_parallel_dblwr_encrypt=true;
start transaction;
insert into t1 values(1, repeat('#',12));
insert into t1 values(2, repeat('+',12));
insert into t1 values(3, repeat('/',12));
insert into t1 values(4, repeat('-',12));
insert into t1 values(5, repeat('.',12));
commit work;
select space from information_schema.innodb_sys_tables
where name = 'test/t1' into @space_id;
# Wait for purge to complete
begin;
insert into t1 values (6, repeat('%', 12));
# Make the first page dirty for table t1
set global innodb_saved_page_number_debug = 1;
set global innodb_fil_make_page_dirty_debug = @space_id;
set global innodb_page_cleaner_disabled_debug= false;
set global innodb_buf_flush_list_now=ON;
# Kill the server
# Make the 1st page of the user tablespace
# corrupted
# restart: --datadir=MYSQLD_DATADIR1 --innodb-sys-tablespace-encrypt=ON
check table t1;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
select f1, f2 from t1;
f1	f2
1	############
2	++++++++++++
3	////////////
4	------------
5	............
drop table t1;
# Start default MTR instance
# restart
