Commit 0f792cb2 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 eb02061c
......@@ -974,7 +974,8 @@ btr_page_reorganize_low(
}
/* 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(
index, page_zip_get_size(page_zip), block,
......@@ -1961,10 +1962,13 @@ func_start:
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
(!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;
}
......
......@@ -883,8 +883,10 @@ btr_cur_insert_if_possible(
rec = page_cur_tuple_insert(page_cursor, tuple,
cursor->index, ext, n_ext, mtr);
if (UNIV_UNLIKELY(!rec)) {
/* If record did not fit, reorganize */
if (UNIV_UNLIKELY(!rec) && !buf_block_get_page_zip(block)) {
/* 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)) {
......@@ -1173,8 +1175,13 @@ fail_err:
}
}
if (UNIV_UNLIKELY(!*rec) && !zip_size) {
/* If the record did not fit, reorganize */
if (UNIV_LIKELY(*rec != NULL)) {
} 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))) {
ut_error;
}
......
......@@ -1632,12 +1632,7 @@ ibuf_data_enough_free_for_insert(
inserts buffered for pages that we read to the buffer pool, without
any risk of running out of free space in the insert buffer. */
if (data->free_list_len >= data->size / 2 + 3 * data->height) {
return(TRUE);
}
return(FALSE);
return(data->free_list_len >= data->size / 2 + 3 * data->height);
}
/*************************************************************************
......@@ -2930,58 +2925,65 @@ dump:
rec = page_cur_tuple_insert(&page_cur, entry, index,
NULL, 0, mtr);
if (UNIV_UNLIKELY(rec == NULL)) {
/* If the record did not fit, reorganize */
if (UNIV_LIKELY(rec != NULL)) {
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,
PAGE_CUR_LE, &page_cur);
goto ibuf_fail;
}
/* This time the record must fit */
if (UNIV_UNLIKELY
(!page_cur_tuple_insert(&page_cur, entry, index,
NULL, 0, mtr))) {
/* If the record did not fit, reorganize */
ulint space;
ulint page_no;
ulint zip_size;
btr_page_reorganize(block, index, mtr);
page_cur_search(block, index, entry, PAGE_CUR_LE, &page_cur);
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,
"InnoDB: Error: Insert buffer insert"
" fails; page free %lu,"
" dtuple size %lu\n",
(ulong) page_get_max_insert_size(
page, 1),
(ulong) rec_get_converted_size(
index, entry, NULL, 0));
fputs("InnoDB: Cannot insert index record ",
stderr);
dtuple_print(stderr, entry);
fputs("\nInnoDB: The table where"
" this index record belongs\n"
"InnoDB: is now probably corrupt."
" Please run CHECK TABLE on\n"
"InnoDB: that table.\n", stderr);
space = page_get_space_id(page);
zip_size = buf_block_get_zip_size(block);
page_no = page_get_page_no(page);
bitmap_page = ibuf_bitmap_get_map_page(
space, page_no, zip_size, mtr);
old_bits = ibuf_bitmap_page_get_bits(
bitmap_page, page_no, zip_size,
IBUF_BITMAP_FREE, mtr);
fprintf(stderr, "Bitmap bits %lu\n",
(ulong) old_bits);
fputs("InnoDB: Submit a detailed bug report"
" to http://bugs.mysql.com\n", stderr);
}
ibuf_fail:
ut_print_timestamp(stderr);
fprintf(stderr,
"InnoDB: Error: Insert buffer insert"
" fails; page free %lu,"
" dtuple size %lu\n",
(ulong) page_get_max_insert_size(
page, 1),
(ulong) rec_get_converted_size(
index, entry, NULL, 0));
fputs("InnoDB: Cannot insert index record ",
stderr);
dtuple_print(stderr, entry);
fputs("\nInnoDB: The table where"
" this index record belongs\n"
"InnoDB: is now probably corrupt."
" Please run CHECK TABLE on\n"
"InnoDB: that table.\n", stderr);
space = page_get_space_id(page);
zip_size = buf_block_get_zip_size(block);
page_no = page_get_page_no(page);
bitmap_page = ibuf_bitmap_get_map_page(
space, page_no, zip_size, mtr);
old_bits = ibuf_bitmap_page_get_bits(
bitmap_page, page_no, zip_size,
IBUF_BITMAP_FREE, mtr);
fprintf(stderr, "Bitmap bits %lu\n",
(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
#include "dict0dict.h"
#include "btr0sea.h"
#include "btr0cur.h"
#include "ibuf0ibuf.h"
#include "page0types.h"
#include "lock0lock.h"
#include "log0recv.h"
......@@ -3872,6 +3873,13 @@ page_zip_reorganize(
lock_move_reorganize_page(block, temp_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);
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