Commit 7e71dfa9 authored by Jan Lindström's avatar Jan Lindström

MDEV-6933: Spurious lock_wait_timeout_thread wakeup in lock_wait_suspend_thread()

Merged Facebooks commit 6e06bbfa315ffb97d713dd6e672d6054036ddc21
authored by Inaam Rana from https://github.com/facebook/mysql-5.6.

Fixes MySQL bug http://bugs.mysql.com/bug.php?id=72123

lock_timeout thread works in a tight loop waking up every second
and checking for lock_wait_timeout. In addition, when a mysql
thread is forced to wait on a lock, it signals the lock_timeout thread
as well. This call is not required. In a heavily contended workload
each thread going to wait will signal the lock_timeout thread making
it work all the time. As lock_timeout thread scans the array of
waiting threads under lock_sys::wait_mutex which is already very
hot in contneded loads, these extra scans can cause significanct
performance regression.

Also, in various codepaths lock_timeout thread is signalled where
actual intention was to signal the innodb monitor thread.
parent f0debf2f
......@@ -1193,7 +1193,7 @@ buf_LRU_check_size_of_non_data_objects(
buf_lru_switched_on_innodb_mon = TRUE;
srv_print_innodb_monitor = TRUE;
os_event_set(lock_sys->timeout_event);
os_event_set(srv_monitor_event);
}
} else if (buf_lru_switched_on_innodb_mon) {
......@@ -1342,7 +1342,7 @@ buf_LRU_get_free_block(
mon_value_was = srv_print_innodb_monitor;
started_monitor = TRUE;
srv_print_innodb_monitor = TRUE;
os_event_set(lock_sys->timeout_event);
os_event_set(srv_monitor_event);
}
/* If we have scanned the whole LRU and still are unable to
......
......@@ -16019,9 +16019,8 @@ innodb_status_output_update(
const void* save __attribute__((unused)))
{
*static_cast<my_bool*>(var_ptr) = *static_cast<const my_bool*>(save);
/* The lock timeout monitor thread also takes care of this
output. */
os_event_set(lock_sys->timeout_event);
/* Wakeup server monitor thread. */
os_event_set(srv_monitor_event);
}
static SHOW_VAR innodb_status_variables_export[]= {
......
......@@ -259,10 +259,6 @@ lock_wait_suspend_thread(
}
}
/* Wake the lock timeout monitor thread, if it is suspended */
os_event_set(lock_sys->timeout_event);
lock_wait_mutex_exit();
trx_mutex_exit(trx);
......
......@@ -2200,23 +2200,23 @@ row_create_table_for_mysql(
/* The lock timeout monitor thread also takes care
of InnoDB monitor prints */
os_event_set(lock_sys->timeout_event);
os_event_set(srv_monitor_event);
} else if (STR_EQ(table_name, table_name_len,
S_innodb_lock_monitor)) {
srv_print_innodb_monitor = TRUE;
srv_print_innodb_lock_monitor = TRUE;
os_event_set(lock_sys->timeout_event);
os_event_set(srv_monitor_event);
} else if (STR_EQ(table_name, table_name_len,
S_innodb_tablespace_monitor)) {
srv_print_innodb_tablespace_monitor = TRUE;
os_event_set(lock_sys->timeout_event);
os_event_set(srv_monitor_event);
} else if (STR_EQ(table_name, table_name_len,
S_innodb_table_monitor)) {
srv_print_innodb_table_monitor = TRUE;
os_event_set(lock_sys->timeout_event);
os_event_set(srv_monitor_event);
#ifdef UNIV_MEM_DEBUG
} else if (STR_EQ(table_name, table_name_len,
S_innodb_mem_validate)) {
......
......@@ -1074,7 +1074,7 @@ sync_array_print_long_waits(
(ulong) os_file_n_pending_pwrites);
srv_print_innodb_monitor = TRUE;
os_event_set(lock_sys->timeout_event);
os_event_set(srv_monitor_event);
os_thread_sleep(30000000);
......
......@@ -1282,7 +1282,7 @@ buf_LRU_check_size_of_non_data_objects(
buf_lru_switched_on_innodb_mon = TRUE;
srv_print_innodb_monitor = TRUE;
os_event_set(lock_sys->timeout_event);
os_event_set(srv_monitor_event);
}
} else if (buf_lru_switched_on_innodb_mon) {
......@@ -1497,7 +1497,7 @@ buf_LRU_get_free_block(
mon_value_was = srv_print_innodb_monitor;
started_monitor = TRUE;
srv_print_innodb_monitor = TRUE;
os_event_set(lock_sys->timeout_event);
os_event_set(srv_monitor_event);
}
/* If we have scanned the whole LRU and still are unable to
......
......@@ -17055,9 +17055,8 @@ innodb_status_output_update(
const void* save __attribute__((unused)))
{
*static_cast<my_bool*>(var_ptr) = *static_cast<const my_bool*>(save);
/* The lock timeout monitor thread also takes care of this
output. */
os_event_set(lock_sys->timeout_event);
/* Wakeup server monitor thread. */
os_event_set(srv_monitor_event);
}
static SHOW_VAR innodb_status_variables_export[]= {
......
......@@ -259,10 +259,6 @@ lock_wait_suspend_thread(
}
}
/* Wake the lock timeout monitor thread, if it is suspended */
os_event_set(lock_sys->timeout_event);
lock_wait_mutex_exit();
trx_mutex_exit(trx);
......
......@@ -2214,23 +2214,23 @@ row_create_table_for_mysql(
/* The lock timeout monitor thread also takes care
of InnoDB monitor prints */
os_event_set(lock_sys->timeout_event);
os_event_set(srv_monitor_event);
} else if (STR_EQ(table_name, table_name_len,
S_innodb_lock_monitor)) {
srv_print_innodb_monitor = TRUE;
srv_print_innodb_lock_monitor = TRUE;
os_event_set(lock_sys->timeout_event);
os_event_set(srv_monitor_event);
} else if (STR_EQ(table_name, table_name_len,
S_innodb_tablespace_monitor)) {
srv_print_innodb_tablespace_monitor = TRUE;
os_event_set(lock_sys->timeout_event);
os_event_set(srv_monitor_event);
} else if (STR_EQ(table_name, table_name_len,
S_innodb_table_monitor)) {
srv_print_innodb_table_monitor = TRUE;
os_event_set(lock_sys->timeout_event);
os_event_set(srv_monitor_event);
#ifdef UNIV_MEM_DEBUG
} else if (STR_EQ(table_name, table_name_len,
S_innodb_mem_validate)) {
......
......@@ -1166,7 +1166,7 @@ sync_array_print_long_waits(
(ulong) os_file_n_pending_pwrites);
srv_print_innodb_monitor = TRUE;
os_event_set(lock_sys->timeout_event);
os_event_set(srv_monitor_event);
os_thread_sleep(30000000);
......
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