summaryrefslogtreecommitdiff
path: root/storage/innobase/lock/lock0lock.cc
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay@mariadb.com>2015-02-27 17:36:54 -0500
committerNirbhay Choubey <nirbhay@mariadb.com>2015-02-27 17:36:54 -0500
commitaf651c80f7d7b49a141958a68e81f2de90e62f25 (patch)
treefe6beb28814b0e5a149dde1597463c8fe9faa177 /storage/innobase/lock/lock0lock.cc
parentf02fdb6b55a2b29595cb7e4eed48a51755e967fb (diff)
parent5c66abf0b0de6d632f85a57c841f80d28a7e0337 (diff)
downloadmariadb-git-af651c80f7d7b49a141958a68e81f2de90e62f25.tar.gz
Merge tag 'mariadb-10.0.17' into 10.0-galera
Conflicts: storage/innobase/include/trx0trx.h
Diffstat (limited to 'storage/innobase/lock/lock0lock.cc')
-rw-r--r--storage/innobase/lock/lock0lock.cc46
1 files changed, 45 insertions, 1 deletions
diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc
index 914b7f42f10..66033530a72 100644
--- a/storage/innobase/lock/lock0lock.cc
+++ b/storage/innobase/lock/lock0lock.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2014, 2015, MariaDB Corporation
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -2044,6 +2045,9 @@ lock_rec_create(
/* Set the bit corresponding to rec */
lock_rec_set_nth_bit(lock, heap_no);
+ lock->requested_time = ut_time();
+ lock->wait_time = 0;
+
index->table->n_rec_locks++;
ut_ad(index->table->n_ref_count > 0 || !index->table->can_be_evicted);
@@ -2276,6 +2280,8 @@ lock_rec_enqueue_waiting(
MONITOR_INC(MONITOR_LOCKREC_WAIT);
+ trx->n_rec_lock_waits++;
+
return(DB_LOCK_WAIT);
}
@@ -2308,7 +2314,8 @@ lock_rec_add_to_queue(
ut_ad(lock_mutex_own());
ut_ad(caller_owns_trx_mutex == trx_mutex_own(trx));
- ut_ad(dict_index_is_clust(index) || !dict_index_is_online_ddl(index));
+ ut_ad(dict_index_is_clust(index)
+ || dict_index_get_online_status(index) != ONLINE_INDEX_CREATION);
#ifdef UNIV_DEBUG
switch (type_mode & LOCK_MODE_MASK) {
case LOCK_X:
@@ -2749,6 +2756,17 @@ lock_grant(
}
}
+ /* Cumulate total lock wait time for statistics */
+ if (lock_get_type_low(lock) & LOCK_TABLE) {
+ lock->trx->total_table_lock_wait_time +=
+ (ulint)difftime(ut_time(), lock->trx->lock.wait_started);
+ } else {
+ lock->trx->total_rec_lock_wait_time +=
+ (ulint)difftime(ut_time(), lock->trx->lock.wait_started);
+ }
+
+ lock->wait_time = (ulint)difftime(ut_time(), lock->requested_time);
+
trx_mutex_exit(lock->trx);
}
@@ -4540,6 +4558,8 @@ lock_table_create(
lock->type_mode = type_mode | LOCK_TABLE;
lock->trx = trx;
+ lock->requested_time = ut_time();
+ lock->wait_time = 0;
lock->un_member.tab_lock.table = table;
@@ -4845,6 +4865,7 @@ lock_table_enqueue_waiting(
trx->lock.wait_started = ut_time();
trx->lock.was_chosen_as_deadlock_victim = FALSE;
+ trx->n_table_lock_waits++;
ut_a(que_thr_stop(thr));
@@ -5552,6 +5573,10 @@ lock_table_print(
fputs(" waiting", file);
}
+ fprintf(file, " lock hold time %lu wait time before grant %lu ",
+ (ulint)difftime(ut_time(), lock->requested_time),
+ lock->wait_time);
+
putc('\n', file);
}
@@ -5583,7 +5608,14 @@ lock_rec_print(
fprintf(file, "RECORD LOCKS space id %lu page no %lu n bits %lu ",
(ulong) space, (ulong) page_no,
(ulong) lock_rec_get_n_bits(lock));
+
dict_index_name_print(file, lock->trx, lock->index);
+
+ /* Print number of table locks */
+ fprintf(file, " trx table locks %lu total table locks %lu ",
+ ib_vector_size(lock->trx->lock.table_locks),
+ UT_LIST_GET_LEN(lock->index->table->locks));
+
fprintf(file, " trx id " TRX_ID_FMT, lock->trx->id);
if (lock_get_mode(lock) == LOCK_S) {
@@ -5612,6 +5644,10 @@ lock_rec_print(
mtr_start(&mtr);
+ fprintf(file, " lock hold time %lu wait time before grant %lu ",
+ (ulint)difftime(ut_time(), lock->requested_time),
+ lock->wait_time);
+
putc('\n', file);
block = buf_page_try_get(space, page_no, &mtr);
@@ -5870,6 +5906,14 @@ loop:
trx->read_view->up_limit_id);
}
+ /* Total trx lock waits and times */
+ fprintf(file, "Trx #rec lock waits %lu #table lock waits %lu\n",
+ trx->n_rec_lock_waits, trx->n_table_lock_waits);
+ fprintf(file, "Trx total rec lock wait time %lu SEC\n",
+ trx->total_rec_lock_wait_time);
+ fprintf(file, "Trx total table lock wait time %lu SEC\n",
+ trx->total_table_lock_wait_time);
+
if (trx->lock.que_state == TRX_QUE_LOCK_WAIT) {
fprintf(file,