mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-9931: InnoDB reads first page of every .ibd file at startup
Analysis: By design InnoDB was reading first page of every .ibd file at startup to find out is tablespace encrypted or not. This is because tablespace could have been encrypted always, not encrypted newer or encrypted based on configuration and this information can be find realible only from first page of .ibd file. Fix: Do not read first page of every .ibd file at startup. Instead whenever tablespace is first time accedded we will read the first page to find necessary information about tablespace encryption status. TODO: Add support for SYS_TABLEOPTIONS where all table options encryption information included will be stored.
This commit is contained in:
@@ -36,10 +36,13 @@ SELECT * FROM t1;
|
||||
ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
|
||||
SHOW WARNINGS;
|
||||
Level Code Message
|
||||
Warning 1812 Tablespace is missing for table 'test/t1'
|
||||
Warning 192 Table test/t1 is encrypted but encryption service or used key_id 2 is not available. Can't continue reading table.
|
||||
Warning 192 Table test/t1 in tablespace 6 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
|
||||
Warning 192 Table test/t1 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
|
||||
Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
|
||||
DROP TABLE t1;
|
||||
Warnings:
|
||||
Warning 192 Table in tablespace 6 encrypted.However key management plugin or used key_id 1 is not found or used encryption algorithm or method does not match. Can't continue opening the table.
|
||||
Warning 192 Table in tablespace 6 encrypted.However key management plugin or used key_id 1 is not found or used encryption algorithm or method does not match. Can't continue opening the table.
|
||||
# Start server with keys.txt
|
||||
CREATE TABLE t2 (c VARCHAR(8), id int not null primary key, b int, key(b)) ENGINE=InnoDB ENCRYPTED=YES;
|
||||
INSERT INTO t2 VALUES ('foobar',1,2);
|
||||
|
@@ -0,0 +1,153 @@
|
||||
SET GLOBAL innodb_file_format = `Barracuda`;
|
||||
SET GLOBAL innodb_file_per_table = ON;
|
||||
create table innodb_compressed1(c1 bigint not null primary key, d int, a varchar(20), b char(200)) engine=innodb row_format=compressed encrypted=yes;
|
||||
create table innodb_compressed2(c1 bigint not null primary key, d int, a varchar(20), b char(200)) engine=innodb row_format=compressed key_block_size=1 encrypted=yes;
|
||||
create table innodb_compressed3(c1 bigint not null primary key, d int, a varchar(20), b char(200)) engine=innodb row_format=compressed key_block_size=2 encrypted=yes;
|
||||
create table innodb_compressed4(c1 bigint not null primary key, d int, a varchar(20), b char(200)) engine=innodb row_format=compressed key_block_size=4 encrypted=yes;
|
||||
insert into innodb_compressed1 values (1, 20, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (2, 20, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (3, 30, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (4, 30, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (5, 30, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (6, 30, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (7, 30, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (8, 20, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (9, 20, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (10, 20, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed2 select * from innodb_compressed1;
|
||||
insert into innodb_compressed3 select * from innodb_compressed1;
|
||||
insert into innodb_compressed4 select * from innodb_compressed1;
|
||||
# t1 yes on expecting NOT FOUND
|
||||
NOT FOUND /private/ in innodb_compressed1.ibd
|
||||
# t2 yes on expecting NOT FOUND
|
||||
NOT FOUND /private/ in innodb_compressed2.ibd
|
||||
# t3 yes on expecting NOT FOUND
|
||||
NOT FOUND /private/ in innodb_compressed3.ibd
|
||||
# t4 yes on expecting NOT FOUND
|
||||
NOT FOUND /private/ in innodb_compressed4.ibd
|
||||
SET GLOBAL innodb_file_format = `Barracuda`;
|
||||
SET GLOBAL innodb_file_per_table = ON;
|
||||
select * from innodb_compressed1 where d = 20;
|
||||
c1 d a b
|
||||
1 20 private evenmoreprivate
|
||||
2 20 private evenmoreprivate
|
||||
8 20 private evenmoreprivate
|
||||
9 20 private evenmoreprivate
|
||||
10 20 private evenmoreprivate
|
||||
select * from innodb_compressed1 where d = 30;
|
||||
c1 d a b
|
||||
3 30 private evenmoreprivate
|
||||
4 30 private evenmoreprivate
|
||||
5 30 private evenmoreprivate
|
||||
6 30 private evenmoreprivate
|
||||
7 30 private evenmoreprivate
|
||||
select * from innodb_compressed2 where d = 20;
|
||||
c1 d a b
|
||||
1 20 private evenmoreprivate
|
||||
2 20 private evenmoreprivate
|
||||
8 20 private evenmoreprivate
|
||||
9 20 private evenmoreprivate
|
||||
10 20 private evenmoreprivate
|
||||
select * from innodb_compressed2 where d = 30;
|
||||
c1 d a b
|
||||
3 30 private evenmoreprivate
|
||||
4 30 private evenmoreprivate
|
||||
5 30 private evenmoreprivate
|
||||
6 30 private evenmoreprivate
|
||||
7 30 private evenmoreprivate
|
||||
select * from innodb_compressed3 where d = 20;
|
||||
c1 d a b
|
||||
1 20 private evenmoreprivate
|
||||
2 20 private evenmoreprivate
|
||||
8 20 private evenmoreprivate
|
||||
9 20 private evenmoreprivate
|
||||
10 20 private evenmoreprivate
|
||||
select * from innodb_compressed3 where d = 30;
|
||||
c1 d a b
|
||||
3 30 private evenmoreprivate
|
||||
4 30 private evenmoreprivate
|
||||
5 30 private evenmoreprivate
|
||||
6 30 private evenmoreprivate
|
||||
7 30 private evenmoreprivate
|
||||
select * from innodb_compressed4 where d = 20;
|
||||
c1 d a b
|
||||
1 20 private evenmoreprivate
|
||||
2 20 private evenmoreprivate
|
||||
8 20 private evenmoreprivate
|
||||
9 20 private evenmoreprivate
|
||||
10 20 private evenmoreprivate
|
||||
select * from innodb_compressed4 where d = 30;
|
||||
c1 d a b
|
||||
3 30 private evenmoreprivate
|
||||
4 30 private evenmoreprivate
|
||||
5 30 private evenmoreprivate
|
||||
6 30 private evenmoreprivate
|
||||
7 30 private evenmoreprivate
|
||||
update innodb_compressed1 set d = d + 10 where d = 30;
|
||||
update innodb_compressed2 set d = d + 10 where d = 30;
|
||||
update innodb_compressed3 set d = d + 10 where d = 30;
|
||||
update innodb_compressed4 set d = d + 10 where d = 30;
|
||||
insert into innodb_compressed1 values (20, 60, 'newprivate', 'newevenmoreprivate');
|
||||
insert into innodb_compressed2 values (20, 60, 'newprivate', 'newevenmoreprivate');
|
||||
insert into innodb_compressed3 values (20, 60, 'newprivate', 'newevenmoreprivate');
|
||||
insert into innodb_compressed4 values (20, 60, 'newprivate', 'newevenmoreprivate');
|
||||
# t1 yes on expecting NOT FOUND
|
||||
NOT FOUND /private/ in innodb_compressed1.ibd
|
||||
# t2 yes on expecting NOT FOUND
|
||||
NOT FOUND /private/ in innodb_compressed2.ibd
|
||||
# t3 yes on expecting NOT FOUND
|
||||
NOT FOUND /private/ in innodb_compressed3.ibd
|
||||
# t4 yes on expecting NOT FOUND
|
||||
NOT FOUND /private/ in innodb_compressed4.ibd
|
||||
select * from innodb_compressed1 where d = 40;
|
||||
c1 d a b
|
||||
3 40 private evenmoreprivate
|
||||
4 40 private evenmoreprivate
|
||||
5 40 private evenmoreprivate
|
||||
6 40 private evenmoreprivate
|
||||
7 40 private evenmoreprivate
|
||||
select * from innodb_compressed1 where d = 60;
|
||||
c1 d a b
|
||||
20 60 newprivate newevenmoreprivate
|
||||
select * from innodb_compressed2 where d = 40;
|
||||
c1 d a b
|
||||
3 40 private evenmoreprivate
|
||||
4 40 private evenmoreprivate
|
||||
5 40 private evenmoreprivate
|
||||
6 40 private evenmoreprivate
|
||||
7 40 private evenmoreprivate
|
||||
select * from innodb_compressed2 where d = 60;
|
||||
c1 d a b
|
||||
20 60 newprivate newevenmoreprivate
|
||||
select * from innodb_compressed3 where d = 40;
|
||||
c1 d a b
|
||||
3 40 private evenmoreprivate
|
||||
4 40 private evenmoreprivate
|
||||
5 40 private evenmoreprivate
|
||||
6 40 private evenmoreprivate
|
||||
7 40 private evenmoreprivate
|
||||
select * from innodb_compressed3 where d = 60;
|
||||
c1 d a b
|
||||
20 60 newprivate newevenmoreprivate
|
||||
select * from innodb_compressed4 where d = 40;
|
||||
c1 d a b
|
||||
3 40 private evenmoreprivate
|
||||
4 40 private evenmoreprivate
|
||||
5 40 private evenmoreprivate
|
||||
6 40 private evenmoreprivate
|
||||
7 40 private evenmoreprivate
|
||||
select * from innodb_compressed4 where d = 60;
|
||||
c1 d a b
|
||||
20 60 newprivate newevenmoreprivate
|
||||
# t1 yes on expecting NOT FOUND
|
||||
NOT FOUND /private/ in innodb_compressed1.ibd
|
||||
# t2 yes on expecting NOT FOUND
|
||||
NOT FOUND /private/ in innodb_compressed2.ibd
|
||||
# t3 yes on expecting NOT FOUND
|
||||
NOT FOUND /private/ in innodb_compressed3.ibd
|
||||
# t4 yes on expecting NOT FOUND
|
||||
NOT FOUND /private/ in innodb_compressed4.ibd
|
||||
drop table innodb_compressed1;
|
||||
drop table innodb_compressed2;
|
||||
drop table innodb_compressed3;
|
||||
drop table innodb_compressed4;
|
154
mysql-test/suite/encryption/r/innodb_lotoftables.result
Normal file
154
mysql-test/suite/encryption/r/innodb_lotoftables.result
Normal file
@@ -0,0 +1,154 @@
|
||||
SET GLOBAL innodb_file_format = `Barracuda`;
|
||||
SET GLOBAL innodb_file_per_table = ON;
|
||||
SHOW VARIABLES LIKE 'innodb_encrypt%';
|
||||
Variable_name Value
|
||||
innodb_encrypt_log OFF
|
||||
innodb_encrypt_tables OFF
|
||||
innodb_encryption_rotate_key_age 1
|
||||
innodb_encryption_rotation_iops 100
|
||||
innodb_encryption_threads 0
|
||||
create database innodb_encrypted_1;
|
||||
use innodb_encrypted_1;
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 1
|
||||
set autocommit=0;
|
||||
set autocommit=1;
|
||||
commit work;
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 1
|
||||
# should be 100
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%';
|
||||
COUNT(*)
|
||||
100
|
||||
create database innodb_encrypted_2;
|
||||
use innodb_encrypted_2;
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 3
|
||||
set autocommit=0;
|
||||
commit work;
|
||||
set autocommit=1;
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 3
|
||||
# should be 100
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
COUNT(*)
|
||||
100
|
||||
# should be 100
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
COUNT(*)
|
||||
100
|
||||
create database innodb_encrypted_3;
|
||||
use innodb_encrypted_3;
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 3
|
||||
set autocommit=0;
|
||||
commit work;
|
||||
set autocommit=1;
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 3
|
||||
# should be 100
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
COUNT(*)
|
||||
100
|
||||
# should be 200
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
COUNT(*)
|
||||
200
|
||||
use test;
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 3
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
COUNT(*)
|
||||
100
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
COUNT(*)
|
||||
200
|
||||
SET GLOBAL innodb_encrypt_tables = on;
|
||||
SET GLOBAL innodb_encryption_threads=4;
|
||||
# Wait until all encrypted tables have been encrypted
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
COUNT(*)
|
||||
200
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
COUNT(*)
|
||||
100
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 3
|
||||
# Success!
|
||||
# Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0
|
||||
# Restart Success!
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 3
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 3
|
||||
use test;
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 3
|
||||
use innodb_encrypted_1;
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 3
|
||||
use innodb_encrypted_2;
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 3
|
||||
use innodb_encrypted_3;
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 3
|
||||
use innodb_encrypted_1;
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 3
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 103
|
||||
use innodb_encrypted_2;
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 103
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 203
|
||||
use innodb_encrypted_3;
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 203
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 203
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
COUNT(*)
|
||||
100
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
COUNT(*)
|
||||
200
|
||||
SET GLOBAL innodb_encrypt_tables = off;
|
||||
SET GLOBAL innodb_encryption_threads=4;
|
||||
# Wait until all default encrypted tables have been decrypted
|
||||
# should be 100
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
COUNT(*)
|
||||
100
|
||||
# should be 200
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
COUNT(*)
|
||||
200
|
||||
show status like 'innodb_pages0_read%';
|
||||
Variable_name Value
|
||||
Innodb_pages0_read 303
|
||||
use test;
|
||||
drop database innodb_encrypted_1;
|
||||
drop database innodb_encrypted_2;
|
||||
drop database innodb_encrypted_3;
|
@@ -0,0 +1,4 @@
|
||||
--innodb-encrypt-tables=ON
|
||||
--innodb-encryption-rotate-key-age=15
|
||||
--innodb-encryption-threads=4
|
||||
--innodb-tablespaces-encryption
|
@@ -0,0 +1,125 @@
|
||||
-- source include/have_innodb.inc
|
||||
-- source include/have_file_key_management_plugin.inc
|
||||
-- source include/not_embedded.inc
|
||||
|
||||
--disable_query_log
|
||||
let $innodb_file_format_orig = `SELECT @@innodb_file_format`;
|
||||
let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`;
|
||||
--enable_query_log
|
||||
|
||||
SET GLOBAL innodb_file_format = `Barracuda`;
|
||||
SET GLOBAL innodb_file_per_table = ON;
|
||||
|
||||
create table innodb_compressed1(c1 bigint not null primary key, d int, a varchar(20), b char(200)) engine=innodb row_format=compressed encrypted=yes;
|
||||
create table innodb_compressed2(c1 bigint not null primary key, d int, a varchar(20), b char(200)) engine=innodb row_format=compressed key_block_size=1 encrypted=yes;
|
||||
create table innodb_compressed3(c1 bigint not null primary key, d int, a varchar(20), b char(200)) engine=innodb row_format=compressed key_block_size=2 encrypted=yes;
|
||||
create table innodb_compressed4(c1 bigint not null primary key, d int, a varchar(20), b char(200)) engine=innodb row_format=compressed key_block_size=4 encrypted=yes;
|
||||
|
||||
insert into innodb_compressed1 values (1, 20, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (2, 20, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (3, 30, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (4, 30, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (5, 30, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (6, 30, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (7, 30, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (8, 20, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (9, 20, 'private', 'evenmoreprivate');
|
||||
insert into innodb_compressed1 values (10, 20, 'private', 'evenmoreprivate');
|
||||
|
||||
insert into innodb_compressed2 select * from innodb_compressed1;
|
||||
insert into innodb_compressed3 select * from innodb_compressed1;
|
||||
insert into innodb_compressed4 select * from innodb_compressed1;
|
||||
|
||||
--source include/restart_mysqld.inc
|
||||
|
||||
--let $MYSQLD_DATADIR=`select @@datadir`
|
||||
--let t1_IBD = $MYSQLD_DATADIR/test/innodb_compressed1.ibd
|
||||
--let t2_IBD = $MYSQLD_DATADIR/test/innodb_compressed2.ibd
|
||||
--let t3_IBD = $MYSQLD_DATADIR/test/innodb_compressed3.ibd
|
||||
--let t4_IBD = $MYSQLD_DATADIR/test/innodb_compressed4.ibd
|
||||
--let SEARCH_RANGE = 10000000
|
||||
--let SEARCH_PATTERN=private
|
||||
--echo # t1 yes on expecting NOT FOUND
|
||||
-- let SEARCH_FILE=$t1_IBD
|
||||
-- source include/search_pattern_in_file.inc
|
||||
--echo # t2 yes on expecting NOT FOUND
|
||||
-- let SEARCH_FILE=$t2_IBD
|
||||
-- source include/search_pattern_in_file.inc
|
||||
--echo # t3 yes on expecting NOT FOUND
|
||||
-- let SEARCH_FILE=$t3_IBD
|
||||
-- source include/search_pattern_in_file.inc
|
||||
--echo # t4 yes on expecting NOT FOUND
|
||||
-- let SEARCH_FILE=$t4_IBD
|
||||
-- source include/search_pattern_in_file.inc
|
||||
|
||||
SET GLOBAL innodb_file_format = `Barracuda`;
|
||||
SET GLOBAL innodb_file_per_table = ON;
|
||||
|
||||
select * from innodb_compressed1 where d = 20;
|
||||
select * from innodb_compressed1 where d = 30;
|
||||
select * from innodb_compressed2 where d = 20;
|
||||
select * from innodb_compressed2 where d = 30;
|
||||
select * from innodb_compressed3 where d = 20;
|
||||
select * from innodb_compressed3 where d = 30;
|
||||
select * from innodb_compressed4 where d = 20;
|
||||
select * from innodb_compressed4 where d = 30;
|
||||
|
||||
update innodb_compressed1 set d = d + 10 where d = 30;
|
||||
update innodb_compressed2 set d = d + 10 where d = 30;
|
||||
update innodb_compressed3 set d = d + 10 where d = 30;
|
||||
update innodb_compressed4 set d = d + 10 where d = 30;
|
||||
|
||||
insert into innodb_compressed1 values (20, 60, 'newprivate', 'newevenmoreprivate');
|
||||
insert into innodb_compressed2 values (20, 60, 'newprivate', 'newevenmoreprivate');
|
||||
insert into innodb_compressed3 values (20, 60, 'newprivate', 'newevenmoreprivate');
|
||||
insert into innodb_compressed4 values (20, 60, 'newprivate', 'newevenmoreprivate');
|
||||
|
||||
--let SEARCH_PATTERN=private
|
||||
--echo # t1 yes on expecting NOT FOUND
|
||||
-- let SEARCH_FILE=$t1_IBD
|
||||
-- source include/search_pattern_in_file.inc
|
||||
--echo # t2 yes on expecting NOT FOUND
|
||||
-- let SEARCH_FILE=$t2_IBD
|
||||
-- source include/search_pattern_in_file.inc
|
||||
--echo # t3 yes on expecting NOT FOUND
|
||||
-- let SEARCH_FILE=$t3_IBD
|
||||
-- source include/search_pattern_in_file.inc
|
||||
--echo # t4 yes on expecting NOT FOUND
|
||||
-- let SEARCH_FILE=$t4_IBD
|
||||
-- source include/search_pattern_in_file.inc
|
||||
|
||||
--source include/restart_mysqld.inc
|
||||
|
||||
select * from innodb_compressed1 where d = 40;
|
||||
select * from innodb_compressed1 where d = 60;
|
||||
select * from innodb_compressed2 where d = 40;
|
||||
select * from innodb_compressed2 where d = 60;
|
||||
select * from innodb_compressed3 where d = 40;
|
||||
select * from innodb_compressed3 where d = 60;
|
||||
select * from innodb_compressed4 where d = 40;
|
||||
select * from innodb_compressed4 where d = 60;
|
||||
|
||||
--let SEARCH_PATTERN=private
|
||||
--echo # t1 yes on expecting NOT FOUND
|
||||
-- let SEARCH_FILE=$t1_IBD
|
||||
-- source include/search_pattern_in_file.inc
|
||||
--echo # t2 yes on expecting NOT FOUND
|
||||
-- let SEARCH_FILE=$t2_IBD
|
||||
-- source include/search_pattern_in_file.inc
|
||||
--echo # t3 yes on expecting NOT FOUND
|
||||
-- let SEARCH_FILE=$t3_IBD
|
||||
-- source include/search_pattern_in_file.inc
|
||||
--echo # t4 yes on expecting NOT FOUND
|
||||
-- let SEARCH_FILE=$t4_IBD
|
||||
-- source include/search_pattern_in_file.inc
|
||||
|
||||
drop table innodb_compressed1;
|
||||
drop table innodb_compressed2;
|
||||
drop table innodb_compressed3;
|
||||
drop table innodb_compressed4;
|
||||
|
||||
# reset system
|
||||
--disable_query_log
|
||||
EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig;
|
||||
EVAL SET GLOBAL innodb_file_format = $innodb_file_format_orig;
|
||||
--enable_query_log
|
3
mysql-test/suite/encryption/t/innodb_lotoftables.opt
Normal file
3
mysql-test/suite/encryption/t/innodb_lotoftables.opt
Normal file
@@ -0,0 +1,3 @@
|
||||
--innodb-tablespaces-encryption
|
||||
--innodb-encrypt-tables=off
|
||||
--innodb-encryption-threads=0
|
274
mysql-test/suite/encryption/t/innodb_lotoftables.test
Normal file
274
mysql-test/suite/encryption/t/innodb_lotoftables.test
Normal file
@@ -0,0 +1,274 @@
|
||||
-- source include/have_innodb.inc
|
||||
-- source include/have_example_key_management_plugin.inc
|
||||
-- source include/big_test.inc
|
||||
|
||||
# embedded does not support restart
|
||||
-- source include/not_embedded.inc
|
||||
|
||||
--disable_query_log
|
||||
let $innodb_file_format_orig = `SELECT @@innodb_file_format`;
|
||||
let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`;
|
||||
let $innodb_encryption_threads_orig = `SELECT @@global.innodb_encryption_threads`;
|
||||
--enable_query_log
|
||||
|
||||
SET GLOBAL innodb_file_format = `Barracuda`;
|
||||
SET GLOBAL innodb_file_per_table = ON;
|
||||
|
||||
SHOW VARIABLES LIKE 'innodb_encrypt%';
|
||||
|
||||
#
|
||||
# This will create 100 tables where that could be
|
||||
# encrypted an unencrypt
|
||||
#
|
||||
create database innodb_encrypted_1;
|
||||
use innodb_encrypted_1;
|
||||
show status like 'innodb_pages0_read%';
|
||||
set autocommit=0;
|
||||
let $tables = 100;
|
||||
|
||||
--disable_query_log
|
||||
while ($tables)
|
||||
{
|
||||
eval create table t_$tables (a int not null primary key, b varchar(200)) engine=innodb;
|
||||
commit;
|
||||
let $rows = 100;
|
||||
while($rows)
|
||||
{
|
||||
eval insert into t_$tables values ($rows, substring(MD5(RAND()), -64));
|
||||
dec $rows;
|
||||
}
|
||||
commit;
|
||||
dec $tables;
|
||||
}
|
||||
--enable_query_log
|
||||
|
||||
set autocommit=1;
|
||||
commit work;
|
||||
show status like 'innodb_pages0_read%';
|
||||
#
|
||||
# Verify
|
||||
#
|
||||
--echo # should be 100
|
||||
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%';
|
||||
|
||||
#
|
||||
# This will create 100 tables that are encrypted always
|
||||
#
|
||||
create database innodb_encrypted_2;
|
||||
use innodb_encrypted_2;
|
||||
show status like 'innodb_pages0_read%';
|
||||
set autocommit=0;
|
||||
|
||||
--disable_query_log
|
||||
let $tables = 100;
|
||||
while ($tables)
|
||||
{
|
||||
eval create table t_$tables (a int not null primary key, b varchar(200)) engine=innodb encrypted=yes;
|
||||
commit;
|
||||
let $rows = 100;
|
||||
while($rows)
|
||||
{
|
||||
eval insert into t_$tables values ($rows, substring(MD5(RAND()), -64));
|
||||
dec $rows;
|
||||
}
|
||||
commit;
|
||||
dec $tables;
|
||||
}
|
||||
--enable_query_log
|
||||
|
||||
commit work;
|
||||
set autocommit=1;
|
||||
show status like 'innodb_pages0_read%';
|
||||
#
|
||||
# Verify
|
||||
#
|
||||
--echo # should be 100
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
--echo # should be 100
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
|
||||
#
|
||||
# This will create 100 tables that are not encrypted
|
||||
#
|
||||
create database innodb_encrypted_3;
|
||||
use innodb_encrypted_3;
|
||||
show status like 'innodb_pages0_read%';
|
||||
set autocommit=0;
|
||||
|
||||
--disable_query_log
|
||||
let $tables = 100;
|
||||
while ($tables)
|
||||
{
|
||||
eval create table t_$tables (a int not null primary key, b varchar(200)) engine=innodb encrypted=no;
|
||||
commit;
|
||||
let $rows = 100;
|
||||
while($rows)
|
||||
{
|
||||
eval insert into t_$tables values ($rows, substring(MD5(RAND()), -64));
|
||||
dec $rows;
|
||||
}
|
||||
commit;
|
||||
dec $tables;
|
||||
}
|
||||
--enable_query_log
|
||||
|
||||
commit work;
|
||||
set autocommit=1;
|
||||
show status like 'innodb_pages0_read%';
|
||||
#
|
||||
# Verify
|
||||
#
|
||||
--echo # should be 100
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
--echo # should be 200
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
|
||||
use test;
|
||||
show status like 'innodb_pages0_read%';
|
||||
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
|
||||
SET GLOBAL innodb_encrypt_tables = on;
|
||||
SET GLOBAL innodb_encryption_threads=4;
|
||||
|
||||
--echo # Wait until all encrypted tables have been encrypted
|
||||
let $cnt=600;
|
||||
while ($cnt)
|
||||
{
|
||||
let $success=`SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0`;
|
||||
if ($success)
|
||||
{
|
||||
let $cnt=0;
|
||||
}
|
||||
if (!$success)
|
||||
{
|
||||
real_sleep 1;
|
||||
dec $cnt;
|
||||
}
|
||||
}
|
||||
if (!$success)
|
||||
{
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
|
||||
SHOW STATUS LIKE 'innodb_encryption%';
|
||||
-- die Timeout waiting for encryption threads
|
||||
}
|
||||
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
show status like 'innodb_pages0_read%';
|
||||
|
||||
--echo # Success!
|
||||
--echo # Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0
|
||||
-- let $restart_parameters=--innodb_encrypt_tables=0 --innodb_encryption_threads=0
|
||||
-- source include/restart_mysqld.inc
|
||||
|
||||
--echo # Restart Success!
|
||||
show status like 'innodb_pages0_read%';
|
||||
|
||||
show status like 'innodb_pages0_read%';
|
||||
use test;
|
||||
show status like 'innodb_pages0_read%';
|
||||
use innodb_encrypted_1;
|
||||
show status like 'innodb_pages0_read%';
|
||||
use innodb_encrypted_2;
|
||||
show status like 'innodb_pages0_read%';
|
||||
use innodb_encrypted_3;
|
||||
show status like 'innodb_pages0_read%';
|
||||
|
||||
use innodb_encrypted_1;
|
||||
show status like 'innodb_pages0_read%';
|
||||
--disable_result_log
|
||||
--disable_query_log
|
||||
let $tables = 100;
|
||||
while ($tables)
|
||||
{
|
||||
eval select * from t_$tables;
|
||||
dec $tables;
|
||||
}
|
||||
--enable_query_log
|
||||
--enable_result_log
|
||||
|
||||
show status like 'innodb_pages0_read%';
|
||||
|
||||
use innodb_encrypted_2;
|
||||
show status like 'innodb_pages0_read%';
|
||||
|
||||
--disable_result_log
|
||||
--disable_query_log
|
||||
let $tables = 100;
|
||||
while ($tables)
|
||||
{
|
||||
eval select * from t_$tables;
|
||||
dec $tables;
|
||||
}
|
||||
--enable_query_log
|
||||
--enable_result_log
|
||||
|
||||
show status like 'innodb_pages0_read%';
|
||||
|
||||
use innodb_encrypted_3;
|
||||
show status like 'innodb_pages0_read%';
|
||||
--disable_result_log
|
||||
--disable_query_log
|
||||
let $tables = 100;
|
||||
while ($tables)
|
||||
{
|
||||
eval select * from t_$tables;
|
||||
dec $tables;
|
||||
}
|
||||
--enable_query_log
|
||||
--enable_result_log
|
||||
|
||||
show status like 'innodb_pages0_read%';
|
||||
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
|
||||
SET GLOBAL innodb_encrypt_tables = off;
|
||||
SET GLOBAL innodb_encryption_threads=4;
|
||||
|
||||
--echo # Wait until all default encrypted tables have been decrypted
|
||||
let $cnt=600;
|
||||
while ($cnt)
|
||||
{
|
||||
let $success=`SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0`;
|
||||
if ($success)
|
||||
{
|
||||
let $cnt=0;
|
||||
}
|
||||
if (!$success)
|
||||
{
|
||||
real_sleep 1;
|
||||
dec $cnt;
|
||||
}
|
||||
}
|
||||
if (!$success)
|
||||
{
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
|
||||
SHOW STATUS LIKE 'innodb_encryption%';
|
||||
-- die Timeout waiting for encryption threads
|
||||
}
|
||||
|
||||
--echo # should be 100
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
--echo # should be 200
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%';
|
||||
show status like 'innodb_pages0_read%';
|
||||
|
||||
#
|
||||
# Cleanup
|
||||
#
|
||||
use test;
|
||||
drop database innodb_encrypted_1;
|
||||
drop database innodb_encrypted_2;
|
||||
drop database innodb_encrypted_3;
|
||||
|
||||
--disable_query_log
|
||||
EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig;
|
||||
EVAL SET GLOBAL innodb_file_format = $innodb_file_format_orig;
|
||||
EVAL SET GLOBAL innodb_encryption_threads = $innodb_encryption_threads_orig;
|
||||
--enable_query_log
|
Reference in New Issue
Block a user