diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2017-03-14 12:56:01 +0200 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2017-03-14 16:23:10 +0200 |
commit | 50eb40a2a8aa3af6cc271f6028f4d6d74301d030 (patch) | |
tree | dd194385ba0e8fc0302d17c7a682d3ae3d65b19f /storage/xtradb/lock | |
parent | a2f34809e55c492af9a23d43840133f01528df7b (diff) | |
download | mariadb-git-50eb40a2a8aa3af6cc271f6028f4d6d74301d030.tar.gz |
MDEV-11738: Mariadb uses 100% of several of my 8 cpus doing nothing
MDEV-11581: Mariadb starts InnoDB encryption threads
when key has not changed or data scrubbing turned off
Background: Key rotation is based on background threads
(innodb-encryption-threads) periodically going through
all tablespaces on fil_system. For each tablespace
current used key version is compared to max key age
(innodb-encryption-rotate-key-age). This process
naturally takes CPU. Similarly, in same time need for
scrubbing is investigated. Currently, key rotation
is fully supported on Amazon AWS key management plugin
only but InnoDB does not have knowledge what key
management plugin is used.
This patch re-purposes innodb-encryption-rotate-key-age=0
to disable key rotation and background data scrubbing.
All new tables are added to special list for key rotation
and key rotation is based on sending a event to
background encryption threads instead of using periodic
checking (i.e. timeout).
fil0fil.cc: Added functions fil_space_acquire_low()
to acquire a tablespace when it could be dropped concurrently.
This function is used from fil_space_acquire() or
fil_space_acquire_silent() that will not print
any messages if we try to acquire space that does not exist.
fil_space_release() to release a acquired tablespace.
fil_space_next() to iterate tablespaces in fil_system
using fil_space_acquire() and fil_space_release().
Similarly, fil_space_keyrotation_next() to iterate new
list fil_system->rotation_list where new tables.
are added if key rotation is disabled.
Removed unnecessary functions fil_get_first_space_safe()
fil_get_next_space_safe()
fil_node_open_file(): After page 0 is read read also
crypt_info if it is not yet read.
btr_scrub_lock_dict_func()
buf_page_check_corrupt()
buf_page_encrypt_before_write()
buf_merge_or_delete_for_page()
lock_print_info_all_transactions()
row_fts_psort_info_init()
row_truncate_table_for_mysql()
row_drop_table_for_mysql()
Use fil_space_acquire()/release() to access fil_space_t.
buf_page_decrypt_after_read():
Use fil_space_get_crypt_data() because at this point
we might not yet have read page 0.
fil0crypt.cc/fil0fil.h: Lot of changes. Pass fil_space_t* directly
to functions needing it and store fil_space_t* to rotation state.
Use fil_space_acquire()/release() when iterating tablespaces
and removed unnecessary is_closing from fil_crypt_t. Use
fil_space_t::is_stopping() to detect when access to
tablespace should be stopped. Removed unnecessary
fil_space_get_crypt_data().
fil_space_create(): Inform key rotation that there could
be something to do if key rotation is disabled and new
table with encryption enabled is created.
Remove unnecessary functions fil_get_first_space_safe()
and fil_get_next_space_safe(). fil_space_acquire()
and fil_space_release() are used instead. Moved
fil_space_get_crypt_data() and fil_space_set_crypt_data()
to fil0crypt.cc.
fsp_header_init(): Acquire fil_space_t*, write crypt_data
and release space.
check_table_options()
Renamed FIL_SPACE_ENCRYPTION_* TO FIL_ENCRYPTION_*
i_s.cc: Added ROTATING_OR_FLUSHING field to
information_schema.innodb_tablespace_encryption
to show current status of key rotation.
Diffstat (limited to 'storage/xtradb/lock')
-rw-r--r-- | storage/xtradb/lock/lock0lock.cc | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc index 163c5d9dc88..0d555ed2dd7 100644 --- a/storage/xtradb/lock/lock0lock.cc +++ b/storage/xtradb/lock/lock0lock.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2014, 2015, MariaDB Corporation +Copyright (c) 2014, 2017, 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 @@ -6450,12 +6450,13 @@ loop: if (lock_get_type_low(lock) == LOCK_REC) { if (load_page_first) { - ulint space = lock->un_member.rec_lock.space; - ulint zip_size= fil_space_get_zip_size(space); + ulint space_id = lock->un_member.rec_lock.space; + /* Check if the space is exists or not. only + when the space is valid, try to get the page. */ + fil_space_t* space = fil_space_acquire(space_id); ulint page_no = lock->un_member.rec_lock.page_no; - ibool tablespace_being_deleted = FALSE; - if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) { + if (!space) { /* It is a single table tablespace and the .ibd file is missing (TRUNCATE @@ -6464,11 +6465,13 @@ loop: load the page in the buffer pool. */ fprintf(file, "RECORD LOCKS on" - " non-existing space %lu\n", - (ulong) space); + " non-existing space: " ULINTPF "\n", + space_id); goto print_rec; } + const ulint zip_size = fsp_flags_get_zip_size(space->flags); + lock_mutex_exit(); mutex_exit(&trx_sys->mutex); @@ -6476,15 +6479,10 @@ loop: DEBUG_SYNC_C("innodb_monitor_before_lock_page_read"); - /* Check if the space is exists or not. only - when the space is valid, try to get the page. */ - tablespace_being_deleted - = fil_inc_pending_ops(space, false); - - if (!tablespace_being_deleted) { + if (space) { mtr_start(&mtr); - buf_page_get_gen(space, zip_size, + buf_page_get_gen(space_id, zip_size, page_no, RW_NO_LATCH, NULL, BUF_GET_POSSIBLY_FREED, @@ -6493,14 +6491,11 @@ loop: mtr_commit(&mtr); - fil_decr_pending_ops(space); - } else { - fprintf(file, "RECORD LOCKS on" - " non-existing space %lu\n", - (ulong) space); } } + fil_space_release(space); + load_page_first = FALSE; lock_mutex_enter(); @@ -6929,7 +6924,7 @@ static void lock_rec_block_validate( /*====================*/ - ulint space, + ulint space_id, ulint page_no) { /* The lock and the block that it is referring to may be freed at @@ -6942,10 +6937,11 @@ lock_rec_block_validate( /* Make sure that the tablespace is not deleted while we are trying to access the page. */ - if (!fil_inc_pending_ops(space, true)) { + if (fil_space_t* space = fil_space_acquire(space_id)) { + mtr_start(&mtr); block = buf_page_get_gen( - space, fil_space_get_zip_size(space), + space_id, fsp_flags_get_zip_size(space->flags), page_no, RW_X_LATCH, NULL, BUF_GET_POSSIBLY_FREED, __FILE__, __LINE__, &mtr); @@ -6955,7 +6951,7 @@ lock_rec_block_validate( ut_ad(lock_rec_validate_page(block)); mtr_commit(&mtr); - fil_decr_pending_ops(space); + fil_space_release(space); } } |