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,58 +2925,65 @@ ibuf_insert_to_index_page( ...@@ -2930,58 +2925,65 @@ 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)) {
/* If the record did not fit, reorganize */ return;
}
btr_page_reorganize(block, index, mtr); if (UNIV_LIKELY_NULL(buf_block_get_page_zip(block))) {
/* For compressed pages, reorganization was
attempted (in vain) in page_cur_tuple_insert(). */
page_cur_search(block, index, entry, goto ibuf_fail;
PAGE_CUR_LE, &page_cur); }
/* This time the record must fit */ /* If the record did not fit, reorganize */
if (UNIV_UNLIKELY
(!page_cur_tuple_insert(&page_cur, entry, index,
NULL, 0, mtr))) {
ulint space; btr_page_reorganize(block, index, mtr);
ulint page_no; page_cur_search(block, index, entry, PAGE_CUR_LE, &page_cur);
ulint zip_size;
ut_print_timestamp(stderr); /* This time the record must fit */
if (UNIV_UNLIKELY
(!page_cur_tuple_insert(&page_cur, entry, index,
NULL, 0, mtr))) {
ulint space;
ulint page_no;
ulint zip_size;
fprintf(stderr, ibuf_fail:
"InnoDB: Error: Insert buffer insert" ut_print_timestamp(stderr);
" fails; page free %lu,"
" dtuple size %lu\n", fprintf(stderr,
(ulong) page_get_max_insert_size( "InnoDB: Error: Insert buffer insert"
page, 1), " fails; page free %lu,"
(ulong) rec_get_converted_size( " dtuple size %lu\n",
index, entry, NULL, 0)); (ulong) page_get_max_insert_size(
fputs("InnoDB: Cannot insert index record ", page, 1),
stderr); (ulong) rec_get_converted_size(
dtuple_print(stderr, entry); index, entry, NULL, 0));
fputs("\nInnoDB: The table where" fputs("InnoDB: Cannot insert index record ",
" this index record belongs\n" stderr);
"InnoDB: is now probably corrupt." dtuple_print(stderr, entry);
" Please run CHECK TABLE on\n" fputs("\nInnoDB: The table where"
"InnoDB: that table.\n", stderr); " this index record belongs\n"
"InnoDB: is now probably corrupt."
space = page_get_space_id(page); " Please run CHECK TABLE on\n"
zip_size = buf_block_get_zip_size(block); "InnoDB: that table.\n", stderr);
page_no = page_get_page_no(page);
space = page_get_space_id(page);
bitmap_page = ibuf_bitmap_get_map_page( zip_size = buf_block_get_zip_size(block);
space, page_no, zip_size, mtr); page_no = page_get_page_no(page);
old_bits = ibuf_bitmap_page_get_bits(
bitmap_page, page_no, zip_size, bitmap_page = ibuf_bitmap_get_map_page(
IBUF_BITMAP_FREE, mtr); space, page_no, zip_size, mtr);
old_bits = ibuf_bitmap_page_get_bits(
fprintf(stderr, "Bitmap bits %lu\n", bitmap_page, page_no, zip_size,
(ulong) old_bits); IBUF_BITMAP_FREE, mtr);
fputs("InnoDB: Submit a detailed bug report" fprintf(stderr, "Bitmap bits %lu\n",
" to http://bugs.mysql.com\n", stderr); (ulong) old_bits);
}
fputs("InnoDB: Submit a detailed bug report"
" 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