mirror of
https://github.com/MariaDB/server.git
synced 2025-02-17 02:45:33 +01:00
Added more wait states for THD wait service
This commit is contained in:
parent
f703a7779f
commit
1c0d998a12
8 changed files with 54 additions and 12 deletions
include/mysql
sql
storage/innobase/srv
|
@ -33,10 +33,16 @@ MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
|
||||||
int allocate_lex_string);
|
int allocate_lex_string);
|
||||||
#include <mysql/service_thd_wait.h>
|
#include <mysql/service_thd_wait.h>
|
||||||
typedef enum _thd_wait_type_e {
|
typedef enum _thd_wait_type_e {
|
||||||
THD_WAIT_MUTEX= 1,
|
THD_WAIT_SLEEP= 1,
|
||||||
THD_WAIT_DISKIO= 2,
|
THD_WAIT_DISKIO= 2,
|
||||||
THD_WAIT_ROW_TABLE_LOCK= 3,
|
THD_WAIT_ROW_LOCK= 3,
|
||||||
THD_WAIT_GLOBAL_LOCK= 4
|
THD_WAIT_GLOBAL_LOCK= 4,
|
||||||
|
THD_WAIT_META_DATA_LOCK= 5,
|
||||||
|
THD_WAIT_TABLE_LOCK= 6,
|
||||||
|
THD_WAIT_USER_LOCK= 7,
|
||||||
|
THD_WAIT_BINLOG= 8,
|
||||||
|
THD_WAIT_GROUP_COMMIT= 9,
|
||||||
|
THD_WAIT_LAST= 10
|
||||||
} thd_wait_type;
|
} thd_wait_type;
|
||||||
extern struct thd_wait_service_st {
|
extern struct thd_wait_service_st {
|
||||||
void (*thd_wait_begin_func)(void*, thd_wait_type);
|
void (*thd_wait_begin_func)(void*, thd_wait_type);
|
||||||
|
|
|
@ -33,10 +33,16 @@ MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
|
||||||
int allocate_lex_string);
|
int allocate_lex_string);
|
||||||
#include <mysql/service_thd_wait.h>
|
#include <mysql/service_thd_wait.h>
|
||||||
typedef enum _thd_wait_type_e {
|
typedef enum _thd_wait_type_e {
|
||||||
THD_WAIT_MUTEX= 1,
|
THD_WAIT_SLEEP= 1,
|
||||||
THD_WAIT_DISKIO= 2,
|
THD_WAIT_DISKIO= 2,
|
||||||
THD_WAIT_ROW_TABLE_LOCK= 3,
|
THD_WAIT_ROW_LOCK= 3,
|
||||||
THD_WAIT_GLOBAL_LOCK= 4
|
THD_WAIT_GLOBAL_LOCK= 4,
|
||||||
|
THD_WAIT_META_DATA_LOCK= 5,
|
||||||
|
THD_WAIT_TABLE_LOCK= 6,
|
||||||
|
THD_WAIT_USER_LOCK= 7,
|
||||||
|
THD_WAIT_BINLOG= 8,
|
||||||
|
THD_WAIT_GROUP_COMMIT= 9,
|
||||||
|
THD_WAIT_LAST= 10
|
||||||
} thd_wait_type;
|
} thd_wait_type;
|
||||||
extern struct thd_wait_service_st {
|
extern struct thd_wait_service_st {
|
||||||
void (*thd_wait_begin_func)(void*, thd_wait_type);
|
void (*thd_wait_begin_func)(void*, thd_wait_type);
|
||||||
|
|
|
@ -51,10 +51,16 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum _thd_wait_type_e {
|
typedef enum _thd_wait_type_e {
|
||||||
THD_WAIT_MUTEX= 1,
|
THD_WAIT_SLEEP= 1,
|
||||||
THD_WAIT_DISKIO= 2,
|
THD_WAIT_DISKIO= 2,
|
||||||
THD_WAIT_ROW_TABLE_LOCK= 3,
|
THD_WAIT_ROW_LOCK= 3,
|
||||||
THD_WAIT_GLOBAL_LOCK= 4
|
THD_WAIT_GLOBAL_LOCK= 4,
|
||||||
|
THD_WAIT_META_DATA_LOCK= 5,
|
||||||
|
THD_WAIT_TABLE_LOCK= 6,
|
||||||
|
THD_WAIT_USER_LOCK= 7,
|
||||||
|
THD_WAIT_BINLOG= 8,
|
||||||
|
THD_WAIT_GROUP_COMMIT= 9,
|
||||||
|
THD_WAIT_LAST= 10
|
||||||
} thd_wait_type;
|
} thd_wait_type;
|
||||||
|
|
||||||
extern struct thd_wait_service_st {
|
extern struct thd_wait_service_st {
|
||||||
|
|
|
@ -52,6 +52,8 @@
|
||||||
#include "sp.h"
|
#include "sp.h"
|
||||||
#include "set_var.h"
|
#include "set_var.h"
|
||||||
#include "debug_sync.h"
|
#include "debug_sync.h"
|
||||||
|
#include <mysql/plugin.h>
|
||||||
|
#include <mysql/service_thd_wait.h>
|
||||||
|
|
||||||
#ifdef NO_EMBEDDED_ACCESS_CHECKS
|
#ifdef NO_EMBEDDED_ACCESS_CHECKS
|
||||||
#define sp_restore_security_context(A,B) while (0) {}
|
#define sp_restore_security_context(A,B) while (0) {}
|
||||||
|
@ -3802,7 +3804,9 @@ longlong Item_func_get_lock::val_int()
|
||||||
while (ull->locked && !thd->killed)
|
while (ull->locked && !thd->killed)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("waiting on lock"));
|
DBUG_PRINT("info", ("waiting on lock"));
|
||||||
|
thd_wait_begin(thd, THD_WAIT_USER_LOCK);
|
||||||
error= interruptible_wait(thd, &ull->cond, &LOCK_user_locks, timeout);
|
error= interruptible_wait(thd, &ull->cond, &LOCK_user_locks, timeout);
|
||||||
|
thd_wait_end(thd);
|
||||||
if (error == ETIMEDOUT || error == ETIME)
|
if (error == ETIMEDOUT || error == ETIME)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("lock wait timeout"));
|
DBUG_PRINT("info", ("lock wait timeout"));
|
||||||
|
@ -4026,7 +4030,9 @@ longlong Item_func_sleep::val_int()
|
||||||
error= 0;
|
error= 0;
|
||||||
while (!thd->killed)
|
while (!thd->killed)
|
||||||
{
|
{
|
||||||
|
thd_wait_begin(thd, THD_WAIT_SLEEP);
|
||||||
error= interruptible_wait(thd, &cond, &LOCK_user_locks, timeout);
|
error= interruptible_wait(thd, &cond, &LOCK_user_locks, timeout);
|
||||||
|
thd_wait_end(thd);
|
||||||
if (error == ETIMEDOUT || error == ETIME)
|
if (error == ETIMEDOUT || error == ETIME)
|
||||||
break;
|
break;
|
||||||
error= 0;
|
error= 0;
|
||||||
|
|
12
sql/lock.cc
12
sql/lock.cc
|
@ -82,6 +82,8 @@
|
||||||
#include "sql_acl.h" // SUPER_ACL
|
#include "sql_acl.h" // SUPER_ACL
|
||||||
#include <hash.h>
|
#include <hash.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <mysql/plugin.h>
|
||||||
|
#include <mysql/service_thd_wait.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@defgroup Locking Locking
|
@defgroup Locking Locking
|
||||||
|
@ -1019,7 +1021,11 @@ bool Global_read_lock::lock_global_read_lock(THD *thd)
|
||||||
|
|
||||||
waiting_for_read_lock++;
|
waiting_for_read_lock++;
|
||||||
while (protect_against_global_read_lock && !thd->killed)
|
while (protect_against_global_read_lock && !thd->killed)
|
||||||
|
{
|
||||||
|
thd_wait_begin(thd, THD_WAIT_GLOBAL_LOCK);
|
||||||
mysql_cond_wait(&COND_global_read_lock, &LOCK_global_read_lock);
|
mysql_cond_wait(&COND_global_read_lock, &LOCK_global_read_lock);
|
||||||
|
thd_wait_end(thd);
|
||||||
|
}
|
||||||
waiting_for_read_lock--;
|
waiting_for_read_lock--;
|
||||||
if (thd->killed)
|
if (thd->killed)
|
||||||
{
|
{
|
||||||
|
@ -1187,7 +1193,9 @@ wait_if_global_read_lock(THD *thd, bool abort_on_refresh,
|
||||||
thd->open_tables->s->version == refresh_version))
|
thd->open_tables->s->version == refresh_version))
|
||||||
{
|
{
|
||||||
DBUG_PRINT("signal", ("Waiting for COND_global_read_lock"));
|
DBUG_PRINT("signal", ("Waiting for COND_global_read_lock"));
|
||||||
|
thd_wait_begin(thd, THD_WAIT_GLOBAL_LOCK);
|
||||||
mysql_cond_wait(&COND_global_read_lock, &LOCK_global_read_lock);
|
mysql_cond_wait(&COND_global_read_lock, &LOCK_global_read_lock);
|
||||||
|
thd_wait_end(thd);
|
||||||
DBUG_PRINT("signal", ("Got COND_global_read_lock"));
|
DBUG_PRINT("signal", ("Got COND_global_read_lock"));
|
||||||
}
|
}
|
||||||
if (thd->killed)
|
if (thd->killed)
|
||||||
|
@ -1285,7 +1293,11 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd)
|
||||||
old_message= thd->enter_cond(&COND_global_read_lock, &LOCK_global_read_lock,
|
old_message= thd->enter_cond(&COND_global_read_lock, &LOCK_global_read_lock,
|
||||||
"Waiting for all running commits to finish");
|
"Waiting for all running commits to finish");
|
||||||
while (protect_against_global_read_lock && !thd->killed)
|
while (protect_against_global_read_lock && !thd->killed)
|
||||||
|
{
|
||||||
|
thd_wait_begin(thd, THD_WAIT_GLOBAL_LOCK);
|
||||||
mysql_cond_wait(&COND_global_read_lock, &LOCK_global_read_lock);
|
mysql_cond_wait(&COND_global_read_lock, &LOCK_global_read_lock);
|
||||||
|
thd_wait_end(thd);
|
||||||
|
}
|
||||||
DBUG_EXECUTE_IF("make_global_read_lock_block_commit_loop",
|
DBUG_EXECUTE_IF("make_global_read_lock_block_commit_loop",
|
||||||
protect_against_global_read_lock--;);
|
protect_against_global_read_lock--;);
|
||||||
if ((error= test(thd->killed)))
|
if ((error= test(thd->killed)))
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include "debug_sync.h"
|
#include "debug_sync.h"
|
||||||
#include <hash.h>
|
#include <hash.h>
|
||||||
#include <mysqld_error.h>
|
#include <mysqld_error.h>
|
||||||
|
#include <mysql/plugin.h>
|
||||||
|
#include <mysql/service_thd_wait.h>
|
||||||
|
|
||||||
#ifdef HAVE_PSI_INTERFACE
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
static PSI_mutex_key key_MDL_map_mutex;
|
static PSI_mutex_key key_MDL_map_mutex;
|
||||||
|
@ -991,8 +993,12 @@ MDL_wait::timed_wait(THD *thd, struct timespec *abs_timeout,
|
||||||
|
|
||||||
while (!m_wait_status && !thd_killed(thd) &&
|
while (!m_wait_status && !thd_killed(thd) &&
|
||||||
wait_result != ETIMEDOUT && wait_result != ETIME)
|
wait_result != ETIMEDOUT && wait_result != ETIME)
|
||||||
|
{
|
||||||
|
thd_wait_begin(thd, THD_WAIT_META_DATA_LOCK);
|
||||||
wait_result= mysql_cond_timedwait(&m_COND_wait_status, &m_LOCK_wait_status,
|
wait_result= mysql_cond_timedwait(&m_COND_wait_status, &m_LOCK_wait_status,
|
||||||
abs_timeout);
|
abs_timeout);
|
||||||
|
thd_wait_end(thd);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_wait_status == EMPTY)
|
if (m_wait_status == EMPTY)
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,7 +82,7 @@ scheduler_functions *thread_scheduler= NULL;
|
||||||
/**@{*/
|
/**@{*/
|
||||||
static void scheduler_wait_begin(void) {
|
static void scheduler_wait_begin(void) {
|
||||||
MYSQL_CALLBACK(thread_scheduler,
|
MYSQL_CALLBACK(thread_scheduler,
|
||||||
thd_wait_begin, (current_thd, THD_WAIT_ROW_TABLE_LOCK));
|
thd_wait_begin, (current_thd, THD_WAIT_TABLE_LOCK));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scheduler_wait_end(void) {
|
static void scheduler_wait_end(void) {
|
||||||
|
|
|
@ -1234,7 +1234,7 @@ retry:
|
||||||
|
|
||||||
trx->op_info = "waiting in InnoDB queue";
|
trx->op_info = "waiting in InnoDB queue";
|
||||||
|
|
||||||
thd_wait_begin(trx->mysql_thd, THD_WAIT_ROW_TABLE_LOCK);
|
thd_wait_begin(trx->mysql_thd, THD_WAIT_USER_LOCK);
|
||||||
os_event_wait(slot->event);
|
os_event_wait(slot->event);
|
||||||
thd_wait_end(trx->mysql_thd);
|
thd_wait_end(trx->mysql_thd);
|
||||||
|
|
||||||
|
@ -1601,7 +1601,7 @@ srv_suspend_mysql_thread(
|
||||||
|
|
||||||
/* Suspend this thread and wait for the event. */
|
/* Suspend this thread and wait for the event. */
|
||||||
|
|
||||||
thd_wait_begin(trx->mysql_thd, THD_WAIT_ROW_TABLE_LOCK);
|
thd_wait_begin(trx->mysql_thd, THD_WAIT_ROW_LOCK);
|
||||||
os_event_wait(event);
|
os_event_wait(event);
|
||||||
thd_wait_end(trx->mysql_thd);
|
thd_wait_end(trx->mysql_thd);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue