Skip to content

Commit a24f5cd

Browse files
committed
Merge branch 'mysql-8.0' into mysql-trunk
2 parents 21a84bc + 4a6d2b0 commit a24f5cd

File tree

6 files changed

+154
-12
lines changed

6 files changed

+154
-12
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# bug#30209760 : ASSERTION FAILURE: SRV0START.CC:969:SUCCESS THREAD
3+
#
4+
#########
5+
# SETUP #
6+
#########
7+
# Create path for ibdata* & undo* files
8+
# create bootstrap file
9+
# Stop the MTR default DB server
10+
#########################################################################
11+
# INITIALIZE NEW SERVER
12+
#########################################################################
13+
# Server should be initialized successfully.
14+
#########################################################################
15+
# RESTART 2 : WITH KEYRING PLUGIN.
16+
innodb_undo_log_encrypt=ON.
17+
Crash server before purge thread could start.
18+
#########################################################################
19+
#########################################################################
20+
# RESTART 3 : WITH KEYRING PLUGIN.
21+
innodb_undo_log_encrypt=ON.
22+
Skip rotating default master key in master thread
23+
#########################################################################
24+
#########################################################################
25+
# RESTART 4 : WITH KEYRING PLUGIN.
26+
innodb_undo_log_encrypt=OFF.
27+
#########################################################################
28+
# Shutdown the running server
29+
SHUTDOWN;
30+
###########
31+
# CLEANUP #
32+
###########
33+
# Restart the server with MTR default
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
--echo #
2+
--echo # bug#30209760 : ASSERTION FAILURE: SRV0START.CC:969:SUCCESS THREAD
3+
--echo #
4+
5+
--source include/have_debug.inc
6+
7+
--disable_query_log
8+
call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* [InnoDB] Assertion failure: srv0start.cc");
9+
--enable_query_log
10+
11+
--echo #########
12+
--echo # SETUP #
13+
--echo #########
14+
let $MYSQLD_BASEDIR= `select @@basedir`;
15+
let $START_PAGE_SIZE= `select @@innodb_page_size`;
16+
let $LOG_FILE_SIZE= `select @@innodb_log_file_size`;
17+
18+
--echo # Create path for ibdata* & undo* files
19+
--mkdir $MYSQL_TMP_DIR/innodb_undo_data_dir
20+
--mkdir $MYSQL_TMP_DIR/innodb_data_home_dir
21+
--mkdir $MYSQL_TMP_DIR/datadir
22+
23+
# Set path for --datadir
24+
let $MYSQLD_DATADIR = $MYSQL_TMP_DIR/datadir/data;
25+
26+
# Set path for undo* files.
27+
let $MYSQLD_UNDO_DATADIR = $MYSQL_TMP_DIR/innodb_undo_data_dir;
28+
29+
# Set path for ibdata* files.
30+
let $MYSQLD_HOME_DATA_DIR = $MYSQL_TMP_DIR/innodb_data_home_dir;
31+
32+
--echo # create bootstrap file
33+
let $BOOTSTRAP_SQL=$MYSQL_TMP_DIR/boot.sql;
34+
write_file $BOOTSTRAP_SQL;
35+
CREATE DATABASE test;
36+
EOF
37+
38+
--echo # Stop the MTR default DB server
39+
--source include/shutdown_mysqld.inc
40+
41+
--echo #########################################################################
42+
--echo # INITIALIZE NEW SERVER
43+
--echo #########################################################################
44+
let NEW_CMD = $MYSQLD --no-defaults --innodb_dedicated_server=OFF --initialize-insecure --innodb_log_file_size=$LOG_FILE_SIZE --innodb_page_size=$START_PAGE_SIZE --innodb_data_home_dir=$MYSQLD_HOME_DATA_DIR --innodb_undo_directory=$MYSQLD_UNDO_DATADIR --basedir=$MYSQLD_BASEDIR --datadir=$MYSQLD_DATADIR --init-file=$BOOTSTRAP_SQL --secure-file-priv="";
45+
46+
--echo # Server should be initialized successfully.
47+
--exec $NEW_CMD
48+
49+
--echo #########################################################################
50+
--echo # RESTART 2 : WITH KEYRING PLUGIN.
51+
--echo innodb_undo_log_encrypt=ON.
52+
--echo Crash server before purge thread could start.
53+
--echo #########################################################################
54+
# Restart the server with undo_log_encrypt=ON and make sure it asserts before
55+
# Purge thread is started (i.e. before master thread could have started to
56+
# rotate default master key. At this time,
57+
# - UNDO tablespace would have been encrypted with default master key
58+
# - Header page for UNDO tablespace wouldn't have been flushed
59+
# - So encryption information is still in REDO Log.
60+
let $NEW_CMD = $MYSQLD --innodb_dedicated_server=OFF --innodb_log_file_size=$LOG_FILE_SIZE --innodb_page_size=$START_PAGE_SIZE --innodb_data_home_dir=$MYSQLD_HOME_DATA_DIR --innodb_undo_directory=$MYSQLD_UNDO_DATADIR --basedir=$MYSQLD_BASEDIR --datadir=$MYSQLD_DATADIR --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT --innodb_undo_log_encrypt=ON --debug=d,crash_before_purge_thread;
61+
--error 1,2,42
62+
--exec $NEW_CMD
63+
64+
--echo #########################################################################
65+
--echo # RESTART 3 : WITH KEYRING PLUGIN.
66+
--echo innodb_undo_log_encrypt=ON.
67+
--echo Skip rotating default master key in master thread
68+
--echo #########################################################################
69+
# Here server would start and UNDO encryption key would be loaded in-mem
70+
# successfully after reading them from REDO Log during scan.
71+
# NOTE: without the fix
72+
# - the encryption information wouldn't be applied on page 0.
73+
# - And as we don't allow master thread to rotate default master key, UNDO
74+
# tablespace encryption information will be lost at next restart.
75+
let $restart_parameters = restart: --innodb_dedicated_server=OFF --innodb_log_file_size=$LOG_FILE_SIZE --innodb_page_size=$START_PAGE_SIZE --innodb_data_home_dir=$MYSQLD_HOME_DATA_DIR --innodb_undo_directory=$MYSQLD_UNDO_DATADIR --basedir=$MYSQLD_BASEDIR --datadir=$MYSQLD_DATADIR --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT --innodb_undo_log_encrypt=ON --debug=d,skip_rotating_default_master_key;
76+
--source include/start_mysqld_no_echo.inc
77+
78+
--echo #########################################################################
79+
--echo # RESTART 4 : WITH KEYRING PLUGIN.
80+
--echo innodb_undo_log_encrypt=OFF.
81+
--echo #########################################################################
82+
# During this restart, without the fix:
83+
# - Encryption information will be looked for on page 0. But as it wasn't
84+
# applied in previous start, it wouldn't be found thus ASSERT will be hit.
85+
let $restart_parameters = restart: --innodb_dedicated_server=OFF --innodb_log_file_size=$LOG_FILE_SIZE --innodb_page_size=$START_PAGE_SIZE --innodb_data_home_dir=$MYSQLD_HOME_DATA_DIR --innodb_undo_directory=$MYSQLD_UNDO_DATADIR --basedir=$MYSQLD_BASEDIR --datadir=$MYSQLD_DATADIR --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT --innodb_undo_log_encrypt=OFF;
86+
--source include/restart_mysqld_no_echo.inc
87+
88+
--echo # Shutdown the running server
89+
SHUTDOWN;
90+
91+
--echo ###########
92+
--echo # CLEANUP #
93+
--echo ###########
94+
--echo # Restart the server with MTR default
95+
--let $restart_parameters=
96+
--source include/start_mysqld_no_echo.inc
97+
#--source include/restart_mysqld_no_echo.inc
98+
99+
# Remove residue files
100+
--remove_file $BOOTSTRAP_SQL
101+
--remove_file $MYSQL_TMP_DIR/mysecret_keyring
102+
--force-rmdir $MYSQL_TMP_DIR/datadir
103+
--force-rmdir $MYSQL_TMP_DIR/innodb_data_home_dir
104+
--force-rmdir $MYSQL_TMP_DIR/innodb_undo_data_dir

