diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-01-30 17:00:51 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-01-31 10:23:20 +0200 |
commit | 1293e5e59b6b412156ef8a78f762c0b099a10b50 (patch) | |
tree | d6ae1f478874cd2dd1279d4116a840a38fad4b90 /storage | |
parent | 9f918b9cf48989a9c1fedbd3fd8849d4d6892690 (diff) | |
download | mariadb-git-1293e5e59b6b412156ef8a78f762c0b099a10b50.tar.gz |
Rewrite the innodb.log_file_size test with DBUG_EXECUTE_IF.
Remove the debug parameter innodb_force_recovery_crash that was
introduced into MySQL 5.6 by me in WL#6494 which allowed InnoDB
to resize the redo log on startup.
Let innodb.log_file_size actually start up the server, but ensure
that the InnoDB storage engine refuses to start up in each of the
scenarios.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/btr/btr0cur.cc | 3 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 10 | ||||
-rw-r--r-- | storage/innobase/include/srv0srv.h | 3 | ||||
-rw-r--r-- | storage/innobase/include/srv0start.h | 13 | ||||
-rw-r--r-- | storage/innobase/include/ut0mutex.h | 2 | ||||
-rw-r--r-- | storage/innobase/srv/srv0srv.cc | 5 | ||||
-rw-r--r-- | storage/innobase/srv/srv0start.cc | 82 |
7 files changed, 52 insertions, 66 deletions
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 8b139d58b96..9033c399ce2 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -3,7 +3,7 @@ Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2015, 2016, MariaDB Corporation. +Copyright (c) 2015, 2017, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -4208,7 +4208,6 @@ btr_cur_pessimistic_update( ut_ad(thr_get_trx(thr)->in_rollback); DBUG_EXECUTE_IF("ib_blob_update_rollback", DBUG_SUICIDE();); - RECOVERY_CRASH(99); btr_rec_free_updated_extern_fields( index, rec, page_zip, *offsets, update, true, mtr); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index fd9702c727e..7edc1fdd687 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -21326,13 +21326,6 @@ static MYSQL_SYSVAR_ULONG(force_recovery, srv_force_recovery, "Helps to save your data in case the disk image of the database becomes corrupt.", NULL, NULL, 0, 0, 6, 0); -#ifndef DBUG_OFF -static MYSQL_SYSVAR_ULONG(force_recovery_crash, srv_force_recovery_crash, - PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, - "Kills the server during crash recovery.", - NULL, NULL, 0, 0, 100, 0); -#endif /* !DBUG_OFF */ - static MYSQL_SYSVAR_ULONG(page_size, srv_page_size, PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY, "Page size to use for all InnoDB tablespaces.", @@ -21975,9 +21968,6 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(flush_log_at_trx_commit), MYSQL_SYSVAR(flush_method), MYSQL_SYSVAR(force_recovery), -#ifndef DBUG_OFF - MYSQL_SYSVAR(force_recovery_crash), -#endif /* !DBUG_OFF */ MYSQL_SYSVAR(fill_factor), MYSQL_SYSVAR(ft_cache_size), MYSQL_SYSVAR(ft_total_cache_size), diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index ca81ad46b8b..b22487ca1ef 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -450,9 +450,6 @@ extern double srv_adaptive_flushing_lwm; extern ulong srv_flushing_avg_loops; extern ulong srv_force_recovery; -#ifndef DBUG_OFF -extern ulong srv_force_recovery_crash; -#endif /* !DBUG_OFF */ extern ulint srv_fast_shutdown; /*!< If this is 1, do not do a purge and index buffer merge. diff --git a/storage/innobase/include/srv0start.h b/storage/innobase/include/srv0start.h index f08e6e71a78..d456806b86b 100644 --- a/storage/innobase/include/srv0start.h +++ b/storage/innobase/include/srv0start.h @@ -34,19 +34,6 @@ Created 10/10/1995 Heikki Tuuri // Forward declaration struct dict_table_t; -#ifdef DBUG_OFF -# define RECOVERY_CRASH(x) do {} while(0) -#else -# define RECOVERY_CRASH(x) do { \ - if (srv_force_recovery_crash == x) { \ - fprintf(stderr, "innodb_force_recovery_crash=%lu\n", \ - srv_force_recovery_crash); \ - fflush(stderr); \ - exit(3); \ - } \ -} while (0) -#endif /* DBUG_OFF */ - /** If buffer pool is less than the size, only one buffer pool instance is used. */ #define BUF_POOL_SIZE_THRESHOLD (1024 * 1024 * 1024) diff --git a/storage/innobase/include/ut0mutex.h b/storage/innobase/include/ut0mutex.h index 197a34e6122..354fd9e0a7a 100644 --- a/storage/innobase/include/ut0mutex.h +++ b/storage/innobase/include/ut0mutex.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2012, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 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 @@ -30,7 +31,6 @@ Created 2012-03-24 Sunny Bains. extern uint srv_spin_wait_delay; extern ulong srv_n_spin_wait_rounds; -extern ulong srv_force_recovery_crash; #include "sync0policy.h" #include "ib0mutex.h" diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 56fc8524945..8ae2193a7a0 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -359,11 +359,6 @@ starting from SRV_FORCE_IGNORE_CORRUPT, so that data can be recovered by SELECT or mysqldump. When this is nonzero, we do not allow any user modifications to the data. */ ulong srv_force_recovery; -#ifndef DBUG_OFF -/** Inject a crash at different steps of the recovery process. -This is for testing and debugging only. */ -ulong srv_force_recovery_crash; -#endif /* !DBUG_OFF */ /** Print all user-level transactions deadlocks to mysqld stderr */ diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 587ffc15adb..408501f6f0d 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -418,12 +418,12 @@ create_log_files( file should be recoverable. The buffer pool was clean, and we can simply create all log files from the scratch. */ - RECOVERY_CRASH(6); + DBUG_EXECUTE_IF("innodb_log_abort_6", return(DB_ERROR);); } ut_ad(!buf_pool_check_no_pending_io()); - RECOVERY_CRASH(7); + DBUG_EXECUTE_IF("innodb_log_abort_7", return(DB_ERROR);); for (unsigned i = 0; i < srv_n_log_files; i++) { sprintf(logfilename + dirnamelen, @@ -436,7 +436,7 @@ create_log_files( } } - RECOVERY_CRASH(8); + DBUG_EXECUTE_IF("innodb_log_abort_8", return(DB_ERROR);); /* We did not create the first log file initially as ib_logfile0, so that crash recovery cannot find it until it @@ -488,10 +488,16 @@ create_log_files( return(DB_SUCCESS); } -/*********************************************************************//** -Renames the first log file. */ +/** Rename the first redo log file. +@param[in,out] logfilename buffer for the log file name +@param[in] dirnamelen length of the directory path +@param[in] lsn FIL_PAGE_FILE_FLUSH_LSN value +@param[in,out] logfile0 name of the first log file +@return error code +@retval DB_SUCCESS on successful operation */ +MY_ATTRIBUTE((warn_unused_result, nonnull)) static -void +dberr_t create_log_files_rename( /*====================*/ char* logfilename, /*!< in/out: buffer for log file name */ @@ -502,6 +508,9 @@ create_log_files_rename( /* If innodb_flush_method=O_DSYNC, we need to explicitly flush the log buffers. */ fil_flush(SRV_LOG_SPACE_FIRST_ID); + + DBUG_EXECUTE_IF("innodb_log_abort_9", return(DB_ERROR);); + /* Close the log files, so that we can rename the first one. */ fil_close_log_files(false); @@ -510,26 +519,26 @@ create_log_files_rename( checkpoint has been created. */ sprintf(logfilename + dirnamelen, "ib_logfile%u", 0); - RECOVERY_CRASH(9); - ib::info() << "Renaming log file " << logfile0 << " to " << logfilename; log_mutex_enter(); ut_ad(strlen(logfile0) == 2 + strlen(logfilename)); - bool success = os_file_rename( - innodb_log_file_key, logfile0, logfilename); - ut_a(success); - - RECOVERY_CRASH(10); + dberr_t err = os_file_rename( + innodb_log_file_key, logfile0, logfilename) + ? DB_SUCCESS : DB_ERROR; /* Replace the first file with ib_logfile0. */ strcpy(logfile0, logfilename); log_mutex_exit(); + DBUG_EXECUTE_IF("innodb_log_abort_10", err = DB_ERROR;); + fil_open_log_and_system_tablespace_files(); ib::warn() << "New log files created, LSN=" << lsn; + + return(err); } /*********************************************************************//** @@ -1117,8 +1126,6 @@ srv_open_tmp_tablespace(bool create_new_db) srv_tmp_space.set_space_id(SRV_TMP_SPACE_ID); - RECOVERY_CRASH(100); - dberr_t err = srv_tmp_space.check_file_spec( &create_new_temp_space, 12 * 1024 * 1024); @@ -1347,7 +1354,7 @@ srv_prepare_to_delete_redo_log_files( /* Clean the buffer pool. */ buf_flush_sync_all_buf_pools(); - RECOVERY_CRASH(1); + DBUG_EXECUTE_IF("innodb_log_abort_1", return(0);); log_mutex_enter(); @@ -1952,14 +1959,17 @@ innobase_start_or_create_for_mysql(void) logfilename, dirnamelen, flushed_lsn, logfile0); + if (err == DB_SUCCESS) { + err = create_log_files_rename( + logfilename, + dirnamelen, + flushed_lsn, logfile0); + } + if (err != DB_SUCCESS) { return(srv_init_abort(err)); } - create_log_files_rename( - logfilename, dirnamelen, - flushed_lsn, logfile0); - /* Suppress the message about crash recovery. */ flushed_lsn = log_get_lsn(); @@ -2119,13 +2129,15 @@ files_checked: err = fil_write_flushed_lsn(flushed_lsn); + if (err == DB_SUCCESS) { + err = create_log_files_rename( + logfilename, dirnamelen, + flushed_lsn, logfile0); + } + if (err != DB_SUCCESS) { return(srv_init_abort(err)); } - - create_log_files_rename( - logfilename, dirnamelen, flushed_lsn, logfile0); - } else { /* Check if we support the max format that is stamped @@ -2348,28 +2360,32 @@ files_checked: /* Prepare to delete the old redo log files */ flushed_lsn = srv_prepare_to_delete_redo_log_files(i); + DBUG_EXECUTE_IF("innodb_log_abort_1", + return(srv_init_abort(DB_ERROR));); /* Prohibit redo log writes from any other threads until creating a log checkpoint at the end of create_log_files(). */ ut_d(recv_no_log_write = true); ut_ad(!buf_pool_check_no_pending_io()); - RECOVERY_CRASH(3); + DBUG_EXECUTE_IF("innodb_log_abort_3", + return(srv_init_abort(DB_ERROR));); /* Stamp the LSN to the data files. */ err = fil_write_flushed_lsn(flushed_lsn); + DBUG_EXECUTE_IF("innodb_log_abort_4", err = DB_ERROR;); + if (err != DB_SUCCESS) { return(srv_init_abort(err)); } - RECOVERY_CRASH(4); - /* Close and free the redo log files, so that we can replace them. */ fil_close_log_files(true); - RECOVERY_CRASH(5); + DBUG_EXECUTE_IF("innodb_log_abort_5", + return(srv_init_abort(DB_ERROR));); /* Free the old log file space. */ log_group_close_all(); @@ -2383,13 +2399,15 @@ files_checked: logfilename, dirnamelen, flushed_lsn, logfile0); + if (err == DB_SUCCESS) { + err = create_log_files_rename( + logfilename, dirnamelen, flushed_lsn, + logfile0); + } + if (err != DB_SUCCESS) { return(srv_init_abort(err)); } - - create_log_files_rename( - logfilename, dirnamelen, flushed_lsn, - logfile0); } recv_recovery_rollback_active(); |