Commit da24a208 authored by Jimmy Yang's avatar Jimmy Yang

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.
parent 15fd2b4f
...@@ -528,6 +528,7 @@ long long thd_test_options(const MYSQL_THD thd, long long test_options); ...@@ -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); int thd_sql_command(const MYSQL_THD thd);
const char *thd_proc_info(MYSQL_THD thd, const char *info); 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_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); int thd_tx_isolation(const MYSQL_THD thd);
char *thd_security_context(MYSQL_THD thd, char *buffer, unsigned int length, char *thd_security_context(MYSQL_THD thd, char *buffer, unsigned int length,
unsigned int max_query_len); unsigned int max_query_len);
......
...@@ -154,6 +154,7 @@ long long thd_test_options(const void* thd, long long test_options); ...@@ -154,6 +154,7 @@ long long thd_test_options(const void* thd, long long test_options);
int thd_sql_command(const void* thd); int thd_sql_command(const void* thd);
const char *thd_proc_info(void* thd, const char *info); const char *thd_proc_info(void* thd, const char *info);
void **thd_ha_data(const void* thd, const struct handlerton *hton); 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); int thd_tx_isolation(const void* thd);
char *thd_security_context(void* thd, char *buffer, unsigned int length, char *thd_security_context(void* thd, char *buffer, unsigned int length,
unsigned int max_query_len); unsigned int max_query_len);
......
...@@ -307,6 +307,11 @@ void **thd_ha_data(const THD *thd, const struct handlerton *hton) ...@@ -307,6 +307,11 @@ void **thd_ha_data(const THD *thd, const struct handlerton *hton)
return (void **) &thd->ha_data[hton->slot].ha_ptr; 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 Provide a handler data getter to simplify coding
......
...@@ -807,6 +807,20 @@ thd_lock_wait_timeout( ...@@ -807,6 +807,20 @@ thd_lock_wait_timeout(
return(THDVAR((THD*) 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. Obtain the InnoDB transaction of a MySQL thread.
@return reference to transaction pointer */ @return reference to transaction pointer */
......
...@@ -267,5 +267,13 @@ thd_lock_wait_timeout( ...@@ -267,5 +267,13 @@ thd_lock_wait_timeout(
/*==================*/ /*==================*/
void* thd); /*!< in: thread handle (THD*), or NULL to query void* thd); /*!< in: thread handle (THD*), or NULL to query
the global innodb_lock_wait_timeout */ 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 #endif
...@@ -1643,6 +1643,9 @@ srv_suspend_mysql_thread( ...@@ -1643,6 +1643,9 @@ srv_suspend_mysql_thread(
start_time != -1 && finish_time != -1) { start_time != -1 && finish_time != -1) {
srv_n_lock_max_wait_time = diff_time; 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) { if (trx->was_chosen_as_deadlock_victim) {
......
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