summaryrefslogtreecommitdiff
path: root/storage/innobase/srv/srv0mon.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-01-26 16:39:56 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2021-01-27 15:45:39 +0200
commite71e6133535da8d5eab86e504f0b116a03680780 (patch)
tree160adf5e0ded57571fa18e376534953f2602d1e8 /storage/innobase/srv/srv0mon.cc
parent7f1ab8f742ac42e82dd39a6e11390254cb72319c (diff)
downloadmariadb-git-e71e6133535da8d5eab86e504f0b116a03680780.tar.gz
MDEV-24671: Replace lock_wait_timeout_task with mysql_cond_timedwait()
lock_wait(): Replaces lock_wait_suspend_thread(). Wait for the lock to be granted or the transaction to be killed using mysql_cond_timedwait() or mysql_cond_wait(). lock_wait_end(): Replaces que_thr_end_lock_wait() and lock_wait_release_thread_if_suspended(). lock_wait_timeout_task: Remove. The operating system kernel will resume the mysql_cond_timedwait() in lock_wait(). An added benefit is that innodb_lock_wait_timeout no longer has a 'jitter' of 1 second, which was caused by this wake-up task waking up only once per second, and then waking up any threads for which the timeout (which was only measured in seconds) was exceeded. innobase_kill_query(): Set trx->error_state=DB_INTERRUPTED, so that a call trx_is_interrupted(trx) in lock_wait() can be avoided. We will protect things more consistently with lock_sys.wait_mutex, which will be moved below lock_sys.mutex in the latching order. trx_lock_t::cond: Condition variable for !wait_lock, used with lock_sys.wait_mutex. srv_slot_t: Remove. Replaced by trx_lock_t::cond, lock_grant_after_reset(): Merged to to lock_grant(). lock_rec_get_index_name(): Remove. lock_sys_t: Introduce wait_pending, wait_count, wait_time, wait_time_max that are protected by wait_mutex. trx_lock_t::que_state: Remove. que_thr_state_t: Remove QUE_THR_COMMAND_WAIT, QUE_THR_LOCK_WAIT. que_thr_t: Remove is_active, start_running(), stop_no_error(). que_fork_t::n_active_thrs, trx_lock_t::n_active_thrs: Remove.
Diffstat (limited to 'storage/innobase/srv/srv0mon.cc')
-rw-r--r--storage/innobase/srv/srv0mon.cc20
1 files changed, 13 insertions, 7 deletions
diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc
index febbfa089f6..4ccd0adb360 100644
--- a/storage/innobase/srv/srv0mon.cc
+++ b/storage/innobase/srv/srv0mon.cc
@@ -1719,32 +1719,38 @@ srv_mon_process_existing_counter(
/* innodb_row_lock_current_waits */
case MONITOR_OVLD_ROW_LOCK_CURRENT_WAIT:
- value = srv_stats.n_lock_wait_current_count;
+ // dirty read without lock_sys.wait_mutex
+ value = lock_sys.get_wait_pending();
break;
/* innodb_row_lock_time */
case MONITOR_OVLD_LOCK_WAIT_TIME:
- value = srv_stats.n_lock_wait_time / 1000;
+ // dirty read without lock_sys.wait_mutex
+ value = lock_sys.get_wait_time_cumulative() / 1000;
break;
/* innodb_row_lock_time_max */
case MONITOR_OVLD_LOCK_MAX_WAIT_TIME:
- value = lock_sys.n_lock_max_wait_time / 1000;
+ // dirty read without lock_sys.wait_mutex
+ value = lock_sys.get_wait_time_max() / 1000;
break;
/* innodb_row_lock_time_avg */
case MONITOR_OVLD_LOCK_AVG_WAIT_TIME:
- if (srv_stats.n_lock_wait_count > 0) {
- value = srv_stats.n_lock_wait_time / 1000
- / srv_stats.n_lock_wait_count;
+ mysql_mutex_lock(&lock_sys.wait_mutex);
+ if (auto count = lock_sys.get_wait_cumulative()) {
+ value = lock_sys.get_wait_time_cumulative() / 1000
+ / count;
} else {
value = 0;
}
+ mysql_mutex_unlock(&lock_sys.wait_mutex);
break;
/* innodb_row_lock_waits */
case MONITOR_OVLD_ROW_LOCK_WAIT:
- value = srv_stats.n_lock_wait_count;
+ // dirty read without lock_sys.wait_mutex
+ value = lock_sys.get_wait_cumulative();
break;
case MONITOR_RSEG_HISTORY_LEN: