summaryrefslogtreecommitdiff
path: root/storage/xtradb/include/ibuf0ibuf.ic
diff options
context:
space:
mode:
Diffstat (limited to 'storage/xtradb/include/ibuf0ibuf.ic')
-rw-r--r--storage/xtradb/include/ibuf0ibuf.ic64
1 files changed, 29 insertions, 35 deletions
diff --git a/storage/xtradb/include/ibuf0ibuf.ic b/storage/xtradb/include/ibuf0ibuf.ic
index 043d7c472d8..21747fdceac 100644
--- a/storage/xtradb/include/ibuf0ibuf.ic
+++ b/storage/xtradb/include/ibuf0ibuf.ic
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1997, 2013, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc.,
-51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -28,9 +28,6 @@ Created 7/19/1997 Heikki Tuuri
#ifndef UNIV_HOTBACKUP
#include "buf0lru.h"
-/** Counter for ibuf_should_try() */
-extern ulint ibuf_flush_count;
-
/** An index page must contain at least UNIV_PAGE_SIZE /
IBUF_PAGE_SIZE_PER_FREE_SPACE bytes of free space for ibuf to try to
buffer inserts to this page. If there is this much of free space, the
@@ -62,7 +59,7 @@ ibuf_mtr_commit(
}
/** Insert buffer struct */
-struct ibuf_struct{
+struct ibuf_t{
ulint size; /*!< current size of the ibuf index
tree, in pages */
ulint max_size; /*!< recommended maximum size of the
@@ -70,10 +67,10 @@ struct ibuf_struct{
ulint seg_size; /*!< allocated pages of the file
segment containing ibuf header and
tree */
- ibool empty; /*!< Protected by the page
+ bool empty; /*!< Protected by the page
latch of the root page of the
insert buffer tree
- (FSP_IBUF_TREE_ROOT_PAGE_NO). TRUE
+ (FSP_IBUF_TREE_ROOT_PAGE_NO). true
if and only if the insert
buffer tree is empty. */
ulint free_list_len; /*!< length of the free list */
@@ -127,21 +124,11 @@ ibuf_should_try(
a secondary index when we
decide */
{
- if (ibuf_use != IBUF_USE_NONE
- && !dict_index_is_clust(index)
- && (ignore_sec_unique || !dict_index_is_unique(index))) {
-
- ibuf_flush_count++;
-
- if (ibuf_flush_count % 4 == 0) {
-
- buf_LRU_try_free_flushed_blocks(NULL);
- }
-
- return(TRUE);
- }
-
- return(FALSE);
+ return(ibuf_use != IBUF_USE_NONE
+ && ibuf->max_size != 0
+ && !dict_index_is_clust(index)
+ && index->table->quiesce == QUIESCE_NONE
+ && (ignore_sec_unique || !dict_index_is_unique(index)));
}
/******************************************************************//**
@@ -174,12 +161,11 @@ ibuf_bitmap_page(
ut_ad(ut_is_2pow(zip_size));
if (!zip_size) {
- return(UNIV_UNLIKELY((page_no & (UNIV_PAGE_SIZE - 1))
- == FSP_IBUF_BITMAP_OFFSET));
+ return((page_no & (UNIV_PAGE_SIZE - 1))
+ == FSP_IBUF_BITMAP_OFFSET);
}
- return(UNIV_UNLIKELY((page_no & (zip_size - 1))
- == FSP_IBUF_BITMAP_OFFSET));
+ return((page_no & (zip_size - 1)) == FSP_IBUF_BITMAP_OFFSET);
}
/*********************************************************************//**
@@ -197,7 +183,7 @@ ibuf_index_page_calc_free_bits(
ulint n;
ut_ad(ut_is_2pow(zip_size));
ut_ad(!zip_size || zip_size > IBUF_PAGE_SIZE_PER_FREE_SPACE);
- ut_ad(zip_size <= UNIV_PAGE_SIZE);
+ ut_ad(zip_size <= UNIV_ZIP_SIZE_MAX);
if (zip_size) {
n = max_ins_size
@@ -232,7 +218,7 @@ ibuf_index_page_calc_free_from_bits(
ut_ad(bits < 4);
ut_ad(ut_is_2pow(zip_size));
ut_ad(!zip_size || zip_size > IBUF_PAGE_SIZE_PER_FREE_SPACE);
- ut_ad(zip_size <= UNIV_PAGE_SIZE);
+ ut_ad(zip_size <= UNIV_ZIP_SIZE_MAX);
if (zip_size) {
if (bits == 3) {
@@ -267,16 +253,24 @@ ibuf_index_page_calc_free_zip(
ut_ad(zip_size == buf_block_get_zip_size(block));
ut_ad(zip_size);
- max_ins_size = page_get_max_insert_size_after_reorganize(
+ /* Consider the maximum insert size on the uncompressed page
+ without reorganizing the page. We must not assume anything
+ about the compression ratio. If zip_max_ins > max_ins_size and
+ there is 1/4 garbage on the page, recompression after the
+ reorganize could fail, in theory. So, let us guarantee that
+ merging a buffered insert to a compressed page will always
+ succeed without reorganizing or recompressing the page, just
+ by using the page modification log. */
+ max_ins_size = page_get_max_insert_size(
buf_block_get_frame(block), 1);
page_zip = buf_block_get_page_zip(block);
zip_max_ins = page_zip_max_ins_size(page_zip,
FALSE/* not clustered */);
- if (UNIV_UNLIKELY(zip_max_ins < 0)) {
+ if (zip_max_ins < 0) {
return(0);
- } else if (UNIV_LIKELY(max_ins_size > (ulint) zip_max_ins)) {
+ } else if (max_ins_size > (ulint) zip_max_ins) {
max_ins_size = (ulint) zip_max_ins;
}
@@ -345,8 +339,8 @@ ibuf_update_free_bits_if_full(
before = ibuf_index_page_calc_free_bits(0, max_ins_size);
if (max_ins_size >= increase) {
-#if ULINT32_UNDEFINED <= UNIV_PAGE_SIZE
-# error "ULINT32_UNDEFINED <= UNIV_PAGE_SIZE"
+#if ULINT32_UNDEFINED <= UNIV_PAGE_SIZE_MAX
+# error "ULINT32_UNDEFINED <= UNIV_PAGE_SIZE_MAX"
#endif
after = ibuf_index_page_calc_free_bits(0, max_ins_size
- increase);