summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-03-22 11:26:38 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2018-03-22 18:01:29 +0200
commit2fb31821deb98d4324b1555ff5ede21feba77f6c (patch)
tree8d0ab0e53ed6647d717a45997335eb62c36277ba
parentb98d80eb84f9b2e433314fa60c2d3c5b968e580d (diff)
downloadmariadb-git-2fb31821deb98d4324b1555ff5ede21feba77f6c.tar.gz
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.
-rw-r--r--mysql-test/suite/encryption/r/encrypt_and_grep.result12
-rw-r--r--mysql-test/suite/encryption/r/innodb-spatial-index.result4
-rw-r--r--mysql-test/suite/encryption/r/innodb_encryption.result40
-rw-r--r--mysql-test/suite/encryption/t/encrypt_and_grep.test6
-rw-r--r--mysql-test/suite/encryption/t/innodb-spatial-index.test2
-rw-r--r--mysql-test/suite/encryption/t/innodb_encryption.test40
-rw-r--r--storage/innobase/handler/i_s.cc161
7 files changed, 97 insertions, 168 deletions
diff --git a/mysql-test/suite/encryption/r/encrypt_and_grep.result b/mysql-test/suite/encryption/r/encrypt_and_grep.result
index 38dc11e7850..7068d1d3502 100644
--- a/mysql-test/suite/encryption/r/encrypt_and_grep.result
+++ b/mysql-test/suite/encryption/r/encrypt_and_grep.result
@@ -14,11 +14,11 @@ NAME
test/t3
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
-mysql/innodb_table_stats
+innodb_system
mysql/innodb_index_stats
+mysql/innodb_table_stats
test/t1
test/t2
-innodb_system
# t1 yes on expecting NOT FOUND
NOT FOUND /foobarsecret/ in t1.ibd
# t2 ... on expecting NOT FOUND
@@ -32,11 +32,11 @@ 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
-mysql/innodb_table_stats
+innodb_system
mysql/innodb_index_stats
+mysql/innodb_table_stats
test/t2
test/t3
-innodb_system
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
test/t1
@@ -56,11 +56,11 @@ NAME
test/t3
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
NAME
-mysql/innodb_table_stats
+innodb_system
mysql/innodb_index_stats
+mysql/innodb_table_stats
test/t1
test/t2
-innodb_system
# t1 yes on expecting NOT FOUND
NOT FOUND /foobarsecret/ in t1.ibd
# t2 ... on expecting NOT FOUND
diff --git a/mysql-test/suite/encryption/r/innodb-spatial-index.result b/mysql-test/suite/encryption/r/innodb-spatial-index.result
index d8f76988f9e..6856d1eecc9 100644
--- a/mysql-test/suite/encryption/r/innodb-spatial-index.result
+++ b/mysql-test/suite/encryption/r/innodb-spatial-index.result
@@ -36,11 +36,11 @@ INSERT INTO t2 values(1, 'secret', ST_GeomFromText('POINT(903994614 180726515)')
# Success!
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION > 0;
NAME
-mysql/innodb_table_stats
+innodb_system
mysql/innodb_index_stats
+mysql/innodb_table_stats
test/t1
test/t2
-innodb_system
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
NAME
DROP TABLE t1, t2;
diff --git a/mysql-test/suite/encryption/r/innodb_encryption.result b/mysql-test/suite/encryption/r/innodb_encryption.result
index 72f2632ba26..7b7601a289c 100644
--- a/mysql-test/suite/encryption/r/innodb_encryption.result
+++ b/mysql-test/suite/encryption/r/innodb_encryption.result
@@ -8,23 +8,23 @@ innodb_encryption_rotation_iops 100
innodb_encryption_threads 4
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;
+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
-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
-mysql/innodb_table_stats
-mysql/innodb_index_stats
innodb_system
# Success!
# Now turn off encryption and wait for threads to decrypt everything
SET GLOBAL innodb_encrypt_tables = off;
# 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
-mysql/innodb_table_stats
-mysql/innodb_index_stats
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
# Success!
# Shutdown innodb_encryption_threads
@@ -33,23 +33,23 @@ SET GLOBAL innodb_encryption_threads=0;
# since threads are off tables should remain unencrypted
SET GLOBAL innodb_encrypt_tables = on;
# 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
-mysql/innodb_table_stats
-mysql/innodb_index_stats
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
# Success!
# Startup innodb_encryption_threads
SET GLOBAL innodb_encryption_threads=@start_global_value;
# 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
-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
-mysql/innodb_table_stats
-mysql/innodb_index_stats
innodb_system
# Success!
# Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0
@@ -60,10 +60,10 @@ innodb_encrypt_tables OFF
innodb_encryption_rotate_key_age 15
innodb_encryption_rotation_iops 100
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
-mysql/innodb_table_stats
-mysql/innodb_index_stats
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
diff --git a/mysql-test/suite/encryption/t/encrypt_and_grep.test b/mysql-test/suite/encryption/t/encrypt_and_grep.test
index f7916843b89..eb587d7ea12 100644
--- a/mysql-test/suite/encryption/t/encrypt_and_grep.test
+++ b/mysql-test/suite/encryption/t/encrypt_and_grep.test
@@ -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
--source include/wait_condition.inc
+--sorted_result
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;
--source include/shutdown_mysqld.inc
@@ -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;
--source include/wait_condition.inc
+--sorted_result
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;
--source include/shutdown_mysqld.inc
@@ -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;
--source include/wait_condition.inc
+--sorted_result
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;
--source include/shutdown_mysqld.inc
diff --git a/mysql-test/suite/encryption/t/innodb-spatial-index.test b/mysql-test/suite/encryption/t/innodb-spatial-index.test
index 8eb6a803765..28b35379a6b 100644
--- a/mysql-test/suite/encryption/t/innodb-spatial-index.test
+++ b/mysql-test/suite/encryption/t/innodb-spatial-index.test
@@ -69,7 +69,9 @@ INSERT INTO t2 values(1, 'secret', ST_GeomFromText('POINT(903994614 180726515)')
--echo # Success!
+--sorted_result
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;
DROP TABLE t1, t2;
diff --git a/mysql-test/suite/encryption/t/innodb_encryption.test b/mysql-test/suite/encryption/t/innodb_encryption.test
index d183a2914bd..cd844af0649 100644
--- a/mysql-test/suite/encryption/t/innodb_encryption.test
+++ b/mysql-test/suite/encryption/t/innodb_encryption.test
@@ -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;
--source include/wait_condition.inc
-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
+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!
@@ -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;
--source include/wait_condition.inc
-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
+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!
@@ -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;
--source include/wait_condition.inc
-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
+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!
@@ -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;
--source include/wait_condition.inc
-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
+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 # 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_
SHOW VARIABLES LIKE 'innodb_encrypt%';
-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
+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';
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index 7615dba9a0e..a7b678230ee 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
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
the terms of the GNU General Public License as published by the Free Software
@@ -8658,12 +8658,6 @@ i_s_tablespaces_encryption_fill_table(
TABLE_LIST* tables, /*!< in/out: tables to fill */
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");
RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
@@ -8672,68 +8666,24 @@ i_s_tablespaces_encryption_fill_table(
DBUG_RETURN(0);
}
- heap = mem_heap_create(1000);
- mutex_enter(&dict_sys->mutex);
- mtr_start(&mtr);
-
- rec = dict_startscan_system(&pcur, &mtr, SYS_TABLESPACES);
-
- while (rec) {
- const char* err_msg;
- ulint space_id;
- const char* name;
- ulint flags;
-
- /* Extract necessary information from a SYS_TABLESPACES row */
- err_msg = dict_process_sys_tablespaces(
- 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);
+ mutex_enter(&fil_system->mutex);
+
+ for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system->space_list);
+ space; space = UT_LIST_GET_NEXT(space_list, space)) {
+ if (space->purpose == FIL_TYPE_TABLESPACE) {
+ space->n_pending_ops++;
+ mutex_exit(&fil_system->mutex);
+ if (int err = i_s_dict_fill_tablespaces_encryption(
+ thd, space, tables->table)) {
+ fil_space_release(space);
+ DBUG_RETURN(err);
+ }
+ mutex_enter(&fil_system->mutex);
+ space->n_pending_ops--;
}
-
- 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);
}
/*******************************************************************//**
@@ -8979,12 +8929,6 @@ i_s_tablespaces_scrubbing_fill_table(
TABLE_LIST* tables, /*!< in/out: tables to fill */
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");
RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
@@ -8993,67 +8937,24 @@ i_s_tablespaces_scrubbing_fill_table(
DBUG_RETURN(0);
}
- heap = mem_heap_create(1000);
- mutex_enter(&dict_sys->mutex);
- mtr_start(&mtr);
-
- rec = dict_startscan_system(&pcur, &mtr, SYS_TABLESPACES);
-
- while (rec) {
- const char* err_msg;
- ulint space_id;
- const char* name;
- ulint flags;
-
- /* Extract necessary information from a SYS_TABLESPACES row */
- err_msg = dict_process_sys_tablespaces(
- 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);
+ mutex_enter(&fil_system->mutex);
+
+ for (fil_space_t* space = UT_LIST_GET_FIRST(fil_system->space_list);
+ space; space = UT_LIST_GET_NEXT(space_list, space)) {
+ if (space->purpose == FIL_TYPE_TABLESPACE) {
+ space->n_pending_ops++;
+ mutex_exit(&fil_system->mutex);
+ if (int err = i_s_dict_fill_tablespaces_scrubbing(
+ thd, space, tables->table)) {
+ fil_space_release(space);
+ DBUG_RETURN(err);
+ }
+ mutex_enter(&fil_system->mutex);
+ space->n_pending_ops--;
}
-
- 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);
}
/*******************************************************************//**