summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Yang <jimmy.yang@oracle.com>2010-08-17 01:19:24 -0700
committerJimmy Yang <jimmy.yang@oracle.com>2010-08-17 01:19:24 -0700
commitb17b122b7daa2f6fbc04ab7a32269d6f2d22cbfe (patch)
treeb34b13dad93e31f86abd6e9768f89d76c0b121b2
parent524e0dc4d54205bebf7bd5d590246c215f0fb801 (diff)
downloadmariadb-git-b17b122b7daa2f6fbc04ab7a32269d6f2d22cbfe.tar.gz
Fix bug #53496 Use Lock_time in slow query log output for InnoDB row
lock wait time. Including the InnoDB lock time in the exiting "Lock_time" output.
-rw-r--r--include/mysql/plugin.h1
-rw-r--r--include/mysql/plugin.h.pp1
-rw-r--r--sql/sql_class.cc5
-rw-r--r--sql/sql_class.h2
-rw-r--r--storage/innobase/handler/ha_innodb.cc14
-rw-r--r--storage/innobase/include/ha_prototypes.h8
-rw-r--r--storage/innobase/srv/srv0srv.c3
7 files changed, 33 insertions, 1 deletions
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index 19cf0ed050d..15f7d785ead 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -528,6 +528,7 @@ long long thd_test_options(const MYSQL_THD thd, long long test_options);
int thd_sql_command(const MYSQL_THD thd);
const char *thd_proc_info(MYSQL_THD thd, const char *info);
void **thd_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
+void thd_storage_lock_wait(MYSQL_THD thd, long long value);
int thd_tx_isolation(const MYSQL_THD thd);
char *thd_security_context(MYSQL_THD thd, char *buffer, unsigned int length,
unsigned int max_query_len);
diff --git a/include/mysql/plugin.h.pp b/include/mysql/plugin.h.pp
index 3a1b03742da..9d2877be5a2 100644
--- a/include/mysql/plugin.h.pp
+++ b/include/mysql/plugin.h.pp
@@ -154,6 +154,7 @@ long long thd_test_options(const void* thd, long long test_options);
int thd_sql_command(const void* thd);
const char *thd_proc_info(void* thd, const char *info);
void **thd_ha_data(const void* thd, const struct handlerton *hton);
+void thd_storage_lock_wait(void* thd, long long value);
int thd_tx_isolation(const void* thd);
char *thd_security_context(void* thd, char *buffer, unsigned int length,
unsigned int max_query_len);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 1bec02afa96..28e86ecc67f 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -307,6 +307,11 @@ void **thd_ha_data(const THD *thd, const struct handlerton *hton)
return (void **) &thd->ha_data[hton->slot].ha_ptr;
}
+extern "C"
+void thd_storage_lock_wait(THD *thd, long long value)
+{
+ thd->utime_after_lock+= value;
+}
/**
Provide a handler data getter to simplify coding
diff --git a/sql/sql_class.h b/sql/sql_class.h
index c095fee6232..b135af41af0 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1505,7 +1505,7 @@ public:
// track down slow pthread_create
ulonglong prior_thr_create_utime, thr_create_utime;
ulonglong start_utime, utime_after_lock;
-
+
thr_lock_type update_lock_default;
Delayed_insert *di;
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index e78f167beb6..a004cba9603 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -807,6 +807,20 @@ thd_lock_wait_timeout(
return(THDVAR((THD*) thd, lock_wait_timeout));
}
+/******************************************************************//**
+Set the time waited for the lock for the current query. */
+extern "C" UNIV_INTERN
+void
+thd_set_lock_wait_time(
+/*===================*/
+ void* thd, /*!< in: thread handle (THD*) */
+ ulint value) /*!< in: time waited for the lock */
+{
+ if (thd) {
+ thd_storage_lock_wait((THD*)thd, value);
+ }
+}
+
/********************************************************************//**
Obtain the InnoDB transaction of a MySQL thread.
@return reference to transaction pointer */
diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h
index a9ee1d66b99..b75002944bd 100644
--- a/storage/innobase/include/ha_prototypes.h
+++ b/storage/innobase/include/ha_prototypes.h
@@ -267,5 +267,13 @@ thd_lock_wait_timeout(
/*==================*/
void* thd); /*!< in: thread handle (THD*), or NULL to query
the global innodb_lock_wait_timeout */
+/******************************************************************//**
+Add up the time waited for the lock for the current query. */
+UNIV_INTERN
+void
+thd_set_lock_wait_time(
+/*===================*/
+ void* thd, /*!< in: thread handle (THD*) */
+ ulint value); /*!< in: time waited for the lock */
#endif
diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c
index 97d699dde99..bea8d7f8fdc 100644
--- a/storage/innobase/srv/srv0srv.c
+++ b/storage/innobase/srv/srv0srv.c
@@ -1643,6 +1643,9 @@ srv_suspend_mysql_thread(
start_time != -1 && finish_time != -1) {
srv_n_lock_max_wait_time = diff_time;
}
+
+ /* Record the lock wait time for this thread */
+ thd_set_lock_wait_time(trx->mysql_thd, diff_time);
}
if (trx->was_chosen_as_deadlock_victim) {