Skip to content
Permalink
Browse files
Disable more threads on innodb_force_recovery=3 or more
The original intention of the setting innodb_force_recovery=3 was to
disable background activity that could create trouble, most notably,
the rollback of incomplete transactions, and the purge of transaction
history.

MySQL 5.6 introduced more background threads, it is creating
dict_stats_thread and fts_optimize_thread even though these threads
are at least as non-essential as the rollback and purge. These
threads are in fact worse, because they can create new transactions
on their own.

innobase_start_or_create_for_mysql(): Do not create any internal
undo log sources unless innodb_force_recovery<3.
  • Loading branch information
dr-m committed Jun 22, 2017
1 parent 064d1a4 commit a133b05
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
@@ -2602,13 +2602,15 @@ innobase_start_or_create_for_mysql()
operations */

if (!srv_read_only_mode) {

thread_handles[1 + SRV_MAX_N_IO_THREADS] = os_thread_create(
srv_master_thread,
NULL, thread_ids + (1 + SRV_MAX_N_IO_THREADS));
thread_started[1 + SRV_MAX_N_IO_THREADS] = true;
srv_start_state_set(SRV_START_STATE_MASTER);
}

if (!srv_read_only_mode
&& srv_force_recovery < SRV_FORCE_NO_BACKGROUND) {
srv_undo_sources = true;
/* Create the dict stats gathering thread */
srv_dict_stats_thread_active = true;
@@ -2617,10 +2619,6 @@ innobase_start_or_create_for_mysql()

/* Create the thread that will optimize the FTS sub-system. */
fts_optimize_init();
}

if (!srv_read_only_mode
&& srv_force_recovery < SRV_FORCE_NO_BACKGROUND) {

thread_handles[5 + SRV_MAX_N_IO_THREADS] = os_thread_create(
srv_purge_coordinator_thread,
@@ -285,13 +285,17 @@ trx_purge_add_update_undo_to_history(
purge have been started, recv_recovery_rollback_active() can
start transactions in row_merge_drop_temp_indexes() and
fts_drop_orphaned_tables(), and roll back recovered transactions.
Also, DROP TABLE may be executed while innodb_force_recovery=2
prevents the purge from running.
After the purge thread has been given permission to exit,
in fast shutdown, we may roll back transactions (trx->undo_no==0)
in THD::cleanup() invoked from unlink_thd(). */
ut_ad(srv_undo_sources
|| ((srv_startup_is_before_trx_rollback_phase
|| trx_rollback_or_clean_is_active)
&& purge_sys->state == PURGE_STATE_INIT)
|| (srv_force_recovery >= SRV_FORCE_NO_BACKGROUND
&& purge_sys->state == PURGE_STATE_DISABLED)
|| (trx->undo_no == 0 && srv_fast_shutdown));

/* Add the log as the first in the history list */

0 comments on commit a133b05

Please sign in to comment.