mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 18:20:07 +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
|
@ -33,10 +33,16 @@ MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
|
|||
int allocate_lex_string);
|
||||
#include <mysql/service_thd_wait.h>
|
||||
typedef enum _thd_wait_type_e {
|
||||
THD_WAIT_MUTEX= 1,
|
||||
THD_WAIT_SLEEP= 1,
|
||||
THD_WAIT_DISKIO= 2,
|
||||
THD_WAIT_ROW_TABLE_LOCK= 3,
|
||||
THD_WAIT_GLOBAL_LOCK= 4
|
||||
THD_WAIT_ROW_LOCK= 3,
|
||||
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;
|
||||
extern struct thd_wait_service_st {
|
||||
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);
|
||||
#include <mysql/service_thd_wait.h>
|
||||
typedef enum _thd_wait_type_e {
|
||||
THD_WAIT_MUTEX= 1,
|
||||
THD_WAIT_SLEEP= 1,
|
||||
THD_WAIT_DISKIO= 2,
|
||||
THD_WAIT_ROW_TABLE_LOCK= 3,
|
||||
THD_WAIT_GLOBAL_LOCK= 4
|
||||
THD_WAIT_ROW_LOCK= 3,
|
||||
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;
|
||||
extern struct thd_wait_service_st {
|
||||
void (*thd_wait_begin_func)(void*, thd_wait_type);
|
||||
|
|
|
@ -51,10 +51,16 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
typedef enum _thd_wait_type_e {
|
||||
THD_WAIT_MUTEX= 1,
|
||||
THD_WAIT_SLEEP= 1,
|
||||
THD_WAIT_DISKIO= 2,
|
||||
THD_WAIT_ROW_TABLE_LOCK= 3,
|
||||
THD_WAIT_GLOBAL_LOCK= 4
|
||||
THD_WAIT_ROW_LOCK= 3,
|
||||
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;
|
||||
|
||||
extern struct thd_wait_service_st {
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
#include "sp.h"
|
||||
#include "set_var.h"
|
||||
#include "debug_sync.h"
|
||||
#include <mysql/plugin.h>
|
||||
#include <mysql/service_thd_wait.h>
|
||||
|
||||
#ifdef NO_EMBEDDED_ACCESS_CHECKS
|
||||
#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)
|
||||
{
|
||||
DBUG_PRINT("info", ("waiting on lock"));
|
||||
thd_wait_begin(thd, THD_WAIT_USER_LOCK);
|
||||
error= interruptible_wait(thd, &ull->cond, &LOCK_user_locks, timeout);
|
||||
thd_wait_end(thd);
|
||||
if (error == ETIMEDOUT || error == ETIME)
|
||||
{
|
||||
DBUG_PRINT("info", ("lock wait timeout"));
|
||||
|
@ -4026,7 +4030,9 @@ longlong Item_func_sleep::val_int()
|
|||
error= 0;
|
||||
while (!thd->killed)
|
||||
{
|
||||
thd_wait_begin(thd, THD_WAIT_SLEEP);
|
||||
error= interruptible_wait(thd, &cond, &LOCK_user_locks, timeout);
|
||||
thd_wait_end(thd);
|
||||
if (error == ETIMEDOUT || error == ETIME)
|
||||
break;
|
||||
error= 0;
|
||||
|
|
12
sql/lock.cc
12
sql/lock.cc
|
@ -82,6 +82,8 @@
|
|||
#include "sql_acl.h" // SUPER_ACL
|
||||
#include <hash.h>
|
||||
#include <assert.h>
|
||||
#include <mysql/plugin.h>
|
||||
#include <mysql/service_thd_wait.h>
|
||||
|
||||
/**
|
||||
@defgroup Locking Locking
|
||||
|
@ -1019,7 +1021,11 @@ bool Global_read_lock::lock_global_read_lock(THD *thd)
|
|||
|
||||
waiting_for_read_lock++;
|
||||
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);
|
||||
thd_wait_end(thd);
|
||||
}
|
||||
waiting_for_read_lock--;
|
||||
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))
|
||||
{
|
||||
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);
|
||||
thd_wait_end(thd);
|
||||
DBUG_PRINT("signal", ("Got COND_global_read_lock"));
|
||||
}
|
||||
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,
|
||||
"Waiting for all running commits to finish");
|
||||
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);
|
||||
thd_wait_end(thd);
|
||||
}
|
||||
DBUG_EXECUTE_IF("make_global_read_lock_block_commit_loop",
|
||||
protect_against_global_read_lock--;);
|
||||
if ((error= test(thd->killed)))
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include "debug_sync.h"
|
||||
#include <hash.h>
|
||||
#include <mysqld_error.h>
|
||||
#include <mysql/plugin.h>
|
||||
#include <mysql/service_thd_wait.h>
|
||||
|
||||
#ifdef HAVE_PSI_INTERFACE
|
||||
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) &&
|
||||
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,
|
||||
abs_timeout);
|
||||
thd_wait_end(thd);
|
||||
}
|
||||
|
||||
if (m_wait_status == EMPTY)
|
||||
{
|
||||
|
|
|
@ -82,7 +82,7 @@ scheduler_functions *thread_scheduler= NULL;
|
|||
/**@{*/
|
||||
static void scheduler_wait_begin(void) {
|
||||
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) {
|
||||
|
|
|
@ -1234,7 +1234,7 @@ retry:
|
|||
|
||||
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);
|
||||
thd_wait_end(trx->mysql_thd);
|
||||
|
||||
|
@ -1601,7 +1601,7 @@ srv_suspend_mysql_thread(
|
|||
|
||||
/* 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);
|
||||
thd_wait_end(trx->mysql_thd);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue