Commit 705dfc7c authored by marko's avatar marko

branches/zip: Many places: Avoid re-reorganizing compressed pages after

failing insert.  Reorganization will have been attempted in
page_cur_tuple_insert() or page_cur_rec_insert().

page_zip_reorganize(): Recompute the insert buffer free bits for
leaf pages of secondary indexes.

ibuf_data_enough_free_for_insert(): Simplify.
parent e08004c5
...@@ -974,7 +974,8 @@ btr_page_reorganize_low( ...@@ -974,7 +974,8 @@ btr_page_reorganize_low(
} }
/* On compressed pages, recompute the insert buffer free bits. */ /* On compressed pages, recompute the insert buffer free bits. */
if (UNIV_LIKELY_NULL(page_zip) && !dict_index_is_clust(index)) { if (UNIV_LIKELY_NULL(page_zip)
&& !dict_index_is_clust(index) && page_is_leaf(page)) {
ibuf_update_free_bits_if_full( ibuf_update_free_bits_if_full(
index, page_zip_get_size(page_zip), block, index, page_zip_get_size(page_zip), block,
...@@ -1961,10 +1962,13 @@ btr_page_split_and_insert( ...@@ -1961,10 +1962,13 @@ btr_page_split_and_insert(
goto func_exit; goto func_exit;
} }
/* 8. If insert did not fit, try page reorganization */ /* 8. If insert did not fit, try page reorganization.
For compressed pages, that is already attempted in
page_cur_tuple_insert(). */
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!btr_page_reorganize(insert_block, cursor->index, mtr))) { (buf_block_get_page_zip(insert_block)
|| !btr_page_reorganize(insert_block, cursor->index, mtr))) {
goto insert_failed; goto insert_failed;
} }
......
...@@ -883,8 +883,10 @@ btr_cur_insert_if_possible( ...@@ -883,8 +883,10 @@ btr_cur_insert_if_possible(
rec = page_cur_tuple_insert(page_cursor, tuple, rec = page_cur_tuple_insert(page_cursor, tuple,
cursor->index, ext, n_ext, mtr); cursor->index, ext, n_ext, mtr);
if (UNIV_UNLIKELY(!rec)) { if (UNIV_UNLIKELY(!rec) && !buf_block_get_page_zip(block)) {
/* If record did not fit, reorganize */ /* If record did not fit, reorganize.
For compressed pages, this is attempted already in
page_cur_tuple_insert(). */
if (btr_page_reorganize(block, cursor->index, mtr)) { if (btr_page_reorganize(block, cursor->index, mtr)) {
...@@ -1173,8 +1175,13 @@ btr_cur_optimistic_insert( ...@@ -1173,8 +1175,13 @@ btr_cur_optimistic_insert(
} }
} }
if (UNIV_UNLIKELY(!*rec) && !zip_size) { if (UNIV_LIKELY(*rec != NULL)) {
/* If the record did not fit, reorganize */ } else if (zip_size) {
/* If the record did not fit on a compressed page, fail. */
goto fail;
} else {
/* If the record did not fit, reorganize. For compressed
pages, this is attempted already in page_cur_tuple_insert(). */
if (UNIV_UNLIKELY(!btr_page_reorganize(block, index, mtr))) { if (UNIV_UNLIKELY(!btr_page_reorganize(block, index, mtr))) {
ut_error; ut_error;
} }
......
...@@ -1632,12 +1632,7 @@ ibuf_data_enough_free_for_insert( ...@@ -1632,12 +1632,7 @@ ibuf_data_enough_free_for_insert(
inserts buffered for pages that we read to the buffer pool, without inserts buffered for pages that we read to the buffer pool, without
any risk of running out of free space in the insert buffer. */ any risk of running out of free space in the insert buffer. */
if (data->free_list_len >= data->size / 2 + 3 * data->height) { return(data->free_list_len >= data->size / 2 + 3 * data->height);
return(TRUE);
}
return(FALSE);
} }
/************************************************************************* /*************************************************************************
...@@ -2930,23 +2925,31 @@ ibuf_insert_to_index_page( ...@@ -2930,23 +2925,31 @@ ibuf_insert_to_index_page(
rec = page_cur_tuple_insert(&page_cur, entry, index, rec = page_cur_tuple_insert(&page_cur, entry, index,
NULL, 0, mtr); NULL, 0, mtr);
if (UNIV_UNLIKELY(rec == NULL)) { if (UNIV_LIKELY(rec != NULL)) {
return;
}
if (UNIV_LIKELY_NULL(buf_block_get_page_zip(block))) {
/* For compressed pages, reorganization was
attempted (in vain) in page_cur_tuple_insert(). */
goto ibuf_fail;
}
/* If the record did not fit, reorganize */ /* If the record did not fit, reorganize */
btr_page_reorganize(block, index, mtr); btr_page_reorganize(block, index, mtr);
page_cur_search(block, index, entry, PAGE_CUR_LE, &page_cur);
page_cur_search(block, index, entry,
PAGE_CUR_LE, &page_cur);
/* This time the record must fit */ /* This time the record must fit */
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_cur_tuple_insert(&page_cur, entry, index, (!page_cur_tuple_insert(&page_cur, entry, index,
NULL, 0, mtr))) { NULL, 0, mtr))) {
ulint space; ulint space;
ulint page_no; ulint page_no;
ulint zip_size; ulint zip_size;
ibuf_fail:
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
...@@ -2983,7 +2986,6 @@ ibuf_insert_to_index_page( ...@@ -2983,7 +2986,6 @@ ibuf_insert_to_index_page(
" to http://bugs.mysql.com\n", stderr); " to http://bugs.mysql.com\n", stderr);
} }
} }
}
} }
/************************************************************************* /*************************************************************************
......
...@@ -19,6 +19,7 @@ Created June 2005 by Marko Makela ...@@ -19,6 +19,7 @@ Created June 2005 by Marko Makela
#include "dict0dict.h" #include "dict0dict.h"
#include "btr0sea.h" #include "btr0sea.h"
#include "btr0cur.h" #include "btr0cur.h"
#include "ibuf0ibuf.h"
#include "page0types.h" #include "page0types.h"
#include "lock0lock.h" #include "lock0lock.h"
#include "log0recv.h" #include "log0recv.h"
...@@ -3872,6 +3873,13 @@ page_zip_reorganize( ...@@ -3872,6 +3873,13 @@ page_zip_reorganize(
lock_move_reorganize_page(block, temp_block); lock_move_reorganize_page(block, temp_block);
btr_search_drop_page_hash_index(block); btr_search_drop_page_hash_index(block);
if (!dict_index_is_clust(index) && page_is_leaf(page)) {
/* Recompute the insert buffer free bits. */
ibuf_update_free_bits_if_full(
index, page_zip_get_size(page_zip), block,
UNIV_PAGE_SIZE, ULINT_UNDEFINED);
}
buf_block_free(temp_block); buf_block_free(temp_block);
return(TRUE); return(TRUE);
} }
......
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