mariadb/mysql-test/suite/encryption/r/innodb_encrypt_freed.result
Thirunarayanan Balathandayuthapani 6e80a34d68 MDEV-24695 Encryption modifies a freed page
During recovery, InnoDB fails if it tries to apply a FREE_PAGE
and WRITE record to the page. InnoDB encryption thread accesses
the freed page and writes redo log for it.

This is similar to commit deadec4e68 (MDEV-24569)
InnoDB is missing buf_page_free() while freeing the segment.
To avoid accessing of freed page in buffer pool, InnoDB should
mark the pages as FREED while freeing the segment. Also to
avoid reading of freed page, InnoDB should check the
allocation bitmap page.

fseg_free_step(): Mark the page in buffer pool as FREED

fseg_free_step_not_header(): Mark the page in buffer pool as FREED

buf_dump(): Ignore the freed pages while dumping the buffer pool content

fil_crypt_get_page_throttle_func(): Skip the rotation for FREED page
to avoid the assert failure during recovery

fil_crypt_rotate_page(): Skip the rotation for the freed page

Reviewed-by: Marko Mäkelä
2021-01-28 13:26:34 +05:30

96 lines
2.9 KiB
Text

SHOW VARIABLES LIKE 'innodb_encrypt%';
Variable_name Value
innodb_encrypt_log ON
innodb_encrypt_tables ON
innodb_encrypt_temporary_tables OFF
innodb_encryption_rotate_key_age 1
innodb_encryption_rotation_iops 100
innodb_encryption_threads 1
SET GLOBAL innodb_encrypt_tables = ON;
CREATE TABLE t1(f1 BIGINT PRIMARY KEY, f2 int not null,
f3 int not null, index(f1), index idx_1(f2),
index(f2, f3)) ENGINE=InnoDB;
# Wait max 10 min for key encryption threads to encrypt all spaces
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
innodb_system
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
test/t1
CREATE TABLE t2 (f1 int not null)engine=innodb;
# restart: --debug=d,ib_log_checkpoint_avoid
connect con1,localhost,root,,,;
begin;
insert into t2 values(1);
connection default;
set global innodb_encrypt_tables = OFF;
# Wait max 10 min for key encryption threads to decrypt all spaces
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
NAME
innodb_system
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
test/t1
test/t2
alter table t1 drop index idx_1;
set global innodb_encrypt_tables = ON;
# Wait max 10 min for key encryption threads to encrypt all spaces
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
innodb_system
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
test/t1
test/t2
disconnect con1;
# restart: --debug=d,ib_log_checkpoint_avoid
drop table t1, t2;
CREATE TABLE t1(f1 BIGINT PRIMARY KEY, f2 int not null,
f3 int not null, index(f1), index idx_1(f2),
index(f2, f3)) ENGINE=InnoDB;
# Wait max 10 min for key encryption threads to encrypt all spaces
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
innodb_system
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
test/t1
CREATE TABLE t2 (f1 int not null)engine=innodb;
# restart: --debug=d,ib_log_checkpoint_avoid
connect con1,localhost,root,,,;
begin;
insert into t2 values(1);
connection default;
set global innodb_encrypt_tables = OFF;
# Wait max 10 min for key encryption threads to decrypt all spaces
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
NAME
innodb_system
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
test/t1
test/t2
alter table t1 drop index idx_1;
disconnect con1;
# restart: --debug=d,ib_log_checkpoint_avoid
connect con1,localhost,root,,,;
begin;
insert into t2 values(1);
connection default;
set global innodb_encrypt_tables = ON;
# Wait max 10 min for key encryption threads to encrypt all spaces
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
innodb_system
mysql/innodb_index_stats
mysql/innodb_table_stats
mysql/transaction_registry
test/t1
test/t2
disconnect con1;
drop table t2, t1;