mirror of
https://github.com/MariaDB/server.git
synced 2025-01-26 08:44:33 +01:00
branches/innodb+: Factor out srv_threads_mutex from the kernel mutex.
Splitting the kernel mutex at once is a complex task, several mutexes will be factored out of it. This is one of the easier ones. This mutex sits below the kernel mutex and is used by the threads infra-structure. It is important for the multi-threaded purge because for multi-threaded purge we will need to activate and use InnoDB task queue and query thread scheduling code. rb://285
This commit is contained in:
parent
c18084f71b
commit
02de8ecfbc
13 changed files with 488 additions and 383 deletions
|
@ -232,7 +232,7 @@ SET(INNOBASE_SOURCES btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c
|
|||
rem/rem0cmp.c rem/rem0rec.c
|
||||
row/row0ext.c row/row0ins.c row/row0merge.c row/row0mysql.c row/row0purge.c row/row0row.c
|
||||
row/row0sel.c row/row0uins.c row/row0umod.c row/row0undo.c row/row0upd.c row/row0vers.c
|
||||
srv/srv0que.c srv/srv0srv.c srv/srv0start.c
|
||||
srv/srv0srv.c srv/srv0start.c
|
||||
sync/sync0arr.c sync/sync0rw.c sync/sync0sync.c
|
||||
thr/thr0loc.c
|
||||
trx/trx0i_s.c trx/trx0purge.c trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c
|
||||
|
|
|
@ -174,7 +174,6 @@ noinst_HEADERS= \
|
|||
include/row0upd.ic \
|
||||
include/row0vers.h \
|
||||
include/row0vers.ic \
|
||||
include/srv0que.h \
|
||||
include/srv0srv.h \
|
||||
include/srv0srv.ic \
|
||||
include/srv0start.h \
|
||||
|
@ -299,7 +298,6 @@ libinnobase_a_SOURCES= \
|
|||
row/row0undo.c \
|
||||
row/row0upd.c \
|
||||
row/row0vers.c \
|
||||
srv/srv0que.c \
|
||||
srv/srv0srv.c \
|
||||
srv/srv0start.c \
|
||||
sync/sync0arr.c \
|
||||
|
|
|
@ -381,6 +381,9 @@ struct que_thr_struct{
|
|||
thus far */
|
||||
ulint lock_state; /*!< lock state of thread (table or
|
||||
row) */
|
||||
struct srv_slot_struct*
|
||||
slot; /* The thread slot in the wait
|
||||
array in srv_sys_t */
|
||||
};
|
||||
|
||||
#define QUE_THR_MAGIC_N 8476583
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
/**************************************************//**
|
||||
@file include/srv0que.h
|
||||
Server query execution
|
||||
|
||||
Created 6/5/1996 Heikki Tuuri
|
||||
*******************************************************/
|
||||
|
||||
#ifndef srv0que_h
|
||||
#define srv0que_h
|
||||
|
||||
#include "univ.i"
|
||||
#include "que0types.h"
|
||||
|
||||
/**********************************************************************//**
|
||||
Enqueues a task to server task queue and releases a worker thread, if there
|
||||
is a suspended one. */
|
||||
UNIV_INTERN
|
||||
void
|
||||
srv_que_task_enqueue_low(
|
||||
/*=====================*/
|
||||
que_thr_t* thr); /*!< in: query thread */
|
||||
|
||||
#endif
|
||||
|
|
@ -239,7 +239,6 @@ extern ibool srv_print_latch_waits;
|
|||
# define srv_print_latch_waits FALSE
|
||||
#endif /* UNIV_DEBUG */
|
||||
|
||||
extern ulint srv_activity_count;
|
||||
extern ulint srv_fatal_semaphore_wait_threshold;
|
||||
extern ulint srv_dml_needed_delay;
|
||||
|
||||
|
@ -314,12 +313,6 @@ typedef struct export_var_struct export_struc;
|
|||
/** Status variables to be passed to MySQL */
|
||||
extern export_struc export_vars;
|
||||
|
||||
/** The server system */
|
||||
typedef struct srv_sys_struct srv_sys_t;
|
||||
|
||||
/** The server system */
|
||||
extern srv_sys_t* srv_sys;
|
||||
|
||||
# ifdef UNIV_PFS_THREAD
|
||||
/* Keys to register InnoDB threads with performance schema */
|
||||
extern mysql_pfs_key_t trx_rollback_clean_thread_key;
|
||||
|
@ -420,6 +413,8 @@ enum srv_thread_type {
|
|||
be biggest) */
|
||||
};
|
||||
|
||||
struct srv_slot_struct;
|
||||
|
||||
/*********************************************************************//**
|
||||
Boots Innobase server.
|
||||
@return DB_SUCCESS or error code */
|
||||
|
@ -470,17 +465,6 @@ srv_set_io_thread_op_info(
|
|||
const char* str); /*!< in: constant char string describing the
|
||||
state */
|
||||
/*********************************************************************//**
|
||||
Releases threads of the type given from suspension in the thread table.
|
||||
NOTE! The server mutex has to be reserved by the caller!
|
||||
@return number of threads released: this may be less than n if not
|
||||
enough threads were suspended at the moment */
|
||||
UNIV_INTERN
|
||||
ulint
|
||||
srv_release_threads(
|
||||
/*================*/
|
||||
enum srv_thread_type type, /*!< in: thread type */
|
||||
ulint n); /*!< in: number of threads to release */
|
||||
/*********************************************************************//**
|
||||
The master thread controlling the server.
|
||||
@return a dummy parameter */
|
||||
UNIV_INTERN
|
||||
|
@ -627,6 +611,13 @@ void
|
|||
srv_export_innodb_status(void);
|
||||
/*==========================*/
|
||||
|
||||
/******************************************************************//**
|
||||
Increment the server activity counter. */
|
||||
UNIV_INTERN
|
||||
void
|
||||
srv_inc_activity_count(void);
|
||||
/*=========================*/
|
||||
|
||||
/*********************************************************************//**
|
||||
Asynchronous purge thread.
|
||||
@return a dummy parameter */
|
||||
|
@ -636,11 +627,23 @@ srv_purge_thread(
|
|||
/*=============*/
|
||||
void* arg __attribute__((unused))); /*!< in: a dummy parameter
|
||||
required by os_thread_create */
|
||||
/** Thread slot in the thread table */
|
||||
typedef struct srv_slot_struct srv_slot_t;
|
||||
|
||||
/** Thread table is an array of slots */
|
||||
typedef srv_slot_t srv_table_t;
|
||||
/**********************************************************************//**
|
||||
Enqueues a task to server task queue and releases a worker thread, if there
|
||||
is a suspended one. */
|
||||
UNIV_INTERN
|
||||
void
|
||||
srv_que_task_enqueue_low(
|
||||
/*=====================*/
|
||||
que_thr_t* thr); /*!< in: query thread */
|
||||
|
||||
/**********************************************************************//**
|
||||
Check whether the master thread is active.
|
||||
@return FALSE is it is not active. */
|
||||
UNIV_INTERN
|
||||
ibool
|
||||
srv_is_master_thread_active(void);
|
||||
/*==============================*/
|
||||
|
||||
/** Status variables to be passed to MySQL */
|
||||
struct export_var_struct{
|
||||
|
@ -696,14 +699,6 @@ struct export_var_struct{
|
|||
ulint innodb_rows_deleted; /*!< srv_n_rows_deleted */
|
||||
};
|
||||
|
||||
/** The server system struct */
|
||||
struct srv_sys_struct{
|
||||
srv_table_t* threads; /*!< server thread table */
|
||||
UT_LIST_BASE_NODE_T(que_thr_t)
|
||||
tasks; /*!< task queue */
|
||||
};
|
||||
|
||||
extern ulint srv_n_threads_active[];
|
||||
#else /* !UNIV_HOTBACKUP */
|
||||
# define srv_use_adaptive_hash_indexes FALSE
|
||||
# define srv_use_checksums TRUE
|
||||
|
|
|
@ -105,6 +105,7 @@ extern mysql_pfs_key_t rw_lock_mutex_key;
|
|||
extern mysql_pfs_key_t srv_dict_tmpfile_mutex_key;
|
||||
extern mysql_pfs_key_t srv_innodb_monitor_mutex_key;
|
||||
extern mysql_pfs_key_t srv_misc_tmpfile_mutex_key;
|
||||
extern mysql_pfs_key_t srv_threads_mutex_key;
|
||||
extern mysql_pfs_key_t srv_monitor_file_mutex_key;
|
||||
extern mysql_pfs_key_t syn_arr_mutex_key;
|
||||
# ifdef UNIV_SYNC_DEBUG
|
||||
|
@ -587,6 +588,9 @@ Kernel mutex If a kernel operation needs a file
|
|||
| fsp x-latch before acquiring the kernel
|
||||
| mutex.
|
||||
V
|
||||
Threads mutex Thread scheduling mutex
|
||||
|
|
||||
V
|
||||
Search system mutex
|
||||
|
|
||||
V
|
||||
|
@ -657,8 +661,9 @@ or row lock! */
|
|||
/*------------------------------------- MySQL binlog mutex */
|
||||
/*-------------------------------*/
|
||||
#define SYNC_KERNEL 300
|
||||
#define SYNC_REC_LOCK 299
|
||||
#define SYNC_TRX_LOCK_HEAP 298
|
||||
#define SYNC_THREADS 299
|
||||
#define SYNC_REC_LOCK 298
|
||||
#define SYNC_TRX_LOCK_HEAP 297
|
||||
#define SYNC_TRX_SYS_HEADER 290
|
||||
#define SYNC_LOG 170
|
||||
#define SYNC_LOG_FLUSH_ORDER 147
|
||||
|
|
|
@ -3131,17 +3131,14 @@ loop:
|
|||
return; /* We SKIP ALL THE REST !! */
|
||||
}
|
||||
|
||||
mutex_exit(&kernel_mutex);
|
||||
|
||||
/* Check that the master thread is suspended */
|
||||
|
||||
if (srv_n_threads_active[SRV_MASTER] != 0) {
|
||||
|
||||
mutex_exit(&kernel_mutex);
|
||||
|
||||
if (srv_is_master_thread_active()) {
|
||||
goto loop;
|
||||
}
|
||||
|
||||
mutex_exit(&kernel_mutex);
|
||||
|
||||
mutex_enter(&(log_sys->mutex));
|
||||
|
||||
if (log_sys->n_pending_checkpoint_writes
|
||||
|
@ -3199,18 +3196,14 @@ loop:
|
|||
|
||||
mutex_exit(&(log_sys->mutex));
|
||||
|
||||
mutex_enter(&kernel_mutex);
|
||||
/* Check that the master thread has stayed suspended */
|
||||
if (srv_n_threads_active[SRV_MASTER] != 0) {
|
||||
if (srv_is_master_thread_active()) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: Warning: the master thread woke up"
|
||||
" during shutdown\n");
|
||||
|
||||
mutex_exit(&kernel_mutex);
|
||||
|
||||
goto loop;
|
||||
}
|
||||
mutex_exit(&kernel_mutex);
|
||||
|
||||
fil_flush_file_spaces(FIL_TABLESPACE);
|
||||
fil_flush_file_spaces(FIL_LOG);
|
||||
|
@ -3228,7 +3221,8 @@ loop:
|
|||
srv_shutdown_state = SRV_SHUTDOWN_LAST_PHASE;
|
||||
|
||||
/* Make some checks that the server really is quiet */
|
||||
ut_a(srv_n_threads_active[SRV_MASTER] == 0);
|
||||
ut_a(!srv_is_master_thread_active());
|
||||
|
||||
ut_a(buf_all_freed());
|
||||
ut_a(lsn == log_sys->lsn);
|
||||
|
||||
|
@ -3249,7 +3243,8 @@ loop:
|
|||
fil_close_all_files();
|
||||
|
||||
/* Make some checks that the server really is quiet */
|
||||
ut_a(srv_n_threads_active[SRV_MASTER] == 0);
|
||||
ut_a(!srv_is_master_thread_active());
|
||||
|
||||
ut_a(buf_all_freed());
|
||||
ut_a(lsn == log_sys->lsn);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ Created 5/27/1996 Heikki Tuuri
|
|||
#include "que0que.ic"
|
||||
#endif
|
||||
|
||||
#include "srv0que.h"
|
||||
#include "usr0sess.h"
|
||||
#include "trx0trx.h"
|
||||
#include "trx0roll.h"
|
||||
|
@ -311,7 +310,9 @@ que_thr_end_wait_no_next_thr(
|
|||
/* In MySQL we let the OS thread (not just the query thread) to wait
|
||||
for the lock to be released: */
|
||||
|
||||
srv_release_mysql_thread_if_suspended(thr);
|
||||
if (thr != NULL) {
|
||||
srv_release_mysql_thread_if_suspended(thr);
|
||||
}
|
||||
|
||||
/* srv_que_task_enqueue_low(thr); */
|
||||
}
|
||||
|
|
|
@ -341,7 +341,7 @@ row_undo_step(
|
|||
|
||||
ut_ad(thr);
|
||||
|
||||
srv_activity_count++;
|
||||
srv_inc_activity_count();
|
||||
|
||||
trx = thr_get_trx(thr);
|
||||
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
/**************************************************//**
|
||||
@file srv/srv0que.c
|
||||
Server query execution
|
||||
|
||||
Created 6/5/1996 Heikki Tuuri
|
||||
*******************************************************/
|
||||
|
||||
#include "srv0que.h"
|
||||
|
||||
#include "srv0srv.h"
|
||||
#include "sync0sync.h"
|
||||
#include "os0thread.h"
|
||||
#include "usr0sess.h"
|
||||
#include "que0que.h"
|
||||
|
||||
/**********************************************************************//**
|
||||
Enqueues a task to server task queue and releases a worker thread, if there
|
||||
is a suspended one. */
|
||||
UNIV_INTERN
|
||||
void
|
||||
srv_que_task_enqueue_low(
|
||||
/*=====================*/
|
||||
que_thr_t* thr) /*!< in: query thread */
|
||||
{
|
||||
ut_ad(thr);
|
||||
ut_ad(mutex_own(&kernel_mutex));
|
||||
|
||||
UT_LIST_ADD_LAST(queue, srv_sys->tasks, thr);
|
||||
|
||||
srv_release_threads(SRV_WORKER, 1);
|
||||
}
|
679
srv/srv0srv.c
679
srv/srv0srv.c
File diff suppressed because it is too large
Load diff
|
@ -1167,6 +1167,7 @@ sync_thread_add_level(
|
|||
case SYNC_SEARCH_SYS_CONF:
|
||||
case SYNC_TRX_LOCK_HEAP:
|
||||
case SYNC_KERNEL:
|
||||
case SYNC_THREADS:
|
||||
case SYNC_IBUF_BITMAP_MUTEX:
|
||||
case SYNC_RSEG:
|
||||
case SYNC_TRX_UNDO:
|
||||
|
|
|
@ -37,7 +37,6 @@ Created 3/26/1996 Heikki Tuuri
|
|||
#include "trx0rec.h"
|
||||
#include "que0que.h"
|
||||
#include "usr0sess.h"
|
||||
#include "srv0que.h"
|
||||
#include "srv0start.h"
|
||||
#include "row0undo.h"
|
||||
#include "row0mysql.h"
|
||||
|
|
Loading…
Add table
Reference in a new issue