Browse Source

MDEV-20638 Remove the deadcode from srv_master_thread() and srv_active_wake_master_thread_low()

- Due to commit fe95cb2e40 (MDEV-16125),
InnoDB master thread does not need to call srv_resume_thread()
and therefore there is no need to wake up the thread.
Due to the above patch, InnoDB should remove the following dead code.

srv_check_activity(): Makes the parameter as in,out and returns the
recent activity value

innobase_active_small(): Removed

srv_active_wake_master_thread(): Removed

srv_wake_master_thread(): Removed

srv_active_wake_master_thread_low(): Removed

Simplify srv_master_thread() and remove switch cases, added the assert.

Replace srv_wake_master_thread() with srv_inc_activity_count()

INNOBASE_WAKE_INTERVAL: Removed
pull/1642/head
Thirunarayanan Balathandayuthapani 5 years ago
parent
commit
fe39d02f51
  1. 6
      extra/mariabackup/xtrabackup.cc
  2. 4
      storage/innobase/buf/buf0flu.cc
  3. 48
      storage/innobase/handler/ha_innodb.cc
  4. 5
      storage/innobase/handler/handler0alter.cc
  5. 25
      storage/innobase/include/srv0srv.h
  6. 2
      storage/innobase/row/row0mysql.cc
  7. 2
      storage/innobase/row/row0trunc.cc
  8. 100
      storage/innobase/srv/srv0srv.cc
  9. 4
      storage/innobase/srv/srv0start.cc
  10. 3
      storage/innobase/trx/trx0roll.cc
  11. 6
      storage/innobase/trx/trx0trx.cc

6
extra/mariabackup/xtrabackup.cc

@ -254,12 +254,6 @@ my_bool innobase_locks_unsafe_for_binlog;
my_bool innobase_rollback_on_timeout;
my_bool innobase_create_status_file;
/* The following counter is used to convey information to InnoDB
about server activity: in selects it is not sensible to call
srv_active_wake_master_thread after each fetch or search, we only do
it every INNOBASE_WAKE_INTERVAL'th step. */
#define INNOBASE_WAKE_INTERVAL 32
ulong innobase_active_counter = 0;

4
storage/innobase/buf/buf0flu.cc

@ -3141,7 +3141,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)(void*)
/* The page_cleaner skips sleep if the server is
idle and there are no pending IOs in the buffer pool
and there is work to do. */
if (srv_check_activity(last_activity)
if (srv_check_activity(&last_activity)
|| buf_get_n_pending_read_ios()
|| n_flushed == 0) {
@ -3233,7 +3233,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)(void*)
n_flushed = n_flushed_lru + n_flushed_list;
} else if (srv_check_activity(last_activity)) {
} else if (srv_check_activity(&last_activity)) {
ulint n_to_flush;
lsn_t lsn_limit = 0;

48
storage/innobase/handler/ha_innodb.cc

@ -446,14 +446,6 @@ static TYPELIB innodb_lock_schedule_algorithm_typelib = {
NULL
};
/* The following counter is used to convey information to InnoDB
about server activity: in case of normal DML ops it is not
sensible to call srv_active_wake_master_thread after each
operation, we only do it every INNOBASE_WAKE_INTERVAL'th step. */
#define INNOBASE_WAKE_INTERVAL 32
static ulong innobase_active_counter = 0;
/** Allowed values of innodb_change_buffering */
static const char* innobase_change_buffering_values[IBUF_USE_COUNT] = {
"none", /* IBUF_USE_NONE */
@ -1893,23 +1885,6 @@ thd_to_trx_id(
}
#endif /* WITH_WSREP */
/********************************************************************//**
Increments innobase_active_counter and every INNOBASE_WAKE_INTERVALth
time calls srv_active_wake_master_thread. This function should be used
when a single database operation may introduce a small need for
server utility activity, like checkpointing. */
inline
void
innobase_active_small(void)
/*=======================*/
{
innobase_active_counter++;
if ((innobase_active_counter % INNOBASE_WAKE_INTERVAL) == 0) {
srv_active_wake_master_thread();
}
}
/********************************************************************//**
Converts an InnoDB error code to a MySQL error code and also tells to MySQL
about a possible transaction rollback inside InnoDB caused by a lock wait
@ -6655,11 +6630,6 @@ ha_innobase::close()
MONITOR_INC(MONITOR_TABLE_CLOSE);
/* Tell InnoDB server that there might be work for
utility threads: */
srv_active_wake_master_thread();
DBUG_RETURN(0);
}
@ -8374,8 +8344,6 @@ report_error:
}
func_exit:
innobase_active_small();
DBUG_RETURN(error_result);
}
@ -9046,11 +9014,6 @@ func_exit:
error, m_prebuilt->table->flags, m_user_thd);
}
/* Tell InnoDB server that there might be work for
utility threads: */
innobase_active_small();
#ifdef WITH_WSREP
if (error == DB_SUCCESS && trx->is_wsrep() &&
wsrep_thd_exec_mode(m_user_thd) == LOCAL_STATE &&
@ -9106,11 +9069,6 @@ ha_innobase::delete_row(
innobase_srv_conc_exit_innodb(m_prebuilt);
/* Tell the InnoDB server that there might be work for
utility threads: */
innobase_active_small();
#ifdef WITH_WSREP
if (error == DB_SUCCESS && trx->is_wsrep()
&& wsrep_thd_exec_mode(m_user_thd) == LOCAL_STATE
@ -12998,7 +12956,6 @@ create_table_info_t::create_table_update_dict()
if (m_flags2 & DICT_TF2_FTS) {
if (!innobase_fts_load_stopword(innobase_table, NULL, m_thd)) {
dict_table_close(innobase_table, FALSE, FALSE);
srv_active_wake_master_thread();
trx_free_for_mysql(m_trx);
DBUG_RETURN(-1);
}
@ -13144,11 +13101,6 @@ ha_innobase::create(
error = info.create_table_update_dict();
/* Tell the InnoDB server that there might be work for
utility threads: */
srv_active_wake_master_thread();
DBUG_RETURN(error);
}

5
storage/innobase/handler/handler0alter.cc

@ -8637,11 +8637,6 @@ foreign_fail:
log_append_on_checkpoint(NULL);
/* Tell the InnoDB server that there might be work for
utility threads: */
srv_active_wake_master_thread();
if (fail) {
for (inplace_alter_handler_ctx** pctx = ctx_array;
*pctx; pctx++) {

25
storage/innobase/include/srv0srv.h

@ -809,19 +809,6 @@ srv_reset_io_thread_op_info();
/** Wake up the purge threads if there is work to do. */
void
srv_wake_purge_thread_if_not_active();
/** Wake up the InnoDB master thread if it was suspended (not sleeping). */
void
srv_active_wake_master_thread_low();
#define srv_active_wake_master_thread() \
do { \
if (!srv_read_only_mode) { \
srv_active_wake_master_thread_low(); \
} \
} while (0)
/** Wake up the master thread if it is suspended or being suspended. */
void
srv_wake_master_thread();
/******************************************************************//**
Outputs to a file the output of the InnoDB Monitor.
@ -850,13 +837,13 @@ reading this value as it is only used in heuristics.
ulint
srv_get_activity_count(void);
/*========================*/
/*******************************************************************//**
Check if there has been any activity.
/** Check if there has been any activity.
@param[in,out] activity_count recent activity count to be returned
if there is a change
@return FALSE if no change in activity counter. */
ibool
srv_check_activity(
/*===============*/
ulint old_activity_count); /*!< old activity count */
bool srv_check_activity(ulint *activity_count);
/******************************************************************//**
Increment the server activity counter. */
void

2
storage/innobase/row/row0mysql.cc

@ -3820,7 +3820,7 @@ funct_exit:
trx->op_info = "";
srv_wake_master_thread();
srv_inc_activity_count();
DBUG_RETURN(err);
}

2
storage/innobase/row/row0trunc.cc

@ -1249,7 +1249,7 @@ row_truncate_complete(
ut_ad(!trx_is_started(trx));
srv_wake_master_thread();
srv_inc_activity_count();
DBUG_EXECUTE_IF("ib_trunc_crash_after_truncate_done",
DBUG_SUICIDE(););

100
storage/innobase/srv/srv0srv.cc

@ -1982,33 +1982,6 @@ srv_get_active_thread_type(void)
return(ret);
}
/** Wake up the InnoDB master thread if it was suspended (not sleeping). */
void
srv_active_wake_master_thread_low()
{
ut_ad(!srv_read_only_mode);
ut_ad(!srv_sys_mutex_own());
srv_inc_activity_count();
if (my_atomic_loadlint(&srv_sys.n_threads_active[SRV_MASTER]) == 0) {
srv_slot_t* slot;
srv_sys_mutex_enter();
slot = &srv_sys.sys_threads[SRV_MASTER_SLOT];
/* Only if the master thread has been started. */
if (slot->in_use) {
ut_a(srv_slot_get_type(slot) == SRV_MASTER);
os_event_set(slot->event);
}
srv_sys_mutex_exit();
}
}
/** Wake up the purge threads if there is work to do. */
void
srv_wake_purge_thread_if_not_active()
@ -2023,14 +1996,6 @@ srv_wake_purge_thread_if_not_active()
}
}
/** Wake up the master thread if it is suspended or being suspended. */
void
srv_wake_master_thread()
{
srv_inc_activity_count();
srv_release_threads(SRV_MASTER, 1);
}
/*******************************************************************//**
Get current server activity count. We don't hold srv_sys::mutex while
reading this value as it is only used in heuristics.
@ -2042,15 +2007,20 @@ srv_get_activity_count(void)
return(srv_sys.activity_count);
}
/*******************************************************************//**
Check if there has been any activity.
/** Check if there has been any activity.
@param[in,out] activity_count recent activity count to be returned
if there is a change
@return FALSE if no change in activity counter. */
ibool
srv_check_activity(
/*===============*/
ulint old_activity_count) /*!< in: old activity count */
bool srv_check_activity(ulint *activity_count)
{
return(srv_sys.activity_count != old_activity_count);
ulint new_activity_count= srv_sys.activity_count;
if (new_activity_count != *activity_count)
{
*activity_count= new_activity_count;
return true;
}
return false;
}
/********************************************************************//**
@ -2457,52 +2427,30 @@ DECLARE_THREAD(srv_master_thread)(
slot = srv_reserve_slot(SRV_MASTER);
ut_a(slot == srv_sys.sys_threads);
loop:
while (srv_shutdown_state <= SRV_SHUTDOWN_INITIATED) {
srv_master_sleep();
MONITOR_INC(MONITOR_MASTER_THREAD_SLEEP);
if (srv_check_activity(old_activity_count)) {
old_activity_count = srv_get_activity_count();
if (srv_check_activity(&old_activity_count)) {
srv_master_do_active_tasks();
} else {
srv_master_do_idle_tasks();
}
}
switch (srv_shutdown_state) {
case SRV_SHUTDOWN_NONE:
case SRV_SHUTDOWN_INITIATED:
break;
case SRV_SHUTDOWN_FLUSH_PHASE:
case SRV_SHUTDOWN_LAST_PHASE:
ut_ad(0);
/* fall through */
case SRV_SHUTDOWN_EXIT_THREADS:
/* srv_init_abort() must have been invoked */
case SRV_SHUTDOWN_CLEANUP:
if (srv_shutdown_state == SRV_SHUTDOWN_CLEANUP
&& srv_fast_shutdown < 2) {
srv_shutdown(srv_fast_shutdown == 0);
}
srv_suspend_thread(slot);
my_thread_end();
os_thread_exit();
}
ut_ad(srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS
|| srv_shutdown_state == SRV_SHUTDOWN_CLEANUP);
srv_main_thread_op_info = "suspending";
if (srv_shutdown_state == SRV_SHUTDOWN_CLEANUP
&& srv_fast_shutdown < 2) {
srv_shutdown(srv_fast_shutdown == 0);
}
srv_suspend_thread(slot);
/* DO NOT CHANGE THIS STRING. innobase_start_or_create_for_mysql()
waits for database activity to die down when converting < 4.1.x
databases, and relies on this string being exactly as it is. InnoDB
manual also mentions this string in several places. */
srv_main_thread_op_info = "waiting for server activity";
srv_resume_thread(slot);
goto loop;
my_thread_end();
os_thread_exit();
OS_THREAD_DUMMY_RETURN;
}
/** Check if purge should stop.
@ -2699,15 +2647,13 @@ srv_do_purge(ulint* n_total_purged
++n_use_threads;
}
} else if (srv_check_activity(old_activity_count)
} else if (srv_check_activity(&old_activity_count)
&& n_use_threads > 1) {
/* History length same or smaller since last snapshot,
use fewer threads. */
--n_use_threads;
old_activity_count = srv_get_activity_count();
}
/* Ensure that the purge threads are less than what

4
storage/innobase/srv/srv0start.cc

@ -1238,7 +1238,7 @@ srv_shutdown_all_bg_threads()
if (srv_start_state_is_set(SRV_START_STATE_MASTER)) {
/* c. We wake the master thread so that
it exits */
srv_wake_master_thread();
srv_inc_activity_count();
}
if (srv_start_state_is_set(SRV_START_STATE_PURGE)) {
@ -2762,7 +2762,7 @@ srv_shutdown_bg_undo_sources()
fts_optimize_shutdown();
dict_stats_shutdown();
while (row_get_background_drop_list_len_low()) {
srv_wake_master_thread();
srv_inc_activity_count();
os_thread_yield();
}
srv_undo_sources = false;

3
storage/innobase/trx/trx0roll.cc

@ -124,9 +124,6 @@ trx_rollback_to_savepoint_low(
mem_heap_free(heap);
/* There might be work for utility threads.*/
srv_active_wake_master_thread();
MONITOR_DEC(MONITOR_TRX_ACTIVE);
}

6
storage/innobase/trx/trx0trx.cc

@ -1804,12 +1804,6 @@ trx_commit_in_memory(
}
trx->commit_lsn = lsn;
/* Tell server some activity has happened, since the trx
does changes something. Background utility threads like
master thread, purge thread or page_cleaner thread might
have some work to do. */
srv_active_wake_master_thread();
}
ut_ad(!trx->rsegs.m_noredo.undo);

Loading…
Cancel
Save