lock_utime= (thd->utime_after_lock - thd->start_utime);
void set_time_after_lock()
{
utime_after_lock= my_micro_time();
MYSQL_SET_STATEMENT_LOCK_TIME(m_statement_psi, (utime_after_lock - start_utime));
}
void thd_storage_lock_wait(THD *thd, long long value)
{
thd->utime_after_lock+= value;
}
/**
Return time in microseconds.
@remark This function is to be used to measure performance in
micro seconds.
@retval Number of microseconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC)
*/
ulonglong my_micro_time()
MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, size_t count, uint flags)
{
int rc;
MYSQL_LOCK *sql_lock;
ulong timeout= (flags & MYSQL_LOCK_IGNORE_TIMEOUT) ?
LONG_TIMEOUT : thd->variables.lock_wait_timeout;
DBUG_ENTER("mysql_lock_tables");
if (lock_tables_check(thd, tables, count, flags))
DBUG_RETURN(NULL);
if (! (sql_lock= get_lock_data(thd, tables, count, GET_LOCK_STORE_LOCKS)))
DBUG_RETURN(NULL);
THD_STAGE_INFO(thd, stage_system_lock);
DBUG_PRINT("info", ("thd->proc_info %s", thd->proc_info));
if (sql_lock->table_count && lock_external(thd, sql_lock->table,
sql_lock->table_count))
{
/* Clear the lock type of all lock data to avoid reusage. */
reset_lock_data_and_free(&sql_lock);
goto end;
}
/* Copy the lock data array. thr_multi_lock() reorders its contents. */
memcpy(sql_lock->locks + sql_lock->lock_count, sql_lock->locks,
sql_lock->lock_count * sizeof(*sql_lock->locks));
/* Lock on the copied half of the lock data array. */
rc= thr_lock_errno_to_mysql[(int) thr_multi_lock(sql_lock->locks +
sql_lock->lock_count,
sql_lock->lock_count,
&thd->lock_info, timeout)];
DBUG_EXECUTE_IF("mysql_lock_tables_kill_query",
thd->killed= THD::KILL_QUERY;);
if (rc)
{
if (sql_lock->table_count)
(void) unlock_external(thd, sql_lock->table, sql_lock->table_count);
reset_lock_data_and_free(&sql_lock);
if (! thd->killed)
my_error(rc, MYF(0));
}
end:
if (!(flags & MYSQL_OPEN_IGNORE_KILLED) && thd->killed)
{
thd->send_kill_message();
if (sql_lock)
{
mysql_unlock_tables(thd, sql_lock);
sql_lock= 0;
}
}
if (thd->variables.session_track_transaction_info > TX_TRACK_NONE)
track_table_access(thd, tables, count);
thd->set_time_after_lock();
DBUG_RETURN(sql_lock);
}
MySQL中为什么慢日志中的select 的lock time也有值?
猜你喜欢
转载自blog.csdn.net/aoerqileng/article/details/105266506
今日推荐
周排行