Commit 2fb31821 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-11984 Avoid accessing SYS_TABLESPACES unnecessarily

The following INFORMATION_SCHEMA views were unnecessarily retrieving
the data from the SYS_TABLESPACES table instead of directly fetching
it from the fil_system cache:

information_schema.innodb_tablespaces_encryption
information_schema.innodb_tablespaces_scrubbing

InnoDB always loads all tablespace metadata into memory at startup
and never evicts it while the tablespace exists.

With this fix, accessing these views will be much faster and use less
memory, and include data about all tablespaces, including undo
tablespaces.

The view information_schema.innodb_sys_tablespaces will still reflect
the contents of the SYS_TABLESPACES table.
parent b98d80eb
...@@ -14,11 +14,11 @@ NAME ...@@ -14,11 +14,11 @@ NAME
test/t3 test/t3
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME NAME
mysql/innodb_table_stats innodb_system
mysql/innodb_index_stats mysql/innodb_index_stats
mysql/innodb_table_stats
test/t1 test/t1
test/t2 test/t2
innodb_system
# t1 yes on expecting NOT FOUND # t1 yes on expecting NOT FOUND
NOT FOUND /foobarsecret/ in t1.ibd NOT FOUND /foobarsecret/ in t1.ibd
# t2 ... on expecting NOT FOUND # t2 ... on expecting NOT FOUND
...@@ -32,11 +32,11 @@ SET GLOBAL innodb_encrypt_tables = off; ...@@ -32,11 +32,11 @@ SET GLOBAL innodb_encrypt_tables = off;
# Wait max 10 min for key encryption threads to decrypt all spaces # 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; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
NAME NAME
mysql/innodb_table_stats innodb_system
mysql/innodb_index_stats mysql/innodb_index_stats
mysql/innodb_table_stats
test/t2 test/t2
test/t3 test/t3
innodb_system
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME NAME
test/t1 test/t1
...@@ -56,11 +56,11 @@ NAME ...@@ -56,11 +56,11 @@ NAME
test/t3 test/t3
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME NAME
mysql/innodb_table_stats innodb_system
mysql/innodb_index_stats mysql/innodb_index_stats
mysql/innodb_table_stats
test/t1 test/t1
test/t2 test/t2
innodb_system
# t1 yes on expecting NOT FOUND # t1 yes on expecting NOT FOUND
NOT FOUND /foobarsecret/ in t1.ibd NOT FOUND /foobarsecret/ in t1.ibd
# t2 ... on expecting NOT FOUND # t2 ... on expecting NOT FOUND
......
...@@ -36,11 +36,11 @@ INSERT INTO t2 values(1, 'secret', ST_GeomFromText('POINT(903994614 180726515)') ...@@ -36,11 +36,11 @@ INSERT INTO t2 values(1, 'secret', ST_GeomFromText('POINT(903994614 180726515)')
# Success! # Success!
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION > 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION > 0;
NAME NAME
mysql/innodb_table_stats innodb_system
mysql/innodb_index_stats mysql/innodb_index_stats
mysql/innodb_table_stats
test/t1 test/t1
test/t2 test/t2
innodb_system
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
NAME NAME
DROP TABLE t1, t2; DROP TABLE t1, t2;
...@@ -8,23 +8,23 @@ innodb_encryption_rotation_iops 100 ...@@ -8,23 +8,23 @@ innodb_encryption_rotation_iops 100
innodb_encryption_threads 4 innodb_encryption_threads 4
SET GLOBAL innodb_encrypt_tables = ON; SET GLOBAL innodb_encrypt_tables = ON;
# Wait max 10 min for key encryption threads to encrypt all spaces # 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; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
NAME NAME
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
NAME NAME
mysql/innodb_table_stats
mysql/innodb_index_stats
innodb_system innodb_system
# Success! # Success!
# Now turn off encryption and wait for threads to decrypt everything # Now turn off encryption and wait for threads to decrypt everything
SET GLOBAL innodb_encrypt_tables = off; SET GLOBAL innodb_encrypt_tables = off;
# Wait max 10 min for key encryption threads to encrypt all spaces # 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; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
NAME NAME
mysql/innodb_table_stats
mysql/innodb_index_stats
innodb_system innodb_system
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
NAME NAME
# Success! # Success!
# Shutdown innodb_encryption_threads # Shutdown innodb_encryption_threads
...@@ -33,23 +33,23 @@ SET GLOBAL innodb_encryption_threads=0; ...@@ -33,23 +33,23 @@ SET GLOBAL innodb_encryption_threads=0;
# since threads are off tables should remain unencrypted # since threads are off tables should remain unencrypted
SET GLOBAL innodb_encrypt_tables = on; SET GLOBAL innodb_encrypt_tables = on;
# Wait 15s to check that nothing gets encrypted # Wait 15s to check that nothing gets encrypted
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
NAME NAME
mysql/innodb_table_stats
mysql/innodb_index_stats
innodb_system innodb_system
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
NAME NAME
# Success! # Success!
# Startup innodb_encryption_threads # Startup innodb_encryption_threads
SET GLOBAL innodb_encryption_threads=@start_global_value; SET GLOBAL innodb_encryption_threads=@start_global_value;
# Wait max 10 min for key encryption threads to encrypt all spaces # 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; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
NAME NAME
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
NAME NAME
mysql/innodb_table_stats
mysql/innodb_index_stats
innodb_system innodb_system
# Success! # Success!
# Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0 # Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0
...@@ -60,10 +60,10 @@ innodb_encrypt_tables OFF ...@@ -60,10 +60,10 @@ innodb_encrypt_tables OFF
innodb_encryption_rotate_key_age 15 innodb_encryption_rotate_key_age 15
innodb_encryption_rotation_iops 100 innodb_encryption_rotation_iops 100
innodb_encryption_threads 0 innodb_encryption_threads 0
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
NAME NAME
mysql/innodb_table_stats
mysql/innodb_index_stats
innodb_system innodb_system
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
NAME NAME
...@@ -33,7 +33,9 @@ insert t3 values (repeat('dummysecret', 12)); ...@@ -33,7 +33,9 @@ insert t3 values (repeat('dummysecret', 12));
--let $wait_condition=SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 --let $wait_condition=SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0
--source include/wait_condition.inc --source include/wait_condition.inc
--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/shutdown_mysqld.inc --source include/shutdown_mysqld.inc
...@@ -67,7 +69,9 @@ SET GLOBAL innodb_encrypt_tables = off; ...@@ -67,7 +69,9 @@ SET GLOBAL innodb_encrypt_tables = off;
--let $wait_condition=SELECT COUNT(*) = $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND CURRENT_KEY_VERSION = 0; --let $wait_condition=SELECT COUNT(*) = $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND CURRENT_KEY_VERSION = 0;
--source include/wait_condition.inc --source include/wait_condition.inc
--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/shutdown_mysqld.inc --source include/shutdown_mysqld.inc
...@@ -100,7 +104,9 @@ SET GLOBAL innodb_encrypt_tables = on; ...@@ -100,7 +104,9 @@ SET GLOBAL innodb_encrypt_tables = on;
--let $wait_condition=SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; --let $wait_condition=SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
--source include/wait_condition.inc --source include/wait_condition.inc
--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/shutdown_mysqld.inc --source include/shutdown_mysqld.inc
......
...@@ -69,7 +69,9 @@ INSERT INTO t2 values(1, 'secret', ST_GeomFromText('POINT(903994614 180726515)') ...@@ -69,7 +69,9 @@ INSERT INTO t2 values(1, 'secret', ST_GeomFromText('POINT(903994614 180726515)')
--echo # Success! --echo # Success!
--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION > 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION > 0;
--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
DROP TABLE t1, t2; DROP TABLE t1, t2;
...@@ -21,8 +21,12 @@ SET GLOBAL innodb_encrypt_tables = ON; ...@@ -21,8 +21,12 @@ SET GLOBAL innodb_encrypt_tables = ON;
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; --let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/wait_condition.inc --source include/wait_condition.inc
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; --sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
--echo # Success! --echo # Success!
...@@ -34,8 +38,12 @@ SET GLOBAL innodb_encrypt_tables = off; ...@@ -34,8 +38,12 @@ SET GLOBAL innodb_encrypt_tables = off;
--let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; --let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/wait_condition.inc --source include/wait_condition.inc
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; --sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
--echo # Success! --echo # Success!
...@@ -51,8 +59,12 @@ SET GLOBAL innodb_encrypt_tables = on; ...@@ -51,8 +59,12 @@ SET GLOBAL innodb_encrypt_tables = on;
--let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; --let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/wait_condition.inc --source include/wait_condition.inc
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; --sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
--echo # Success! --echo # Success!
...@@ -64,8 +76,12 @@ SET GLOBAL innodb_encryption_threads=@start_global_value; ...@@ -64,8 +76,12 @@ SET GLOBAL innodb_encryption_threads=@start_global_value;
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; --let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/wait_condition.inc --source include/wait_condition.inc
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; --sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
--echo # Success! --echo # Success!
--echo # Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0 --echo # Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0
...@@ -74,5 +90,9 @@ SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_ ...@@ -74,5 +90,9 @@ SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_
SHOW VARIABLES LIKE 'innodb_encrypt%'; SHOW VARIABLES LIKE 'innodb_encrypt%';
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; --sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0
AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats';
/***************************************************************************** /*****************************************************************************
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2017, MariaDB Corporation. Copyright (c) 2014, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -8658,12 +8658,6 @@ i_s_tablespaces_encryption_fill_table( ...@@ -8658,12 +8658,6 @@ i_s_tablespaces_encryption_fill_table(
TABLE_LIST* tables, /*!< in/out: tables to fill */ TABLE_LIST* tables, /*!< in/out: tables to fill */
Item* ) /*!< in: condition (not used) */ Item* ) /*!< in: condition (not used) */
{ {
btr_pcur_t pcur;
const rec_t* rec;
mem_heap_t* heap;
mtr_t mtr;
bool found_space_0 = false;
DBUG_ENTER("i_s_tablespaces_encryption_fill_table"); DBUG_ENTER("i_s_tablespaces_encryption_fill_table");
RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name); RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
...@@ -8672,68 +8666,24 @@ i_s_tablespaces_encryption_fill_table( ...@@ -8672,68 +8666,24 @@ i_s_tablespaces_encryption_fill_table(
DBUG_RETURN(0); DBUG_RETURN(0);
} }
heap = mem_heap_create(1000); mutex_enter(&fil_system->mutex);
mutex_enter(&dict_sys->mutex);
mtr_start(&mtr); for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system->space_list);
space; space = UT_LIST_GET_NEXT(space_list, space)) {
rec = dict_startscan_system(&pcur, &mtr, SYS_TABLESPACES); if (space->purpose == FIL_TYPE_TABLESPACE) {
space->n_pending_ops++;
while (rec) { mutex_exit(&fil_system->mutex);
const char* err_msg; if (int err = i_s_dict_fill_tablespaces_encryption(
ulint space_id; thd, space, tables->table)) {
const char* name; fil_space_release(space);
ulint flags; DBUG_RETURN(err);
}
/* Extract necessary information from a SYS_TABLESPACES row */ mutex_enter(&fil_system->mutex);
err_msg = dict_process_sys_tablespaces( space->n_pending_ops--;
heap, rec, &space_id, &name, &flags);
mtr_commit(&mtr);
mutex_exit(&dict_sys->mutex);
if (space_id == 0) {
found_space_0 = true;
}
fil_space_t* space = fil_space_acquire_silent(space_id);
if (!err_msg && space) {
i_s_dict_fill_tablespaces_encryption(
thd, space, tables->table);
} else {
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_CANT_FIND_SYSTEM_REC, "%s",
err_msg);
}
if (space) {
fil_space_release(space);
} }
mem_heap_empty(heap);
/* Get the next record */
mutex_enter(&dict_sys->mutex);
mtr_start(&mtr);
rec = dict_getnext_system(&pcur, &mtr);
}
mtr_commit(&mtr);
mutex_exit(&dict_sys->mutex);
mem_heap_free(heap);
if (found_space_0 == false) {
/* space 0 does for what ever unknown reason not show up
* in iteration above, add it manually */
fil_space_t* space = fil_space_acquire_silent(0);
i_s_dict_fill_tablespaces_encryption(
thd, space, tables->table);
fil_space_release(space);
} }
mutex_exit(&fil_system->mutex);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/*******************************************************************//** /*******************************************************************//**
...@@ -8979,12 +8929,6 @@ i_s_tablespaces_scrubbing_fill_table( ...@@ -8979,12 +8929,6 @@ i_s_tablespaces_scrubbing_fill_table(
TABLE_LIST* tables, /*!< in/out: tables to fill */ TABLE_LIST* tables, /*!< in/out: tables to fill */
Item* ) /*!< in: condition (not used) */ Item* ) /*!< in: condition (not used) */
{ {
btr_pcur_t pcur;
const rec_t* rec;
mem_heap_t* heap;
mtr_t mtr;
bool found_space_0 = false;
DBUG_ENTER("i_s_tablespaces_scrubbing_fill_table"); DBUG_ENTER("i_s_tablespaces_scrubbing_fill_table");
RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name); RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
...@@ -8993,67 +8937,24 @@ i_s_tablespaces_scrubbing_fill_table( ...@@ -8993,67 +8937,24 @@ i_s_tablespaces_scrubbing_fill_table(
DBUG_RETURN(0); DBUG_RETURN(0);
} }
heap = mem_heap_create(1000); mutex_enter(&fil_system->mutex);
mutex_enter(&dict_sys->mutex);
mtr_start(&mtr); for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system->space_list);
space; space = UT_LIST_GET_NEXT(space_list, space)) {
rec = dict_startscan_system(&pcur, &mtr, SYS_TABLESPACES); if (space->purpose == FIL_TYPE_TABLESPACE) {
space->n_pending_ops++;
while (rec) { mutex_exit(&fil_system->mutex);
const char* err_msg; if (int err = i_s_dict_fill_tablespaces_scrubbing(
ulint space_id; thd, space, tables->table)) {
const char* name; fil_space_release(space);
ulint flags; DBUG_RETURN(err);
}
/* Extract necessary information from a SYS_TABLESPACES row */ mutex_enter(&fil_system->mutex);
err_msg = dict_process_sys_tablespaces( space->n_pending_ops--;
heap, rec, &space_id, &name, &flags);
mtr_commit(&mtr);
mutex_exit(&dict_sys->mutex);
if (space_id == 0) {
found_space_0 = true;
}
fil_space_t* space = fil_space_acquire_silent(space_id);
if (!err_msg && space) {
i_s_dict_fill_tablespaces_scrubbing(
thd, space, tables->table);
} else {
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_CANT_FIND_SYSTEM_REC, "%s",
err_msg);
}
if (space) {
fil_space_release(space);
} }
mem_heap_empty(heap);
/* Get the next record */
mutex_enter(&dict_sys->mutex);
mtr_start(&mtr);
rec = dict_getnext_system(&pcur, &mtr);
}
mtr_commit(&mtr);
mutex_exit(&dict_sys->mutex);
mem_heap_free(heap);
if (found_space_0 == false) {
/* space 0 does for what ever unknown reason not show up
* in iteration above, add it manually */
fil_space_t* space = fil_space_acquire_silent(0);
i_s_dict_fill_tablespaces_scrubbing(
thd, space, tables->table);
fil_space_release(space);
} }
mutex_exit(&fil_system->mutex);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/*******************************************************************//** /*******************************************************************//**
......
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