summaryrefslogtreecommitdiff
path: root/storage/innobase/fsp
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@mariadb.com>2017-03-14 12:56:01 +0200
committerJan Lindström <jan.lindstrom@mariadb.com>2017-03-14 16:23:10 +0200
commit50eb40a2a8aa3af6cc271f6028f4d6d74301d030 (patch)
treedd194385ba0e8fc0302d17c7a682d3ae3d65b19f /storage/innobase/fsp
parenta2f34809e55c492af9a23d43840133f01528df7b (diff)
downloadmariadb-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/innobase/fsp')
-rw-r--r--storage/innobase/fsp/fsp0fsp.cc40
1 files changed, 19 insertions, 21 deletions
diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc
index c5289b48ccc..a40283412e2 100644
--- a/storage/innobase/fsp/fsp0fsp.cc
+++ b/storage/innobase/fsp/fsp0fsp.cc
@@ -677,7 +677,7 @@ UNIV_INTERN
void
fsp_header_init(
/*============*/
- ulint space, /*!< in: space id */
+ ulint space_id, /*!< in: space id */
ulint size, /*!< in: current size in blocks */
mtr_t* mtr) /*!< in/out: mini-transaction */
{
@@ -689,11 +689,11 @@ fsp_header_init(
ut_ad(mtr);
- mtr_x_lock(fil_space_get_latch(space, &flags), mtr);
+ mtr_x_lock(fil_space_get_latch(space_id, &flags), mtr);
zip_size = fsp_flags_get_zip_size(flags);
- block = buf_page_create(space, 0, zip_size, mtr);
- buf_page_get(space, zip_size, 0, RW_X_LATCH, mtr);
+ block = buf_page_create(space_id, 0, zip_size, mtr);
+ buf_page_get(space_id, zip_size, 0, RW_X_LATCH, mtr);
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
/* The prior contents of the file page should be ignored */
@@ -706,7 +706,7 @@ fsp_header_init(
header = FSP_HEADER_OFFSET + page;
- mlog_write_ulint(header + FSP_SPACE_ID, space, MLOG_4BYTES, mtr);
+ mlog_write_ulint(header + FSP_SPACE_ID, space_id, MLOG_4BYTES, mtr);
mlog_write_ulint(header + FSP_NOT_USED, 0, MLOG_4BYTES, mtr);
mlog_write_ulint(header + FSP_SIZE, size, MLOG_4BYTES, mtr);
@@ -722,18 +722,23 @@ fsp_header_init(
flst_init(header + FSP_SEG_INODES_FREE, mtr);
mlog_write_ull(header + FSP_SEG_ID, 1, mtr);
- if (space == 0) {
- fsp_fill_free_list(FALSE, space, header, mtr);
+ if (space_id == 0) {
+ fsp_fill_free_list(FALSE, space_id, header, mtr);
btr_create(DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF,
- 0, 0, DICT_IBUF_ID_MIN + space,
+ 0, 0, DICT_IBUF_ID_MIN + space_id,
dict_ind_redundant, mtr);
} else {
- fsp_fill_free_list(TRUE, space, header, mtr);
+ fsp_fill_free_list(TRUE, space_id, header, mtr);
}
- ulint maxsize = 0;
- ulint offset = fsp_header_get_crypt_offset(zip_size, &maxsize);
- fil_space_write_crypt_data(space, page, offset, maxsize, mtr);
+ fil_space_t* space = fil_space_acquire(space_id);
+ ut_ad(space);
+
+ if (space->crypt_data) {
+ space->crypt_data->write_page0(page, mtr);
+ }
+
+ fil_space_release(space);
}
#endif /* !UNIV_HOTBACKUP */
@@ -4123,12 +4128,11 @@ fsp_print(
/**********************************************************************//**
Compute offset after xdes where crypt data can be stored
+@param[in] zip_size Compressed size or 0
@return offset */
ulint
fsp_header_get_crypt_offset(
-/*========================*/
- ulint zip_size, /*!< in: zip_size */
- ulint* max_size) /*!< out: free space available for crypt data */
+ const ulint zip_size)
{
ulint pageno = 0;
/* compute first page_no that will have xdes stored on page != 0*/
@@ -4143,12 +4147,6 @@ fsp_header_get_crypt_offset(
ulint iv_offset = XDES_ARR_OFFSET +
XDES_SIZE * (1 + xdes_calc_descriptor_index(zip_size, pageno));
- if (max_size != NULL) {
- /* return how much free space there is available on page */
- *max_size = (zip_size ? zip_size : UNIV_PAGE_SIZE) -
- (FSP_HEADER_OFFSET + iv_offset + FIL_PAGE_DATA_END);
- }
-
return FSP_HEADER_OFFSET + iv_offset;
}