diff --git a/mysql-test/suite/encryption/r/innodb-redo-badkey.result b/mysql-test/suite/encryption/r/innodb-redo-badkey.result index e12dad6d0d7..9eba53622e8 100644 --- a/mysql-test/suite/encryption/r/innodb-redo-badkey.result +++ b/mysql-test/suite/encryption/r/innodb-redo-badkey.result @@ -1,17 +1,8 @@ -call mtr.add_suppression("InnoDB: Block in space_id .* in file .* encrypted."); -call mtr.add_suppression("Plugin 'file_key_management' .*"); +call mtr.add_suppression("Plugin 'file_key_management'"); call mtr.add_suppression("Plugin 'InnoDB' init function returned error."); -call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed."); -call mtr.add_suppression("InnoDB: Read operation failed for tablespace .*"); -call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed.*"); -call mtr.add_suppression("InnoDB: Recovery read page .*"); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t2 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t3 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t4 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); -call mtr.add_suppression("InnoDB: Missing MLOG_FILE_NAME or MLOG_FILE_DELETE .*"); -call mtr.add_suppression("InnoDB: Plugin initialization aborted .*"); -call mtr.add_suppression("InnoDB: ############### CORRUPT LOG RECORD FOUND ##################"); +call mtr.add_suppression("InnoDB: The page \[page id: space=[1-9][0-9]*, page number=[0-9]+\] in file test/t[1-4] cannot be decrypted"); +call mtr.add_suppression("InnoDB: Plugin initialization aborted"); +call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed"); # Restart mysqld --file-key-management-filename=keys2.txt # Wait max 10 min for key encryption threads to encrypt all spaces SET GLOBAL innodb_file_format = `Barracuda`; diff --git a/mysql-test/suite/encryption/t/innodb-redo-badkey.test b/mysql-test/suite/encryption/t/innodb-redo-badkey.test index 159646541c7..15cccf29fe1 100644 --- a/mysql-test/suite/encryption/t/innodb-redo-badkey.test +++ b/mysql-test/suite/encryption/t/innodb-redo-badkey.test @@ -3,20 +3,11 @@ # embedded does not support restart -- source include/not_embedded.inc -call mtr.add_suppression("InnoDB: Block in space_id .* in file .* encrypted."); -call mtr.add_suppression("Plugin 'file_key_management' .*"); +call mtr.add_suppression("Plugin 'file_key_management'"); call mtr.add_suppression("Plugin 'InnoDB' init function returned error."); -call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed."); -call mtr.add_suppression("InnoDB: Read operation failed for tablespace .*"); -call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed.*"); -call mtr.add_suppression("InnoDB: Recovery read page .*"); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t2 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t3 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t4 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); -call mtr.add_suppression("InnoDB: Missing MLOG_FILE_NAME or MLOG_FILE_DELETE .*"); -call mtr.add_suppression("InnoDB: Plugin initialization aborted .*"); -call mtr.add_suppression("InnoDB: ############### CORRUPT LOG RECORD FOUND ##################"); +call mtr.add_suppression("InnoDB: The page \[page id: space=[1-9][0-9]*, page number=[0-9]+\] in file test/t[1-4] cannot be decrypted"); +call mtr.add_suppression("InnoDB: Plugin initialization aborted"); +call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed"); --echo # Restart mysqld --file-key-management-filename=keys2.txt -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index fef05a7ebfc..c458da8c1c0 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -1004,7 +1004,8 @@ fil_crypt_start_encrypting_space( do { mtr_t mtr; - mtr_start(&mtr); + mtr.start(); + mtr.set_named_space(space); /* 2 - get page 0 */ dberr_t err = DB_SUCCESS; @@ -1020,7 +1021,7 @@ fil_crypt_start_encrypting_space( crypt_data->type = CRYPT_SCHEME_1; crypt_data->write_page0(space, frame, &mtr); - mtr_commit(&mtr); + mtr.commit(); /* record lsn of update */ lsn_t end_lsn = mtr.commit_lsn(); @@ -1758,12 +1759,11 @@ fil_crypt_rotate_page( } mtr_t mtr; - mtr_start(&mtr); - buf_block_t* block = fil_crypt_get_page_throttle(state, - offset, &mtr, - &sleeptime_ms); - - if (block) { + mtr.start(); + if (buf_block_t* block = fil_crypt_get_page_throttle(state, + offset, &mtr, + &sleeptime_ms)) { + mtr.set_named_space(space); bool modified = false; int needs_scrubbing = BTR_SCRUB_SKIP_PAGE; @@ -1804,11 +1804,11 @@ fil_crypt_rotate_page( BTR_SCRUB_PAGE_ALLOCATION_UNKNOWN); } - mtr_commit(&mtr); + mtr.commit(); lsn_t end_lsn = mtr.commit_lsn(); if (needs_scrubbing == BTR_SCRUB_PAGE) { - mtr_start(&mtr); + mtr.start(); /* * refetch page and allocation status */ @@ -1820,6 +1820,7 @@ fil_crypt_rotate_page( &sleeptime_ms); if (block) { + mtr.set_named_space(space); /* get required table/index and index-locks */ needs_scrubbing = btr_scrub_recheck_page( @@ -1981,6 +1982,7 @@ fil_crypt_flush_space( page_id_t(space->id, 0), page_size_t(space->flags), RW_X_LATCH, NULL, BUF_GET, __FILE__, __LINE__, &mtr, &err)) { + mtr.set_named_space(space); crypt_data->write_page0(space, block->frame, &mtr); } diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index d44b8c164c2..61a5f9ddcb4 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -4773,7 +4773,7 @@ fsp_flags_try_adjust(ulint space_id, ulint flags) ut_ad(fsp_flags_is_valid(flags)); mtr_t mtr; - mtr_start(&mtr); + mtr.start(); if (buf_block_t* b = buf_page_get( page_id_t(space_id, 0), page_size_t(flags), RW_X_LATCH, &mtr)) { @@ -4787,12 +4787,13 @@ fsp_flags_try_adjust(ulint space_id, ulint flags) << " to " << ib::hex(flags); } if (f != flags) { + mtr.set_named_space(space_id); mlog_write_ulint(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + b->frame, flags, MLOG_4BYTES, &mtr); } } - mtr_commit(&mtr); + mtr.commit(); } /** Determine if a matching tablespace exists in the InnoDB tablespace diff --git a/storage/innobase/include/mtr0log.ic b/storage/innobase/include/mtr0log.ic index 972fdc81518..dd68ea25613 100644 --- a/storage/innobase/include/mtr0log.ic +++ b/storage/innobase/include/mtr0log.ic @@ -76,10 +76,10 @@ mlog_catenate_ulint( ulint val, /*!< in: value to write */ mlog_id_t type) /*!< in: type of value to write */ { - ut_ad(MLOG_1BYTE == 1); - ut_ad(MLOG_2BYTES == 2); - ut_ad(MLOG_4BYTES == 4); - ut_ad(MLOG_8BYTES == 8); + compile_time_assert(MLOG_1BYTE == 1); + compile_time_assert(MLOG_2BYTES == 2); + compile_time_assert(MLOG_4BYTES == 4); + compile_time_assert(MLOG_8BYTES == 8); byte* ptr = mtr_buf->push(type); @@ -182,6 +182,14 @@ mlog_write_initial_log_record_low( mtr_t* mtr) { ut_ad(type <= MLOG_BIGGEST_TYPE || EXTRA_CHECK_MLOG_NUMBER(type)); + ut_ad(type == MLOG_FILE_NAME + || type == MLOG_FILE_DELETE + || type == MLOG_FILE_CREATE2 + || type == MLOG_FILE_RENAME2 + || type == MLOG_INDEX_LOAD + || type == MLOG_TRUNCATE + || type == MLOG_FILE_WRITE_CRYPT_DATA + || mtr->is_named_space(space_id)); mach_write_to_1(log_ptr, type); log_ptr++;