summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Ronstrom <mikael@dator8>2011-01-12 14:31:17 +0100
committerMikael Ronstrom <mikael@dator8>2011-01-12 14:31:17 +0100
commit7dae4282d4d5ec2ec8d17f600e87918e0a0aea00 (patch)
tree6f0d9007e11477c581fdf31fa209192fe65ca591
parent6e7752d557aa0d77e49299eefa04136fe45bbb11 (diff)
downloadmariadb-git-7dae4282d4d5ec2ec8d17f600e87918e0a0aea00.tar.gz
BUG#59392, removed thread local storage use in MySQL Threads by storing ibuf_inside indicator in MTR object instead
-rw-r--r--include/mysql/plugin_auth.h.pp13
-rw-r--r--storage/innobase/btr/btr0cur.c2
-rw-r--r--storage/innobase/buf/buf0buf.c16
-rw-r--r--storage/innobase/buf/buf0rea.c7
-rw-r--r--storage/innobase/fil/fil0fil.c2
-rw-r--r--storage/innobase/handler/ha_innodb.cc1
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.c113
-rw-r--r--storage/innobase/include/buf0rea.h4
-rw-r--r--storage/innobase/include/ibuf0ibuf.h13
-rw-r--r--storage/innobase/include/mtr0mtr.h2
-rw-r--r--storage/innobase/include/mtr0mtr.ic1
-rw-r--r--storage/innobase/include/thr0loc.h8
-rw-r--r--storage/innobase/mtr/mtr0mtr.c1
-rw-r--r--storage/innobase/thr/thr0loc.c20
14 files changed, 75 insertions, 128 deletions
diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp
index 88588d03b9e..aed764ddb51 100644
--- a/include/mysql/plugin_auth.h.pp
+++ b/include/mysql/plugin_auth.h.pp
@@ -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);
diff --git a/storage/innobase/btr/btr0cur.c b/storage/innobase/btr/btr0cur.c
index 50489ae4cc6..27f05da6f28 100644
--- a/storage/innobase/btr/btr0cur.c
+++ b/storage/innobase/btr/btr0cur.c
@@ -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
diff --git a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c
index b79b5634957..0fd518ac6a4 100644
--- a/storage/innobase/buf/buf0buf.c
+++ b/storage/innobase/buf/buf0buf.c
@@ -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)) {
diff --git a/storage/innobase/buf/buf0rea.c b/storage/innobase/buf/buf0rea.c
index 82b45172988..519724d0b9a 100644
--- a/storage/innobase/buf/buf0rea.c
+++ b/storage/innobase/buf/buf0rea.c
@@ -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
diff --git a/storage/innobase/fil/fil0fil.c b/storage/innobase/fil/fil0fil.c
index cb4ccc005b5..7f1551b6bb7 100644
--- a/storage/innobase/fil/fil0fil.c
+++ b/storage/innobase/fil/fil0fil.c
@@ -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;
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 6cbf7234043..824f12b97b7 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -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);
diff --git a/storage/innobase/ibuf/ibuf0ibuf.c b/storage/innobase/ibuf/ibuf0ibuf.c
index ab42f1ad4f3..aab0084c214 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.c
+++ b/storage/innobase/ibuf/ibuf0ibuf.c
@@ -324,37 +324,27 @@ still physically like the index page even if the index would have been
dropped! So, there seems to be no problem. */
/******************************************************************//**
-Sets the flag in the current OS thread local storage denoting that it is
+Sets the flag in the current mini-transaction record indicating we're
inside an insert buffer routine. */
-UNIV_INLINE
+UNIV_INTERN
void
-ibuf_enter(void)
+ibuf_enter(
+ mtr_t *mtr) /*!< in: mtr stores ibuf_inside info */
/*============*/
{
- ibool* ptr;
-
- ptr = thr_local_get_in_ibuf_field();
-
- ut_ad(*ptr == FALSE);
-
- *ptr = TRUE;
+ mtr->ibuf_inside = TRUE;
}
/******************************************************************//**
-Sets the flag in the current OS thread local storage denoting that it is
+Sets the flag in the current mini-transaction record indicating we're
exiting an insert buffer routine. */
UNIV_INLINE
void
-ibuf_exit(void)
+ibuf_exit(
+ mtr_t *mtr) /*!< in: mtr stores ibuf_inside info */
/*===========*/
{
- ibool* ptr;
-
- ptr = thr_local_get_in_ibuf_field();
-
- ut_ad(*ptr == TRUE);
-
- *ptr = FALSE;
+ mtr->ibuf_inside = FALSE;
}
/******************************************************************//**
@@ -366,10 +356,11 @@ 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: mtr stores ibuf_inside info */
/*=============*/
{
- return(*thr_local_get_in_ibuf_field());
+ return(mtr->ibuf_inside);
}
/******************************************************************//**
@@ -383,7 +374,7 @@ ibuf_header_page_get(
{
buf_block_t* block;
- ut_ad(!ibuf_inside());
+ ut_ad(!ibuf_inside(mtr));
block = buf_page_get(
IBUF_SPACE_ID, 0, FSP_IBUF_HEADER_PAGE_NO, RW_X_LATCH, mtr);
@@ -404,7 +395,7 @@ ibuf_tree_root_get(
buf_block_t* block;
page_t* root;
- ut_ad(ibuf_inside());
+ ut_ad(ibuf_inside(mtr));
ut_ad(mutex_own(&ibuf_mutex));
mtr_x_lock(dict_index_get_lock(ibuf->index), mtr);
@@ -547,7 +538,7 @@ ibuf_init_at_db_start(void)
fseg_n_reserved_pages(header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER,
&n_used, &mtr);
- ibuf_enter();
+ ibuf_enter(&mtr);
ut_ad(n_used >= 2);
@@ -570,8 +561,6 @@ ibuf_init_at_db_start(void)
ibuf->empty = (page_get_n_recs(root) == 0);
mtr_commit(&mtr);
- ibuf_exit();
-
heap = mem_heap_create(450);
/* Use old-style record format for the insert buffer. */
@@ -1164,7 +1153,6 @@ ibuf_rec_get_page_no(
const byte* field;
ulint len;
- ut_ad(ibuf_inside());
ut_ad(rec_get_n_fields_old(rec) > 2);
field = rec_get_nth_field_old(rec, 1, &len);
@@ -1199,7 +1187,6 @@ ibuf_rec_get_space(
const byte* field;
ulint len;
- ut_ad(ibuf_inside());
ut_ad(rec_get_n_fields_old(rec) > 2);
field = rec_get_nth_field_old(rec, 1, &len);
@@ -1244,7 +1231,6 @@ ibuf_rec_get_info(
ulint info_len_local;
ulint counter_local;
- ut_ad(ibuf_inside());
fields = rec_get_n_fields_old(rec);
ut_a(fields > 4);
@@ -1304,7 +1290,6 @@ ibuf_rec_get_op_type(
{
ulint len;
- ut_ad(ibuf_inside());
ut_ad(rec_get_n_fields_old(rec) > 2);
(void) rec_get_nth_field_old(rec, 1, &len);
@@ -1677,7 +1662,6 @@ ibuf_rec_get_volume(
ibool pre_4_1;
ulint comp;
- ut_ad(ibuf_inside());
ut_ad(rec_get_n_fields_old(ibuf_rec) > 2);
data = rec_get_nth_field_old(ibuf_rec, 1, &len);
@@ -2094,7 +2078,7 @@ ibuf_add_free_page(void)
page = buf_block_get_frame(block);
}
- ibuf_enter();
+ ibuf_enter(&mtr);
mutex_enter(&ibuf_mutex);
@@ -2124,8 +2108,6 @@ ibuf_add_free_page(void)
mtr_commit(&mtr);
- ibuf_exit();
-
return(TRUE);
}
@@ -2156,7 +2138,7 @@ ibuf_remove_free_page(void)
header_page = ibuf_header_page_get(&mtr);
/* Prevent pessimistic inserts to insert buffer trees for a while */
- ibuf_enter();
+ ibuf_enter(&mtr);
mutex_enter(&ibuf_pessimistic_insert_mutex);
mutex_enter(&ibuf_mutex);
@@ -2165,14 +2147,14 @@ ibuf_remove_free_page(void)
mutex_exit(&ibuf_mutex);
mutex_exit(&ibuf_pessimistic_insert_mutex);
- ibuf_exit();
-
mtr_commit(&mtr);
return;
}
+ ibuf_exit(&mtr);
mtr_start(&mtr2);
+ ibuf_enter(&mtr2);
root = ibuf_tree_root_get(&mtr2);
@@ -2187,8 +2169,6 @@ ibuf_remove_free_page(void)
mtr_commit(&mtr2);
- ibuf_exit();
-
/* Since pessimistic inserts were prevented, we know that the
page is still in the free list. NOTE that also deletes may take
pages from the free list, but they take them from the start, and
@@ -2202,7 +2182,7 @@ ibuf_remove_free_page(void)
buf_page_reset_file_page_was_freed(IBUF_SPACE_ID, page_no);
#endif
- ibuf_enter();
+ ibuf_enter(&mtr);
mutex_enter(&ibuf_mutex);
@@ -2248,8 +2228,6 @@ ibuf_remove_free_page(void)
buf_page_set_file_page_was_freed(IBUF_SPACE_ID, page_no);
#endif
mtr_commit(&mtr);
-
- ibuf_exit();
}
/***********************************************************************//**
@@ -2271,8 +2249,6 @@ ibuf_free_excess_pages(void)
ut_ad(rw_lock_get_x_lock_count(
fil_space_get_latch(IBUF_SPACE_ID, NULL)) == 1);
- ut_ad(!ibuf_inside());
-
/* NOTE: We require that the thread did not own the latch before,
because then we know that we can obey the correct latching order
for ibuf latches */
@@ -2498,7 +2474,6 @@ ibuf_contract_ext(
mtr_t mtr;
*n_pages = 0;
- ut_ad(!ibuf_inside());
/* We perform a dirty read of ibuf->empty, without latching
the insert buffer root page. We trust this dirty read except
@@ -2529,7 +2504,7 @@ ibuf_is_empty:
mtr_start(&mtr);
- ibuf_enter();
+ ibuf_enter(&mtr);
/* Open a cursor to a randomly chosen leaf of the tree, at a random
position within the leaf */
@@ -2548,8 +2523,6 @@ ibuf_is_empty:
ut_ad(page_get_page_no(btr_pcur_get_page(&pcur))
== FSP_IBUF_TREE_ROOT_PAGE_NO);
- ibuf_exit();
-
mtr_commit(&mtr);
btr_pcur_close(&pcur);
@@ -2563,8 +2536,6 @@ ibuf_is_empty:
fprintf(stderr, "Ibuf contract sync %lu pages %lu volume %lu\n",
sync, *n_pages, sum_sizes);
#endif
- ibuf_exit();
-
mtr_commit(&mtr);
btr_pcur_close(&pcur);
@@ -2725,7 +2696,6 @@ ibuf_get_volume_buffered_count(
const byte* types;
ulint n_fields = rec_get_n_fields_old(rec);
- ut_ad(ibuf_inside());
ut_ad(n_fields > 4);
n_fields -= 4;
@@ -3039,9 +3009,8 @@ ibuf_update_max_tablespace_id(void)
ut_a(!dict_table_is_comp(ibuf->index->table));
- ibuf_enter();
-
mtr_start(&mtr);
+ ibuf_enter(&mtr);
btr_pcur_open_at_index_side(
FALSE, ibuf->index, BTR_SEARCH_LEAF, &pcur, TRUE, &mtr);
@@ -3065,7 +3034,6 @@ ibuf_update_max_tablespace_id(void)
}
mtr_commit(&mtr);
- ibuf_exit();
/* printf("Maximum space id in insert buffer %lu\n", max_space_id); */
@@ -3089,7 +3057,6 @@ ibuf_get_entry_counter_low(
const byte* field;
ulint len;
- ut_ad(ibuf_inside());
ut_ad(rec_get_n_fields_old(rec) > 2);
field = rec_get_nth_field_old(rec, 1, &len);
@@ -3374,7 +3341,6 @@ ibuf_insert_low(
if (mode == BTR_MODIFY_TREE) {
for (;;) {
- ibuf_enter();
mutex_enter(&ibuf_pessimistic_insert_mutex);
mutex_enter(&ibuf_mutex);
@@ -3385,7 +3351,6 @@ ibuf_insert_low(
mutex_exit(&ibuf_mutex);
mutex_exit(&ibuf_pessimistic_insert_mutex);
- ibuf_exit();
if (UNIV_UNLIKELY(!ibuf_add_free_page())) {
@@ -3393,11 +3358,12 @@ ibuf_insert_low(
return(DB_STRONG_FAIL);
}
}
+ mtr_start(&mtr);
} else {
- ibuf_enter();
+ mtr_start(&mtr);
+ ibuf_enter(&mtr);
}
- mtr_start(&mtr);
btr_pcur_open(ibuf->index, ibuf_entry, PAGE_CUR_LE, mode, &pcur, &mtr);
ut_ad(page_validate(btr_pcur_get_page(&pcur), ibuf->index));
@@ -3453,6 +3419,7 @@ fail_exit:
ut_a((buffered == 0) || ibuf_count_get(space, page_no));
#endif
mtr_start(&bitmap_mtr);
+ bitmap_mtr.ibuf_inside = mtr.ibuf_inside;
bitmap_page = ibuf_bitmap_get_map_page(space, page_no,
zip_size, &bitmap_mtr);
@@ -3579,7 +3546,6 @@ func_exit:
mtr_commit(&mtr);
btr_pcur_close(&pcur);
- ibuf_exit();
mem_heap_free(heap);
@@ -3837,7 +3803,7 @@ ibuf_insert_to_index_page(
page_t* page = buf_block_get_frame(block);
rec_t* rec;
- ut_ad(ibuf_inside());
+ ut_ad(ibuf_inside(mtr));
ut_ad(dtuple_check_typed(entry));
ut_ad(!buf_block_align(page)->is_hashed);
@@ -3984,7 +3950,7 @@ ibuf_set_del_mark(
page_cur_t page_cur;
ulint low_match;
- ut_ad(ibuf_inside());
+ ut_ad(ibuf_inside(mtr));
ut_ad(dtuple_check_typed(entry));
low_match = page_cur_search(
@@ -4041,7 +4007,7 @@ ibuf_delete(
page_cur_t page_cur;
ulint low_match;
- ut_ad(ibuf_inside());
+ ut_ad(ibuf_inside(mtr));
ut_ad(dtuple_check_typed(entry));
low_match = page_cur_search(
@@ -4183,7 +4149,7 @@ ibuf_delete_rec(
page_t* root;
ulint err;
- ut_ad(ibuf_inside());
+ ut_ad(ibuf_inside(mtr));
ut_ad(page_rec_is_user_rec(btr_pcur_get_rec(pcur)));
ut_ad(ibuf_rec_get_page_no(btr_pcur_get_rec(pcur)) == page_no);
ut_ad(ibuf_rec_get_space(btr_pcur_get_rec(pcur)) == space);
@@ -4373,8 +4339,6 @@ ibuf_merge_or_delete_for_page(
return;
}
- ibuf_enter();
-
heap = mem_heap_create(512);
if (!trx_sys_multiple_tablespace_format) {
@@ -4405,6 +4369,7 @@ ibuf_merge_or_delete_for_page(
ut_print_timestamp(stderr);
mtr_start(&mtr);
+ ibuf_enter(&mtr);
fputs(" InnoDB: Dump of the ibuf bitmap page:\n",
stderr);
@@ -4445,6 +4410,7 @@ ibuf_merge_or_delete_for_page(
loop:
mtr_start(&mtr);
+ ibuf_enter(&mtr);
if (block) {
ibool success;
@@ -4551,6 +4517,7 @@ loop:
btr_pcur_commit_specify_mtr(&pcur, &mtr);
mtr_start(&mtr);
+ ibuf_enter(&mtr);
success = buf_page_get_known_nowait(
RW_X_LATCH, block,
@@ -4649,8 +4616,6 @@ reset_bit:
fil_decr_pending_ibuf_merges(space);
}
- ibuf_exit();
-
#ifdef UNIV_IBUF_COUNT_DEBUG
ut_a(ibuf_count_get(space, page_no) == 0);
#endif
@@ -4687,9 +4652,8 @@ ibuf_delete_for_discarded_space(
memset(dops, 0, sizeof(dops));
loop:
- ibuf_enter();
-
mtr_start(&mtr);
+ ibuf_enter(&mtr);
/* Position pcur in the insert buffer at the first entry for the
space */
@@ -4725,8 +4689,6 @@ loop:
/* Deletion was pessimistic and mtr was committed:
we start from the beginning again */
- ibuf_exit();
-
goto loop;
}
@@ -4734,8 +4696,6 @@ loop:
mtr_commit(&mtr);
btr_pcur_close(&pcur);
- ibuf_exit();
-
goto loop;
}
}
@@ -4753,8 +4713,6 @@ leave_loop:
mutex_exit(&ibuf_mutex);
#endif /* HAVE_ATOMIC_BUILTINS */
- ibuf_exit();
-
mem_heap_free(heap);
}
@@ -4770,8 +4728,8 @@ ibuf_is_empty(void)
const page_t* root;
mtr_t mtr;
- ibuf_enter();
mtr_start(&mtr);
+ ibuf_enter(&mtr);
mutex_enter(&ibuf_mutex);
root = ibuf_tree_root_get(&mtr);
@@ -4779,7 +4737,6 @@ ibuf_is_empty(void)
is_empty = (page_get_n_recs(root) == 0);
mtr_commit(&mtr);
- ibuf_exit();
ut_a(is_empty == ibuf->empty);
diff --git a/storage/innobase/include/buf0rea.h b/storage/innobase/include/buf0rea.h
index 4a52f9dcd8d..6e1f832942a 100644
--- a/storage/innobase/include/buf0rea.h
+++ b/storage/innobase/include/buf0rea.h
@@ -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
diff --git a/storage/innobase/include/ibuf0ibuf.h b/storage/innobase/include/ibuf0ibuf.h
index dd05bcb0608..66b06575b0d 100644
--- a/storage/innobase/include/ibuf0ibuf.h
+++ b/storage/innobase/include/ibuf0ibuf.h
@@ -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.
diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h
index 8abca093548..2aaad3322c3 100644
--- a/storage/innobase/include/mtr0mtr.h
+++ b/storage/innobase/include/mtr0mtr.h
@@ -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 */
diff --git a/storage/innobase/include/mtr0mtr.ic b/storage/innobase/include/mtr0mtr.ic
index 18f8e87b3cf..fd72b3b75e6 100644
--- a/storage/innobase/include/mtr0mtr.ic
+++ b/storage/innobase/include/mtr0mtr.ic
@@ -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);
diff --git a/storage/innobase/include/thr0loc.h b/storage/innobase/include/thr0loc.h
index b7eb29f2ed0..14da8bffdd7 100644
--- a/storage/innobase/include/thr0loc.h
+++ b/storage/innobase/include/thr0loc.h
@@ -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"
diff --git a/storage/innobase/mtr/mtr0mtr.c b/storage/innobase/mtr/mtr0mtr.c
index 74d04a22b86..0b2100319c2 100644
--- a/storage/innobase/mtr/mtr0mtr.c
+++ b/storage/innobase/mtr/mtr0mtr.c
@@ -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
diff --git a/storage/innobase/thr/thr0loc.c b/storage/innobase/thr/thr0loc.c
index 2bd3e4b1c43..b7364afa166 100644
--- a/storage/innobase/thr/thr0loc.c
+++ b/storage/innobase/thr/thr0loc.c
@@ -175,26 +175,6 @@ thr_local_set_slot_no(
}
/*******************************************************************//**
-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
void