summaryrefslogtreecommitdiff
path: root/innobase/srv/srv0srv.c
diff options
context:
space:
mode:
authorunknown <vtkachenko@intelp4d.mysql.com>2004-12-24 12:13:32 +0100
committerunknown <vtkachenko@intelp4d.mysql.com>2004-12-24 12:13:32 +0100
commit40d7e74efd94a62ca9d71a24f348e8ea5c3e4790 (patch)
treec26b31d028fae331ef7cf148ca410771f43ef0ef /innobase/srv/srv0srv.c
parent1fabc5de0adaf326e86f01fb93e0e895b12bebe8 (diff)
downloadmariadb-git-40d7e74efd94a62ca9d71a24f348e8ea5c3e4790.tar.gz
logging_ok:
Logging to logging@openlogging.org accepted sql_yacc.yy, sql_parse.cc, sql_lex.h, lex.h: Implements the SHOW MUTEX STATUS command set_var.cc, mysqld.cc, mysql_priv.h: Added new GLOBAL variable timed_mutexes ha_innodb.h: New function innodb_mutex_show_status ha_innodb.cc: Added new innodb variables in SHOW STATUS Implements the SHOW MUTEX STATUS command innodb.test, innodb.result: Added new row_lock_waits status variables tests. variables.test, variables.result: test new variable timed_mutexes ut0ut.c: New function ut_usectime. sync0sync.c: Mutex counting. sync0rw.c: New mutex parameters initialization. srv0srv.c: Counting row lock waits row0sel.c, row0mysql.c: Setting row_lock or table_lock state to thd. que0que.c: Added default no_lock_state to thd. univ.i: Added UNIV_SRV_PRINT_LATCH_WAITS debug define sync0sync.ic: Count mutex using. sync0sync.h: Added new parameters to mutex structure for counting. sync0rw.h: Added new parameters to rw_create_func. srv0srv.h: Added new innodb varuables to SHOW STATUS. que0que.h: Added thread lock states. innobase/include/que0que.h: Added thread lock states. innobase/include/srv0srv.h: Added new innodb varuables to SHOW STATUS. innobase/include/sync0rw.h: Added new parameters to rw_create_func. innobase/include/sync0sync.h: Added new parameters to mutex structure for counting. innobase/include/sync0sync.ic: Count mutex using. innobase/include/univ.i: Added UNIV_SRV_PRINT_LATCH_WAITS debug define innobase/que/que0que.c: Added default no_lock_state to thd. innobase/row/row0mysql.c: Setting row_lock or table_lock state to thd. innobase/row/row0sel.c: Setting row_lock or table_lock state to thd. innobase/srv/srv0srv.c: Counting row lock waits innobase/sync/sync0rw.c: New mutex parameters initialization. innobase/sync/sync0sync.c: Mutex counting. innobase/ut/ut0ut.c: New function ut_usectime. mysql-test/r/variables.result: test new variable timed_mutexes mysql-test/r/innodb.result: Added new row_lock_waits status variables tests. mysql-test/t/variables.test: test new variable timed_mutexes mysql-test/t/innodb.test: Added new row_lock_waits status variables tests. sql/ha_innodb.cc: Added new innodb variables in SHOW STATUS Implements the SHOW MUTEX STATUS command sql/ha_innodb.h: New function innodb_mutex_show_status sql/lex.h: Implements the SHOW MUTEX STATUS command sql/mysql_priv.h: Added new GLOBAL variable timed_mutexes sql/mysqld.cc: Added new GLOBAL variable timed_mutexes sql/set_var.cc: Added new GLOBAL variable timed_mutexes sql/sql_lex.h: Implements the SHOW MUTEX STATUS command sql/sql_parse.cc: Implements the SHOW MUTEX STATUS command sql/sql_yacc.yy: Implements the SHOW MUTEX STATUS command BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
Diffstat (limited to 'innobase/srv/srv0srv.c')
-rw-r--r--innobase/srv/srv0srv.c50
1 files changed, 45 insertions, 5 deletions
diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
index 83d4fb4d39d..aa2a7fa9169 100644
--- a/innobase/srv/srv0srv.c
+++ b/innobase/srv/srv0srv.c
@@ -346,6 +346,12 @@ static ulint srv_n_rows_updated_old = 0;
static ulint srv_n_rows_deleted_old = 0;
static ulint srv_n_rows_read_old = 0;
+ulint srv_n_lock_wait_count= 0;
+ulint srv_n_lock_wait_current_count= 0;
+ib_longlong srv_n_lock_wait_time= 0;
+ulint srv_n_lock_max_wait_time= 0;
+
+
/*
Set the following to 0 if you want InnoDB to write messages on
stderr on startup/shutdown
@@ -1378,7 +1384,11 @@ srv_suspend_mysql_thread(
trx_t* trx;
ibool had_dict_lock = FALSE;
ibool was_declared_inside_innodb = FALSE;
-
+ ib_longlong start_time, finish_time;
+ ulint diff_time;
+ ulint sec;
+ ulint ms;
+
#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&kernel_mutex));
#endif /* UNIV_SYNC_DEBUG */
@@ -1420,7 +1430,15 @@ srv_suspend_mysql_thread(
os_event_reset(event);
slot->suspend_time = ut_time();
+ if (thr->lock_state == QUE_THR_LOCK_ROW)
+ {
+ srv_n_lock_wait_count++;
+ srv_n_lock_wait_current_count++;
+
+ ut_usectime(&sec, &ms);
+ start_time= (ib_longlong)sec * 1000000 + ms;
+ }
/* Wake the lock timeout monitor thread, if it is suspended */
os_event_set(srv_lock_timeout_thread_event);
@@ -1471,7 +1489,22 @@ srv_suspend_mysql_thread(
slot->in_use = FALSE;
wait_time = ut_difftime(ut_time(), slot->suspend_time);
-
+
+ if (thr->lock_state == QUE_THR_LOCK_ROW)
+ {
+ ut_usectime(&sec, &ms);
+ finish_time= (ib_longlong)sec * 1000000 + ms;
+
+ diff_time= finish_time-start_time;
+
+ srv_n_lock_wait_current_count--;
+ srv_n_lock_wait_time= srv_n_lock_wait_time + diff_time;
+ if (diff_time > srv_n_lock_max_wait_time)
+ {
+ srv_n_lock_max_wait_time= diff_time;
+ }
+ }
+
if (trx->was_chosen_as_deadlock_victim) {
trx->error_state = DB_DEADLOCK;
@@ -1689,15 +1722,14 @@ srv_printf_innodb_monitor(
(srv_n_rows_read - srv_n_rows_read_old)
/ time_elapsed);
- srv_n_rows_inserted_old = srv_n_rows_inserted;
+ srv_n_rows_inserted_old = srv_n_rows_inserted;
srv_n_rows_updated_old = srv_n_rows_updated;
srv_n_rows_deleted_old = srv_n_rows_deleted;
srv_n_rows_read_old = srv_n_rows_read;
- fputs("----------------------------\n"
+ fputs("----------------------------\n"
"END OF INNODB MONITOR OUTPUT\n"
"============================\n", file);
-
mutex_exit(&srv_innodb_monitor_mutex);
fflush(file);
}
@@ -1746,11 +1778,19 @@ srv_export_innodb_status(void)
export_vars.innodb_pages_created= buf_pool->n_pages_created;
export_vars.innodb_pages_read= buf_pool->n_pages_read;
export_vars.innodb_pages_written= buf_pool->n_pages_written;
+ export_vars.innodb_row_lock_waits= srv_n_lock_wait_count;
+ export_vars.innodb_row_lock_current_waits= srv_n_lock_wait_current_count;
+ export_vars.innodb_row_lock_time= srv_n_lock_wait_time / 10000;
+ export_vars.innodb_row_lock_time_avg=
+ (srv_n_lock_wait_count > 0) ?
+ (srv_n_lock_wait_time / 10000 / srv_n_lock_wait_count) : 0;
+ export_vars.innodb_row_lock_time_max= srv_n_lock_max_wait_time / 10000;
export_vars.innodb_rows_read= srv_n_rows_read;
export_vars.innodb_rows_inserted= srv_n_rows_inserted;
export_vars.innodb_rows_updated= srv_n_rows_updated;
export_vars.innodb_rows_deleted= srv_n_rows_deleted;
mutex_exit(&srv_innodb_monitor_mutex);
+
}
/*************************************************************************