Commit 7dae4282 authored by Mikael Ronstrom's avatar Mikael Ronstrom

BUG#59392, removed thread local storage use in MySQL Threads by storing...

BUG#59392, removed thread local storage use in MySQL Threads by storing ibuf_inside indicator in MTR object instead
parent 6e7752d5
......@@ -33,10 +33,17 @@ 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_SYNC= 10,
THD_WAIT_LAST= 11
} thd_wait_type;
extern struct thd_wait_service_st {
void (*thd_wait_begin_func)(void*, thd_wait_type);
......
......@@ -390,7 +390,7 @@ btr_cur_search_to_nth_level(
ut_ad(level == 0 || mode == PAGE_CUR_LE);
ut_ad(dict_index_check_search_tuple(index, tuple));
ut_ad(!dict_index_is_ibuf(index) || ibuf_inside());
ut_ad(!dict_index_is_ibuf(index) || ibuf_inside(mtr));
ut_ad(dtuple_check_typed(tuple));
#ifdef UNIV_DEBUG
......
......@@ -2314,9 +2314,6 @@ buf_page_get_zip(
unsigned access_time;
buf_pool_t* buf_pool = buf_pool_get(space, offset);
#ifndef UNIV_LOG_DEBUG
ut_ad(!ibuf_inside());
#endif
buf_pool->stat.n_page_gets++;
for (;;) {
......@@ -2745,7 +2742,7 @@ buf_page_get_gen(
ut_ad(zip_size == fil_space_get_zip_size(space));
ut_ad(ut_is_2pow(zip_size));
#ifndef UNIV_LOG_DEBUG
ut_ad(!ibuf_inside() || ibuf_page(space, zip_size, offset, NULL));
ut_ad(!ibuf_inside(mtr) || ibuf_page(space, zip_size, offset, NULL));
#endif
buf_pool->stat.n_page_gets++;
fold = buf_page_address_fold(space, offset);
......@@ -3114,7 +3111,7 @@ wait_until_unfixed:
/* In the case of a first access, try to apply linear
read-ahead */
buf_read_ahead_linear(space, zip_size, offset);
buf_read_ahead_linear(space, zip_size, offset, mtr);
}
#ifdef UNIV_IBUF_COUNT_DEBUG
......@@ -3171,7 +3168,7 @@ buf_page_optimistic_get(
access_time = buf_page_is_accessed(&block->page);
buf_page_set_accessed_make_young(&block->page, access_time);
ut_ad(!ibuf_inside()
ut_ad(!ibuf_inside(mtr)
|| ibuf_page(buf_block_get_space(block),
buf_block_get_zip_size(block),
buf_block_get_page_no(block), NULL));
......@@ -3227,7 +3224,8 @@ buf_page_optimistic_get(
buf_read_ahead_linear(buf_block_get_space(block),
buf_block_get_zip_size(block),
buf_block_get_page_no(block));
buf_block_get_page_no(block),
mtr);
}
#ifdef UNIV_IBUF_COUNT_DEBUG
......@@ -3303,7 +3301,7 @@ buf_page_get_known_nowait(
buf_pool_mutex_exit(buf_pool);
}
ut_ad(!ibuf_inside() || (mode == BUF_KEEP_OLD));
ut_ad(!ibuf_inside(mtr) || (mode == BUF_KEEP_OLD));
if (rw_latch == RW_S_LATCH) {
success = rw_lock_s_lock_nowait(&(block->lock),
......@@ -3568,9 +3566,9 @@ buf_page_init_for_read(
/* It is a read-ahead within an ibuf routine */
ut_ad(!ibuf_bitmap_page(zip_size, offset));
ut_ad(ibuf_inside());
mtr_start(&mtr);
ibuf_enter(&mtr);
if (!recv_no_ibuf_operations
&& !ibuf_page(space, zip_size, offset, &mtr)) {
......
......@@ -238,8 +238,10 @@ buf_read_ahead_linear(
/*==================*/
ulint space, /*!< in: space id */
ulint zip_size,/*!< in: compressed page size in bytes, or 0 */
ulint offset) /*!< in: page number of a page; NOTE: the current thread
ulint offset, /*!< in: page number of a page; NOTE: the current thread
must want access to this page (see NOTE 3 above) */
mtr_t *mtr) /*!< in: mtr with knowledge if we're inside ibuf
routine */
{
buf_pool_t* buf_pool = buf_pool_get(space, offset);
ib_int64_t tablespace_version;
......@@ -429,7 +431,7 @@ buf_read_ahead_linear(
/* If we got this far, read-ahead can be sensible: do it */
if (ibuf_inside()) {
if (ibuf_inside(mtr)) {
ibuf_mode = BUF_READ_IBUF_PAGES_ONLY;
} else {
ibuf_mode = BUF_READ_ANY_PAGE;
......@@ -520,7 +522,6 @@ buf_read_ibuf_merge_pages(
{
ulint i;
ut_ad(!ibuf_inside());
#ifdef UNIV_IBUF_DEBUG
ut_a(n_stored < UNIV_PAGE_SIZE);
#endif
......
......@@ -4314,8 +4314,6 @@ fil_io(
ut_ad(recv_no_ibuf_operations || (type == OS_FILE_WRITE)
|| !ibuf_bitmap_page(zip_size, block_offset)
|| sync || is_log);
ut_ad(!ibuf_inside() || is_log || (type == OS_FILE_WRITE)
|| ibuf_page(space_id, zip_size, block_offset, NULL));
# endif /* UNIV_LOG_DEBUG */
if (sync) {
mode = OS_AIO_SYNC;
......
......@@ -3006,7 +3006,6 @@ innobase_close_connection(
innobase_rollback_trx(trx);
thr_local_free(trx->mysql_thread_id);
trx_free_for_mysql(trx);
DBUG_RETURN(0);
......
This diff is collapsed.
......@@ -28,6 +28,7 @@ Created 11/5/1995 Heikki Tuuri
#include "univ.i"
#include "buf0types.h"
#include "mtr0types.h"
/********************************************************************//**
High-level function which reads a page asynchronously from a file to the
......@@ -72,8 +73,9 @@ buf_read_ahead_linear(
/*==================*/
ulint space, /*!< in: space id */
ulint zip_size,/*!< in: compressed page size in bytes, or 0 */
ulint offset);/*!< in: page number of a page; NOTE: the current thread
ulint offset, /*!< in: page number of a page; NOTE: the current thread
must want access to this page (see NOTE 3 above) */
mtr_t *mtr); /*!< in: mtr to get ibuf_inside indicator */
/********************************************************************//**
Issues read requests for pages which the ibuf module wants to read in, in
order to contract the insert buffer tree. Technically, this function is like
......
......@@ -218,7 +218,7 @@ ibuf_should_try(
a secondary index when we
decide */
/******************************************************************//**
Returns TRUE if the current OS thread is performing an insert buffer
Returns TRUE if the current MTR is performing an insert buffer
routine.
For instance, a read-ahead of non-ibuf pages is forbidden by threads
......@@ -226,7 +226,16 @@ that are executing an insert buffer routine.
@return TRUE if inside an insert buffer routine */
UNIV_INTERN
ibool
ibuf_inside(void);
ibuf_inside(
mtr_t* mtr);/*!< in: ibuf_inside stored on mtr */
/*=============*/
/***********************************************************************//**
Sets ibuf_inside indicator on current MTR.
*/
UNIV_INTERN
void
ibuf_enter(
mtr_t* mtr);/*!< in: ibuf_inside stored on mtr */
/*=============*/
/***********************************************************************//**
Checks if a page address is an ibuf bitmap page (level 3 page) address.
......
......@@ -378,6 +378,8 @@ struct mtr_struct{
#endif
dyn_array_t memo; /*!< memo stack for locks etc. */
dyn_array_t log; /*!< mini-transaction log */
ibool ibuf_inside;
/* TRUE if inside ibuf changes */
ibool modifications;
/* TRUE if the mtr made modifications to
buffer pool pages */
......
......@@ -44,6 +44,7 @@ mtr_start(
mtr->log_mode = MTR_LOG_ALL;
mtr->modifications = FALSE;
mtr->ibuf_inside = FALSE;
mtr->n_log_recs = 0;
ut_d(mtr->state = MTR_ACTIVE);
......
......@@ -74,14 +74,6 @@ thr_local_set_slot_no(
/*==================*/
os_thread_id_t id, /*!< in: thread id of the thread */
ulint slot_no);/*!< in: slot number */
/*******************************************************************//**
Returns pointer to the 'in_ibuf' field within the current thread local
storage.
@return pointer to the in_ibuf field */
UNIV_INTERN
ibool*
thr_local_get_in_ibuf_field(void);
/*=============================*/
#ifndef UNIV_NONINL
#include "thr0loc.ic"
......
......@@ -267,6 +267,7 @@ mtr_commit(
ut_d(mtr->state = MTR_COMMITTED);
dyn_array_free(&(mtr->memo));
dyn_array_free(&(mtr->log));
mtr->ibuf_inside = FALSE;
}
#ifndef UNIV_HOTBACKUP
......
......@@ -174,26 +174,6 @@ thr_local_set_slot_no(
mutex_exit(&thr_local_mutex);
}
/*******************************************************************//**
Returns pointer to the 'in_ibuf' field within the current thread local
storage.
@return pointer to the in_ibuf field */
UNIV_INTERN
ibool*
thr_local_get_in_ibuf_field(void)
/*=============================*/
{
thr_local_t* local;
mutex_enter(&thr_local_mutex);
local = thr_local_get(os_thread_get_curr_id());
mutex_exit(&thr_local_mutex);
return(&(local->in_ibuf));
}
/*******************************************************************//**
Creates a local storage struct for the calling new thread. */
UNIV_INTERN
......
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