storage/innobase/fsp/fsp0fsp.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 1995, 2019, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 1995, 2020, Oracle and/or its affiliates. All Rights Reserved.
44
55
This program is free software; you can redistribute it and/or modify it under
66
the terms of the GNU General Public License, version 2.0, as published by the
@@ -1009,6 +1009,7 @@ bool fsp_header_init(space_id_t space_id, page_no_t size, mtr_t *mtr,
10091009
ut_ad(mtr);
10101010

10111011
fil_space_t *space = fil_space_get(space_id);
1012+
ut_ad(space != nullptr);
10121013

10131014
mtr_x_lock_space(space, mtr);
10141015

storage/innobase/log/log0recv.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ specified.
15951595
static byte *recv_parse_or_apply_log_rec_body(
15961596
mlog_id_t type, byte *ptr, byte *end_ptr, space_id_t space_id,
15971597
page_no_t page_no, buf_block_t *block, mtr_t *mtr, ulint parsed_bytes) {
1598-
ut_ad(!block == !mtr);
1598+
bool applying_redo = (block != nullptr);
15991599

16001600
switch (type) {
16011601
#ifndef UNIV_HOTBACKUP
@@ -1663,12 +1663,11 @@ static byte *recv_parse_or_apply_log_rec_body(
16631663
#ifdef UNIV_HOTBACKUP
16641664
if (recv_recovery_on && meb_is_space_loaded(space_id)) {
16651665
#endif /* UNIV_HOTBACKUP */
1666-
/* For encrypted tablespace, we need to get the
1667-
encryption key information before the page 0 is
1668-
recovered. Otherwise, redo will not find the key
1669-
to decrypt the data pages. */
1670-
1671-
if (page_no == 0 && !fsp_is_system_or_temp_tablespace(space_id) &&
1666+
/* For encrypted tablespace, we need to get the encryption key
1667+
information before the page 0 is recovered. Otherwise, redo will not
1668+
find the key to decrypt the data pages. */
1669+
if (page_no == 0 && !applying_redo &&
1670+
!fsp_is_system_or_temp_tablespace(space_id) &&
16721671
/* For cloned db header page has the encryption information. */
16731672
!recv_sys->is_cloned_db) {
16741673
return (fil_tablespace_redo_encryption(ptr, end_ptr, space_id));
@@ -1701,8 +1700,9 @@ static byte *recv_parse_or_apply_log_rec_body(
17011700
<< ", mtr: " << static_cast<const void *>(mtr) << " }";
17021701
#endif /* UNIV_HOTBACKUP && UNIV_DEBUG */
17031702

1704-
if (block != nullptr) {
1703+
if (applying_redo) {
17051704
/* Applying a page log record. */
1705+
ut_ad(mtr != nullptr);
17061706

17071707
page = block->frame;
17081708
page_zip = buf_block_get_page_zip(block);
@@ -1716,6 +1716,7 @@ static byte *recv_parse_or_apply_log_rec_body(
17161716

17171717
} else {
17181718
/* Parsing a page log record. */
1719+
ut_ad(mtr == nullptr);
17191720
page = nullptr;
17201721
page_zip = nullptr;
17211722

storage/innobase/srv/srv0srv.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,6 +2401,8 @@ void undo_rotate_default_master_key() {
24012401
return;
24022402
}
24032403

2404+
DBUG_EXECUTE_IF("skip_rotating_default_master_key", return;);
2405+
24042406
undo::spaces->s_lock();
24052407
for (auto undo_space : undo::spaces->m_spaces) {
24062408
ut_ad(fsp_is_undo_tablespace(undo_space->id()));

storage/innobase/srv/srv0start.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ static dberr_t srv_undo_tablespace_enable_encryption(space_id_t space_id) {
659659

660660
/** Try to read encryption metadata from an undo tablespace.
661661
@param[in] fh file handle of undo log file
662-
@param[in] file_name file name
662+
@param[in] file_name file name
663663
@param[in] space undo tablespace
664664
@return DB_SUCCESS if success */
665665
static dberr_t srv_undo_tablespace_read_encryption(pfs_os_file_t fh,
@@ -2918,8 +2918,7 @@ bool is_early_redo_undo_encryption_done() {
29182918
/** Start purge threads. During upgrade we start
29192919
purge threads early to apply purge. */
29202920
void srv_start_purge_threads() {
2921-
/* Start purge threads only if they are not started
2922-
earlier. */
2921+
/* Start purge threads only if they are not started earlier. */
29232922
if (srv_start_state_is_set(SRV_START_STATE_PURGE)) {
29242923
return;
29252924
}
@@ -3048,6 +3047,8 @@ void srv_start_threads_after_ddl_recovery() {
30483047
auto &gtid_persistor = clone_sys->get_gtid_persistor();
30493048
gtid_persistor.start();
30503049

3050+
DBUG_EXECUTE_IF("crash_before_purge_thread", ut_ad(false););
3051+
30513052
/* Now the InnoDB Metadata and file system should be consistent.
30523053
Start the Purge thread */
30533054
srv_start_purge_threads();

0 commit comments

Comments
 (0)