Commit a133b05c authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent 064d1a48
...@@ -2602,13 +2602,15 @@ innobase_start_or_create_for_mysql() ...@@ -2602,13 +2602,15 @@ innobase_start_or_create_for_mysql()
operations */ operations */
if (!srv_read_only_mode) { if (!srv_read_only_mode) {
thread_handles[1 + SRV_MAX_N_IO_THREADS] = os_thread_create( thread_handles[1 + SRV_MAX_N_IO_THREADS] = os_thread_create(
srv_master_thread, srv_master_thread,
NULL, thread_ids + (1 + SRV_MAX_N_IO_THREADS)); NULL, thread_ids + (1 + SRV_MAX_N_IO_THREADS));
thread_started[1 + SRV_MAX_N_IO_THREADS] = true; thread_started[1 + SRV_MAX_N_IO_THREADS] = true;
srv_start_state_set(SRV_START_STATE_MASTER); srv_start_state_set(SRV_START_STATE_MASTER);
}
if (!srv_read_only_mode
&& srv_force_recovery < SRV_FORCE_NO_BACKGROUND) {
srv_undo_sources = true; srv_undo_sources = true;
/* Create the dict stats gathering thread */ /* Create the dict stats gathering thread */
srv_dict_stats_thread_active = true; srv_dict_stats_thread_active = true;
...@@ -2617,10 +2619,6 @@ innobase_start_or_create_for_mysql() ...@@ -2617,10 +2619,6 @@ innobase_start_or_create_for_mysql()
/* Create the thread that will optimize the FTS sub-system. */ /* Create the thread that will optimize the FTS sub-system. */
fts_optimize_init(); 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( thread_handles[5 + SRV_MAX_N_IO_THREADS] = os_thread_create(
srv_purge_coordinator_thread, srv_purge_coordinator_thread,
......
...@@ -285,6 +285,8 @@ trx_purge_add_update_undo_to_history( ...@@ -285,6 +285,8 @@ trx_purge_add_update_undo_to_history(
purge have been started, recv_recovery_rollback_active() can purge have been started, recv_recovery_rollback_active() can
start transactions in row_merge_drop_temp_indexes() and start transactions in row_merge_drop_temp_indexes() and
fts_drop_orphaned_tables(), and roll back recovered transactions. 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, After the purge thread has been given permission to exit,
in fast shutdown, we may roll back transactions (trx->undo_no==0) in fast shutdown, we may roll back transactions (trx->undo_no==0)
in THD::cleanup() invoked from unlink_thd(). */ in THD::cleanup() invoked from unlink_thd(). */
...@@ -292,6 +294,8 @@ trx_purge_add_update_undo_to_history( ...@@ -292,6 +294,8 @@ trx_purge_add_update_undo_to_history(
|| ((srv_startup_is_before_trx_rollback_phase || ((srv_startup_is_before_trx_rollback_phase
|| trx_rollback_or_clean_is_active) || trx_rollback_or_clean_is_active)
&& purge_sys->state == PURGE_STATE_INIT) && 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)); || (trx->undo_no == 0 && srv_fast_shutdown));
/* Add the log as the first in the history list */ /* Add the log as the first in the history list */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment