Commit 4df65a76 authored by marko's avatar marko

branches/zip: ibuf_set_free_bits_func(): Disable redo logging when

crash recovery is in progress.  This avoids a hang when
btr_parse_page_reorganize(), called from an I/O handler thread,
attempts to acquire log_sys->mutex while it is being held by
the main thread (the one that runs innobase_init()).  This change
was committed accidentally.  It may be unsafe to clear
mtr.modifications, because buf_page_release() at mtr_commit() may
forget to put modified pages to the flush list.

Cleanup: Remove the "type" parameter from many ibuf functions.
Let the caller check that !dict_index_is_clust().  This should avoid
function calls and register spilling.

ibuf_set_free_bits_func(), ibuf_set_free_bits(): Remove the parameter "type".

ibuf_reset_free_bits_with_type(): Rename to ibuf_reset_free_bits().
Remove the parameter "type".

ibuf_update_free_bits_if_full(), ibuf_update_free_bits_zip(),
ibuf_update_free_bits_low(), ibuf_update_free_bits_for_two_pages_low():
Remove the parameter "index".
parent d28d18ca
......@@ -787,7 +787,9 @@ btr_create(
trees in the same mtr, otherwise the latch on a bitmap page would
prevent it because of the latching order */
ibuf_reset_free_bits_with_type(type, block);
if (!(type & DICT_CLUSTERED)) {
ibuf_reset_free_bits(block);
}
/* In the following assertion we test that two records of maximum
allowed size fit on the root page: this fact is needed to ensure
......@@ -977,8 +979,7 @@ btr_page_reorganize_low(
if (UNIV_LIKELY_NULL(page_zip)
&& !dict_index_is_clust(index) && page_is_leaf(page)) {
ibuf_update_free_bits_zip(
index, page_zip_get_size(page_zip), block);
ibuf_update_free_bits_zip(page_zip_get_size(page_zip), block);
}
func_exit:
......@@ -1212,7 +1213,10 @@ btr_root_raise_and_insert(
fprintf(stderr, "Root raise new page no %lu\n", new_page_no);
#endif
ibuf_reset_free_bits_with_type(index->type, new_block);
if (!dict_index_is_clust(index)) {
ibuf_reset_free_bits(new_block);
}
/* Reposition the cursor to the child node */
page_cur_search(new_block, index, tuple,
PAGE_CUR_LE, page_cursor);
......@@ -1979,7 +1983,9 @@ btr_page_split_and_insert(
start of the function for a new split */
insert_failed:
/* We play safe and reset the free bits for new_page */
ibuf_reset_free_bits_with_type(cursor->index->type, new_block);
if (!dict_index_is_clust(cursor->index)) {
ibuf_reset_free_bits(new_block);
}
/* fprintf(stderr, "Split second round %lu\n",
page_get_page_no(page)); */
......@@ -1998,7 +2004,6 @@ btr_page_split_and_insert(
if (!dict_index_is_clust(cursor->index) && page_is_leaf(page)) {
ibuf_update_free_bits_for_two_pages_low(
cursor->index,
buf_block_get_zip_size(left_block),
left_block, right_block, mtr);
}
......@@ -2281,7 +2286,9 @@ btr_lift_page_up(
btr_page_free(index, block, mtr);
/* We play safe and reset the free bits for the father */
ibuf_reset_free_bits_with_type(index->type, father_block);
if (!dict_index_is_clust(index)) {
ibuf_reset_free_bits(father_block);
}
ut_ad(page_validate(father_page, index));
ut_ad(btr_check_node_ptr(index, father_block, mtr));
}
......@@ -2519,10 +2526,9 @@ btr_compress(
/* We have added new records to merge_page:
update its free bits */
if (zip_size) {
ibuf_update_free_bits_zip(index, zip_size,
merge_block);
ibuf_update_free_bits_zip(zip_size, merge_block);
} else {
ibuf_update_free_bits_if_full(index, merge_block,
ibuf_update_free_bits_if_full(merge_block,
UNIV_PAGE_SIZE,
ULINT_UNDEFINED);
}
......@@ -2580,7 +2586,9 @@ btr_discard_only_page_on_level(
btr_page_empty(father_block, father_page_zip, mtr, index);
/* We play safe and reset the free bits for the father */
ibuf_reset_free_bits_with_type(index->type, father_block);
if (!dict_index_is_clust(index)) {
ibuf_reset_free_bits(father_block);
}
} else {
ut_ad(page_get_n_recs(father_page) == 1);
......
......@@ -898,8 +898,7 @@ btr_cur_insert_if_possible(
&& !dict_index_is_clust(cursor->index)
&& page_is_leaf(buf_block_get_frame(block))) {
/* Update the free bits in the insert buffer. */
ibuf_update_free_bits_zip(cursor->index,
buf_block_get_zip_size(block),
ibuf_update_free_bits_zip(buf_block_get_zip_size(block),
block);
}
......@@ -1226,11 +1225,10 @@ btr_cur_optimistic_insert(
if (!dict_index_is_clust(index) && UNIV_LIKELY(0 == level)) {
/* We have added a record to page: update its free bits */
if (zip_size) {
ibuf_update_free_bits_zip(cursor->index,
zip_size, block);
ibuf_update_free_bits_zip(zip_size, block);
} else {
ibuf_update_free_bits_if_full(
cursor->index, block, max_size,
block, max_size,
rec_size + PAGE_DIR_SLOT_SIZE);
}
}
......@@ -1664,7 +1662,7 @@ btr_cur_update_alloc_zip(
length, 0)) {
if (!dict_index_is_clust(index)) {
/* No space on the page: reset the free bits. */
ibuf_reset_free_bits_with_type(index->type, block);
ibuf_reset_free_bits(block);
}
return(FALSE);
}
......@@ -1734,7 +1732,7 @@ btr_cur_update_in_place(
&& page_is_leaf(buf_block_get_frame(block))) {
/* Update the free bits in the insert buffer. */
ibuf_update_free_bits_zip(
index, page_zip_get_size(page_zip), block);
page_zip_get_size(page_zip), block);
}
if (UNIV_LIKELY_NULL(heap)) {
......@@ -1775,7 +1773,7 @@ btr_cur_update_in_place(
if (page_zip && !dict_index_is_clust(index)
&& page_is_leaf(buf_block_get_frame(block))) {
/* Update the free bits in the insert buffer. */
ibuf_update_free_bits_zip(index, buf_block_get_zip_size(block),
ibuf_update_free_bits_zip(buf_block_get_zip_size(block),
block);
}
......@@ -1954,7 +1952,7 @@ btr_cur_optimistic_update(
&& page_is_leaf(page)) {
/* Update the free bits in the insert buffer. */
ibuf_update_free_bits_zip(
index, buf_block_get_zip_size(block), block);
buf_block_get_zip_size(block), block);
}
mem_heap_free(heap);
......@@ -2785,8 +2783,10 @@ btr_cur_optimistic_delete(
ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */
ibuf_update_free_bits_low(cursor->index, zip_size,
block, max_ins_size, mtr);
if (!dict_index_is_clust(cursor->index)) {
ibuf_update_free_bits_low(zip_size, block,
max_ins_size, mtr);
}
}
if (UNIV_LIKELY_NULL(heap)) {
......
......@@ -791,7 +791,6 @@ UNIV_INLINE
void
ibuf_set_free_bits_low(
/*===================*/
ulint type, /* in: index type */
ulint zip_size,/* in: compressed page size in bytes;
0 for uncompressed pages */
buf_block_t* block, /* in: index page; free bits are set if
......@@ -804,11 +803,6 @@ ibuf_set_free_bits_low(
ulint space;
ulint page_no;
if (type & DICT_CLUSTERED) {
return;
}
if (!page_is_leaf(buf_block_get_frame(block))) {
return;
......@@ -840,10 +834,8 @@ were kept. */
void
ibuf_set_free_bits_func(
/*====================*/
ulint type, /* in: index type */
buf_block_t* block, /* in: index page; free bit is reset
if the index is a non-clustered
non-unique, and page level is 0 */
buf_block_t* block, /* in: index page of a non-clustered index;
free bit is reset if page level is 0 */
#ifdef UNIV_IBUF_DEBUG
ulint max_val,/* in: ULINT_UNDEFINED or a maximum
value which the bits must have before
......@@ -858,11 +850,6 @@ ibuf_set_free_bits_func(
ulint page_no;
ulint zip_size;
if (type & DICT_CLUSTERED) {
return;
}
page = buf_block_get_frame(block);
if (!page_is_leaf(page)) {
......@@ -872,6 +859,10 @@ ibuf_set_free_bits_func(
mtr_start(&mtr);
if (recv_recovery_is_on()) {
mtr_set_log_mode(&mtr, MTR_LOG_NONE);
}
space = buf_block_get_space(block);
page_no = buf_block_get_page_no(block);
zip_size = buf_block_get_zip_size(block);
......@@ -905,6 +896,14 @@ ibuf_set_free_bits_func(
#endif /* UNIV_IBUF_DEBUG */
ibuf_bitmap_page_set_bits(bitmap_page, page_no, zip_size,
IBUF_BITMAP_FREE, val, &mtr);
if (recv_recovery_is_on()) {
/* Do not acquire log_sys->mutex or attempt to
write to the redo log, because the lock is being
held by the crash recovery thread. */
mtr.modifications = FALSE;
}
mtr_commit(&mtr);
}
......@@ -915,14 +914,13 @@ work to only ibuf bitmap operations, which would result if the latch to the
bitmap page were kept. */
void
ibuf_reset_free_bits_with_type(
/*===========================*/
ulint type, /* in: index type */
ibuf_reset_free_bits(
/*=================*/
buf_block_t* block) /* in: index page; free bits are set to 0
if the index is a non-clustered
non-unique, and page level is 0 */
{
ibuf_set_free_bits(type, block, 0, ULINT_UNDEFINED);
ibuf_set_free_bits(block, 0, ULINT_UNDEFINED);
}
/**************************************************************************
......@@ -933,7 +931,6 @@ any further operations for this OS thread until mtr is committed. */
void
ibuf_update_free_bits_low(
/*======================*/
dict_index_t* index, /* in: index */
ulint zip_size, /* in: compressed page size in bytes;
0 for uncompressed pages */
buf_block_t* block, /* in: index page */
......@@ -950,8 +947,7 @@ ibuf_update_free_bits_low(
after = ibuf_index_page_calc_free(zip_size, block);
if (before != after) {
ibuf_set_free_bits_low(index->type, zip_size,
block, after, mtr);
ibuf_set_free_bits_low(zip_size, block, after, mtr);
}
}
......@@ -963,7 +959,6 @@ prevent any further operations until mtr is committed. */
void
ibuf_update_free_bits_for_two_pages_low(
/*====================================*/
dict_index_t* index, /* in: index */
ulint zip_size,/* in: compressed page size in bytes;
0 for uncompressed pages */
buf_block_t* block1, /* in: index page */
......@@ -980,11 +975,11 @@ ibuf_update_free_bits_for_two_pages_low(
state = ibuf_index_page_calc_free(zip_size, block1);
ibuf_set_free_bits_low(index->type, zip_size, block1, state, mtr);
ibuf_set_free_bits_low(zip_size, block1, state, mtr);
state = ibuf_index_page_calc_free(zip_size, block2);
ibuf_set_free_bits_low(index->type, zip_size, block2, state, mtr);
ibuf_set_free_bits_low(zip_size, block2, state, mtr);
mutex_exit(&ibuf_bitmap_mutex);
}
......
......@@ -61,9 +61,8 @@ work to only ibuf bitmap operations, which would result if the latch to the
bitmap page were kept. */
void
ibuf_reset_free_bits_with_type(
/*===========================*/
ulint type, /* in: index type */
ibuf_reset_free_bits(
/*=================*/
buf_block_t* block); /* in: index page; free bits are set to 0
if the index is a non-clustered
non-unique, and page level is 0 */
......@@ -76,7 +75,6 @@ UNIV_INLINE
void
ibuf_update_free_bits_if_full(
/*==========================*/
dict_index_t* index, /* in: index */
buf_block_t* block, /* in: index page to which we have added new
records; the free bits are updated if the
index is non-clustered and non-unique and
......@@ -97,7 +95,6 @@ UNIV_INLINE
void
ibuf_update_free_bits_zip(
/*======================*/
dict_index_t* index, /* in: index */
ulint zip_size,/* in: compressed page size in bytes */
buf_block_t* block); /* in: B-tree leaf page of a secondary
index */
......@@ -109,7 +106,6 @@ prevent any further operations for this OS thread until mtr is committed. */
void
ibuf_update_free_bits_low(
/*======================*/
dict_index_t* index, /* in: index */
ulint zip_size, /* in: compressed page size in bytes;
0 for uncompressed pages */
buf_block_t* block, /* in: index page */
......@@ -125,7 +121,6 @@ prevent any further operations until mtr is committed. */
void
ibuf_update_free_bits_for_two_pages_low(
/*====================================*/
dict_index_t* index, /* in: index */
ulint zip_size,/* in: compressed page size in bytes;
0 for uncompressed pages */
buf_block_t* block1, /* in: index page */
......
......@@ -59,10 +59,8 @@ were kept. */
void
ibuf_set_free_bits_func(
/*====================*/
ulint type, /* in: index type */
buf_block_t* block, /* in: index page; free bit is reset
if the index is a non-clustered
non-unique, and page level is 0 */
buf_block_t* block, /* in: index page of a non-clustered index;
free bit is reset if page level is 0 */
#ifdef UNIV_IBUF_DEBUG
ulint max_val,/* in: ULINT_UNDEFINED or a maximum
value which the bits must have before
......@@ -70,9 +68,9 @@ ibuf_set_free_bits_func(
#endif /* UNIV_IBUF_DEBUG */
ulint val); /* in: value to set: < 4 */
#ifdef UNIV_IBUF_DEBUG
# define ibuf_set_free_bits(t,b,v,max) ibuf_set_free_bits_func(t,b,max,v)
# define ibuf_set_free_bits(b,v,max) ibuf_set_free_bits_func(b,max,v)
#else /* UNIV_IBUF_DEBUG */
# define ibuf_set_free_bits(t,b,v,max) ibuf_set_free_bits_func(t,b,v)
# define ibuf_set_free_bits(b,v,max) ibuf_set_free_bits_func(b,v)
#endif /* UNIV_IBUF_DEBUG */
/**************************************************************************
......@@ -238,7 +236,6 @@ UNIV_INLINE
void
ibuf_update_free_bits_if_full(
/*==========================*/
dict_index_t* index, /* in: index */
buf_block_t* block, /* in: index page to which we have added new
records; the free bits are updated if the
index is non-clustered and non-unique and
......@@ -279,7 +276,7 @@ ibuf_update_free_bits_if_full(
}
if (before > after) {
ibuf_set_free_bits(index->type, block, after, before);
ibuf_set_free_bits(block, after, before);
}
}
......@@ -292,7 +289,6 @@ UNIV_INLINE
void
ibuf_update_free_bits_zip(
/*======================*/
dict_index_t* index, /* in: index */
ulint zip_size,/* in: compressed page size in bytes */
buf_block_t* block) /* in: B-tree leaf page of a secondary
index */
......@@ -308,5 +304,5 @@ ibuf_update_free_bits_zip(
buf_page_make_young(&block->page);
}
ibuf_set_free_bits(index->type, block, free_bits, ULINT_UNDEFINED);
ibuf_set_free_bits(block, free_bits, ULINT_UNDEFINED);
}
......@@ -20,7 +20,7 @@ ibool
recv_recovery_is_on(void)
/*=====================*/
{
return(recv_recovery_on);
return(UNIV_UNLIKELY(recv_recovery_on));
}
/***********************************************************************
......
......@@ -3887,8 +3887,7 @@ page_zip_reorganize(
if (!dict_index_is_clust(index) && page_is_leaf(page)) {
/* Recompute the insert buffer free bits. */
ibuf_update_free_bits_zip(index,
page_zip_get_size(page_zip), block);
ibuf_update_free_bits_zip(page_zip_get_size(page_zip), block);
}
buf_block_free(temp_block);
......
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