2009-02-17 08:59:22 +00:00
|
|
|
/*****************************************************************************
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2009-02-17 08:59:22 +00:00
|
|
|
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2009-02-17 08:59:22 +00:00
|
|
|
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
|
|
|
|
Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
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., 59 Temple
|
|
|
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
*****************************************************************************/
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**************************************************//**
|
|
|
|
@file include/buf0buf.h
|
2005-10-27 07:29:40 +00:00
|
|
|
The database buffer pool high-level routines
|
|
|
|
|
|
|
|
Created 11/5/1995 Heikki Tuuri
|
|
|
|
*******************************************************/
|
|
|
|
|
|
|
|
#ifndef buf0buf_h
|
|
|
|
#define buf0buf_h
|
|
|
|
|
|
|
|
#include "univ.i"
|
|
|
|
#include "fil0fil.h"
|
|
|
|
#include "mtr0types.h"
|
|
|
|
#include "buf0types.h"
|
|
|
|
#include "hash0hash.h"
|
|
|
|
#include "ut0byte.h"
|
2005-10-27 11:48:10 +00:00
|
|
|
#include "page0types.h"
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
|
|
#include "os0proc.h"
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-27 06:57:25 +00:00
|
|
|
/** @name Modes for buf_page_get_gen */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
|
|
|
#define BUF_GET 10 /*!< get always */
|
|
|
|
#define BUF_GET_IF_IN_POOL 11 /*!< get if in pool */
|
|
|
|
#define BUF_GET_NO_LATCH 14 /*!< get and bufferfix, but
|
|
|
|
set no latch; we have
|
|
|
|
separated this case, because
|
|
|
|
it is error-prone programming
|
|
|
|
not to set a latch, and it
|
|
|
|
should be used with care */
|
|
|
|
/* @} */
|
2009-05-27 06:57:25 +00:00
|
|
|
/** @name Modes for buf_page_get_known_nowait */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
|
|
|
#define BUF_MAKE_YOUNG 51 /*!< Move the block to the
|
|
|
|
start of the LRU list if there
|
|
|
|
is a danger that the block
|
|
|
|
would drift out of the buffer
|
|
|
|
pool*/
|
|
|
|
#define BUF_KEEP_OLD 52 /*!< Preserve the current LRU
|
|
|
|
position of the block. */
|
|
|
|
/* @} */
|
|
|
|
|
|
|
|
extern buf_pool_t* buf_pool; /*!< The buffer pool of the database */
|
2005-10-27 07:29:40 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
2009-05-26 12:28:49 +00:00
|
|
|
extern ibool buf_debug_prints;/*!< If this is set TRUE, the program
|
2005-10-27 07:29:40 +00:00
|
|
|
prints info whenever read or flush
|
|
|
|
occurs */
|
|
|
|
#endif /* UNIV_DEBUG */
|
2009-05-26 12:28:49 +00:00
|
|
|
extern ulint srv_buf_pool_write_requests; /*!< variable to count write request
|
2006-02-23 19:25:29 +00:00
|
|
|
issued */
|
2009-03-23 14:21:34 +00:00
|
|
|
#else /* !UNIV_HOTBACKUP */
|
2009-05-26 12:28:49 +00:00
|
|
|
extern buf_block_t* back_block1; /*!< first block, for --apply-log */
|
|
|
|
extern buf_block_t* back_block2; /*!< second block, for page reorganize */
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/** Magic value to use instead of checksums when they are disabled */
|
2009-03-23 14:21:34 +00:00
|
|
|
#define BUF_NO_CHECKSUM_MAGIC 0xDEADBEEFUL
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 12:09:24 +00:00
|
|
|
/** @brief States of a control block
|
|
|
|
@see buf_page_struct
|
|
|
|
|
2006-12-05 12:10:30 +00:00
|
|
|
The enumeration values must be 0..7. */
|
2006-11-24 08:32:18 +00:00
|
|
|
enum buf_page_state {
|
2009-05-25 12:09:24 +00:00
|
|
|
BUF_BLOCK_ZIP_FREE = 0, /*!< contains a free
|
|
|
|
compressed page */
|
|
|
|
BUF_BLOCK_ZIP_PAGE, /*!< contains a clean
|
|
|
|
compressed page */
|
|
|
|
BUF_BLOCK_ZIP_DIRTY, /*!< contains a compressed
|
|
|
|
page that is in the
|
|
|
|
buf_pool->flush_list */
|
2006-12-05 12:10:30 +00:00
|
|
|
|
2009-05-25 12:09:24 +00:00
|
|
|
BUF_BLOCK_NOT_USED, /*!< is in the free list;
|
|
|
|
must be after the BUF_BLOCK_ZIP_
|
|
|
|
constants for compressed-only pages
|
|
|
|
@see buf_block_state_valid() */
|
|
|
|
BUF_BLOCK_READY_FOR_USE, /*!< when buf_LRU_get_free_block
|
|
|
|
returns a block, it is in this state */
|
|
|
|
BUF_BLOCK_FILE_PAGE, /*!< contains a buffered file page */
|
|
|
|
BUF_BLOCK_MEMORY, /*!< contains some main memory
|
|
|
|
object */
|
|
|
|
BUF_BLOCK_REMOVE_HASH /*!< hash index should be removed
|
2006-11-23 13:26:01 +00:00
|
|
|
before putting to the free list */
|
|
|
|
};
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Creates the buffer pool.
|
|
|
|
@return own: buf_pool object, NULL if not enough memory or error */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_pool_t*
|
2006-11-14 14:27:26 +00:00
|
|
|
buf_pool_init(void);
|
|
|
|
/*===============*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2008-01-16 12:44:44 +00:00
|
|
|
Frees the buffer pool at shutdown. This must not be invoked before
|
|
|
|
freeing all mutexes. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2008-01-16 12:44:44 +00:00
|
|
|
void
|
|
|
|
buf_pool_free(void);
|
|
|
|
/*===============*/
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
branches/zip: Make innodb_adaptive_hash_index settable.
btr_search_disabled: Rename to btr_search_enabled and change the type
to char, so that it can be directly linked to the MySQL parameters.
Note that the variable is protected by btr_search_latch and
btr_search_enabled_mutex, a new mutex introduced in this patch.
btr_search_enabled_mutex: A new mutex, to protect btr_search_enabled
together with btr_search_latch.
buf_pool_drop_hash_index(): New function, to be called from
btr_search_disable().
btr_search_disable(), btr_search_enable(): Fix bugs. These functions
were previously unused.
btr_search_guess_on_hash(), btr_search_build_page_hash_index():
Check btr_search_enabled once more, while holding btr_search_latch.
btr_cur_search_to_nth_level(): Note that the reads of btr_search_enabled
may be dirty and explain why it should not be a problem.
innobase_adaptive_hash_index: Remove. The variable btr_search_enabled will be used directly instead.
innodb_adaptive_hash_index_update(): New function, an update callback for
innodb_adaptive_hash_index. This will call either btr_search_disable()
or btr_search_enable() when the value is assigned. The functions will
be called even if the value does not appear to be changed, e.g., when
setting from TRUE to TRUE or FALSE to FALSE.
rb://85 approved by Heikki Tuuri. This addresses Issue #163.
2009-01-30 21:30:29 +00:00
|
|
|
Drops the adaptive hash index. To prevent a livelock, this function
|
|
|
|
is only to be called while holding btr_search_latch and while
|
|
|
|
btr_search_enabled == FALSE. */
|
|
|
|
UNIV_INTERN
|
|
|
|
void
|
|
|
|
buf_pool_drop_hash_index(void);
|
|
|
|
/*==========================*/
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2006-12-14 15:15:51 +00:00
|
|
|
Relocate a buffer control block. Relocates the block on the LRU list
|
2008-02-29 08:20:17 +00:00
|
|
|
and in buf_pool->page_hash. Does not relocate bpage->list.
|
|
|
|
The caller must take care of relocating bpage->list. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-12-14 15:15:51 +00:00
|
|
|
void
|
|
|
|
buf_relocate(
|
|
|
|
/*=========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* bpage, /*!< in/out: control block being relocated;
|
2008-02-29 08:20:17 +00:00
|
|
|
buf_page_get_state(bpage) must be
|
|
|
|
BUF_BLOCK_ZIP_DIRTY or BUF_BLOCK_ZIP_PAGE */
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* dpage) /*!< in/out: destination control block */
|
2006-12-14 15:15:51 +00:00
|
|
|
__attribute__((nonnull));
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2006-11-14 14:27:26 +00:00
|
|
|
Resizes the buffer pool. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-11-14 14:27:26 +00:00
|
|
|
void
|
|
|
|
buf_pool_resize(void);
|
|
|
|
/*=================*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the current size of buffer buf_pool in bytes.
|
|
|
|
@return size in bytes */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_pool_get_curr_size(void);
|
|
|
|
/*========================*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Gets the smallest oldest_modification lsn for any page in the pool. Returns
|
2009-05-25 05:30:14 +00:00
|
|
|
zero if all modified pages have been flushed to disk.
|
|
|
|
@return oldest modification in pool, zero if none */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
2006-11-29 14:52:16 +00:00
|
|
|
ib_uint64_t
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_pool_get_oldest_modification(void);
|
|
|
|
/*==================================*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Allocates a buffer block.
|
|
|
|
@return own: the allocated block, in state BUF_BLOCK_MEMORY */
|
2006-08-17 11:57:51 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
buf_block_t*
|
|
|
|
buf_block_alloc(
|
|
|
|
/*============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint zip_size); /*!< in: compressed page size in bytes,
|
2006-08-17 11:57:51 +00:00
|
|
|
or 0 if uncompressed tablespace */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2006-08-17 11:57:51 +00:00
|
|
|
Frees a buffer block which does not contain a file page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_block_free(
|
|
|
|
/*===========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block); /*!< in, own: block to be freed */
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Copies contents of a buffer frame to a given buffer.
|
|
|
|
@return buf */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
byte*
|
|
|
|
buf_frame_copy(
|
|
|
|
/*===========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
byte* buf, /*!< in: buffer to copy to */
|
|
|
|
const buf_frame_t* frame); /*!< in: buffer frame */
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-25 09:52:29 +00:00
|
|
|
/**************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
NOTE! The following macros should be used instead of buf_page_get_gen,
|
|
|
|
to improve debugging. Only values RW_S_LATCH and RW_X_LATCH are allowed
|
|
|
|
in LA! */
|
2007-01-18 09:59:00 +00:00
|
|
|
#define buf_page_get(SP, ZS, OF, LA, MTR) buf_page_get_gen(\
|
|
|
|
SP, ZS, OF, LA, NULL,\
|
2005-10-27 07:29:40 +00:00
|
|
|
BUF_GET, __FILE__, __LINE__, MTR)
|
2009-05-25 09:52:29 +00:00
|
|
|
/**************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Use these macros to bufferfix a page with no latching. Remember not to
|
|
|
|
read the contents of the page unless you know it is safe. Do not modify
|
|
|
|
the contents of the page! We have separated this case, because it is
|
|
|
|
error-prone programming not to set a latch, and it should be used
|
|
|
|
with care. */
|
2007-01-18 09:59:00 +00:00
|
|
|
#define buf_page_get_with_no_latch(SP, ZS, OF, MTR) buf_page_get_gen(\
|
|
|
|
SP, ZS, OF, RW_NO_LATCH, NULL,\
|
2005-10-27 07:29:40 +00:00
|
|
|
BUF_GET_NO_LATCH, __FILE__, __LINE__, MTR)
|
2009-05-25 09:52:29 +00:00
|
|
|
/**************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
NOTE! The following macros should be used instead of
|
|
|
|
buf_page_optimistic_get_func, to improve debugging. Only values RW_S_LATCH and
|
|
|
|
RW_X_LATCH are allowed as LA! */
|
2006-10-30 13:48:08 +00:00
|
|
|
#define buf_page_optimistic_get(LA, BL, MC, MTR) \
|
|
|
|
buf_page_optimistic_get_func(LA, BL, MC, __FILE__, __LINE__, MTR)
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
This is the general function used to get optimistic access to a database
|
2009-05-25 05:30:14 +00:00
|
|
|
page.
|
|
|
|
@return TRUE if success */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
buf_page_optimistic_get_func(
|
|
|
|
/*=========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH */
|
|
|
|
buf_block_t* block, /*!< in: guessed block */
|
|
|
|
ib_uint64_t modify_clock,/*!< in: modify clock value if mode is
|
2005-10-27 07:29:40 +00:00
|
|
|
..._GUESS_ON_CLOCK */
|
2009-05-25 05:30:14 +00:00
|
|
|
const char* file, /*!< in: file name */
|
|
|
|
ulint line, /*!< in: line where called */
|
|
|
|
mtr_t* mtr); /*!< in: mini-transaction */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
This is used to get access to a known database page, when no waiting can be
|
2009-05-25 05:30:14 +00:00
|
|
|
done.
|
|
|
|
@return TRUE if success */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
buf_page_get_known_nowait(
|
|
|
|
/*======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH */
|
|
|
|
buf_block_t* block, /*!< in: the known page */
|
|
|
|
ulint mode, /*!< in: BUF_MAKE_YOUNG or BUF_KEEP_OLD */
|
|
|
|
const char* file, /*!< in: file name */
|
|
|
|
ulint line, /*!< in: line where called */
|
|
|
|
mtr_t* mtr); /*!< in: mini-transaction */
|
2007-09-27 14:35:18 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2007-09-27 14:35:18 +00:00
|
|
|
Given a tablespace id and page number tries to get that page. If the
|
|
|
|
page is not in the buffer pool it is not loaded and NULL is returned.
|
|
|
|
Suitable for using when holding the kernel mutex. */
|
2009-06-04 05:58:23 +00:00
|
|
|
UNIV_INTERN
|
2007-10-01 07:32:45 +00:00
|
|
|
const buf_block_t*
|
2007-09-27 14:35:18 +00:00
|
|
|
buf_page_try_get_func(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space_id,/*!< in: tablespace id */
|
|
|
|
ulint page_no,/*!< in: page number */
|
|
|
|
const char* file, /*!< in: file name */
|
|
|
|
ulint line, /*!< in: line where called */
|
|
|
|
mtr_t* mtr); /*!< in: mini-transaction */
|
2007-09-27 14:35:18 +00:00
|
|
|
|
2009-06-04 05:58:23 +00:00
|
|
|
/** Tries to get a page. If the page is not in the buffer pool it is
|
|
|
|
not loaded. Suitable for using when holding the kernel mutex.
|
|
|
|
@param space_id in: tablespace id
|
|
|
|
@param page_no in: page number
|
|
|
|
@param mtr in: mini-transaction
|
|
|
|
@return the page if in buffer pool, NULL if not */
|
2007-09-27 14:35:18 +00:00
|
|
|
#define buf_page_try_get(space_id, page_no, mtr) \
|
|
|
|
buf_page_try_get_func(space_id, page_no, __FILE__, __LINE__, mtr);
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2008-01-24 08:12:02 +00:00
|
|
|
Get read access to a compressed page (usually of type
|
|
|
|
FIL_PAGE_TYPE_ZBLOB or FIL_PAGE_TYPE_ZBLOB2).
|
2008-01-16 10:45:14 +00:00
|
|
|
The page must be released with buf_page_release_zip().
|
|
|
|
NOTE: the page is not protected by any latch. Mutual exclusion has to
|
|
|
|
be implemented at a higher level. In other words, all possible
|
|
|
|
accesses to a given page through this function must be protected by
|
2009-05-25 05:30:14 +00:00
|
|
|
the same set of mutexes or latches.
|
|
|
|
@return pointer to the block, or NULL if not compressed */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2007-01-18 23:10:49 +00:00
|
|
|
buf_page_t*
|
|
|
|
buf_page_get_zip(
|
|
|
|
/*=============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size */
|
|
|
|
ulint offset);/*!< in: page number */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
This is the general function used to get access to a database page.
|
|
|
|
@return pointer to the block or NULL */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t*
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_page_get_gen(
|
|
|
|
/*=============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint offset, /*!< in: page number */
|
|
|
|
ulint rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
|
|
|
|
buf_block_t* guess, /*!< in: guessed block or NULL */
|
|
|
|
ulint mode, /*!< in: BUF_GET, BUF_GET_IF_IN_POOL,
|
2005-10-27 07:29:40 +00:00
|
|
|
BUF_GET_NO_LATCH */
|
2009-05-25 05:30:14 +00:00
|
|
|
const char* file, /*!< in: file name */
|
|
|
|
ulint line, /*!< in: line where called */
|
|
|
|
mtr_t* mtr); /*!< in: mini-transaction */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Initializes a page to the buffer buf_pool. The page is usually not read
|
|
|
|
from a file even if it cannot be found in the buffer buf_pool. This is one
|
|
|
|
of the functions which perform to a block a state transition NOT_USED =>
|
2009-05-25 05:30:14 +00:00
|
|
|
FILE_PAGE (the other is buf_page_get_gen).
|
|
|
|
@return pointer to the block, page bufferfixed */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t*
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_page_create(
|
|
|
|
/*============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset, /*!< in: offset of the page within space in units of
|
2005-10-27 07:29:40 +00:00
|
|
|
a page */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint zip_size,/*!< in: compressed page size, or 0 */
|
|
|
|
mtr_t* mtr); /*!< in: mini-transaction handle */
|
2009-03-23 14:21:34 +00:00
|
|
|
#else /* !UNIV_HOTBACKUP */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Inits a page to the buffer buf_pool, for use in ibbackup --restore. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
buf_page_init_for_backup_restore(
|
|
|
|
/*=============================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset, /*!< in: offset of the page within space
|
2005-10-27 07:29:40 +00:00
|
|
|
in units of a page */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2006-10-06 11:23:19 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block); /*!< in: block to init */
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2007-01-18 23:10:49 +00:00
|
|
|
Releases a compressed-only page acquired with buf_page_get_zip(). */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_release_zip(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* bpage); /*!< in: buffer block */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Decrements the bufferfix count of a buffer control block and releases
|
|
|
|
a latch, if specified. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_release(
|
|
|
|
/*=============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in: buffer block */
|
|
|
|
ulint rw_latch, /*!< in: RW_S_LATCH, RW_X_LATCH,
|
2005-10-27 07:29:40 +00:00
|
|
|
RW_NO_LATCH */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr); /*!< in: mtr */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Moves a page to the start of the buffer pool LRU list. This high-level
|
2009-09-10 09:10:20 +00:00
|
|
|
function can be used to prevent an important page from slipping out of
|
2005-10-27 07:29:40 +00:00
|
|
|
the buffer pool. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
buf_page_make_young(
|
2006-02-23 19:25:29 +00:00
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* bpage); /*!< in: buffer block of a file page */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-05-25 08:09:45 +00:00
|
|
|
Returns TRUE if the page can be found in the buffer pool hash table.
|
|
|
|
|
|
|
|
NOTE that it is possible that the page is not yet read from disk,
|
|
|
|
though.
|
|
|
|
|
|
|
|
@return TRUE if found in the page hash table */
|
2007-01-04 21:40:10 +00:00
|
|
|
UNIV_INLINE
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
buf_page_peek(
|
|
|
|
/*==========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset);/*!< in: page number */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Resets the check_index_page_at_flush field of a page if found in the buffer
|
|
|
|
pool. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
buf_reset_check_index_page_at_flush(
|
|
|
|
/*================================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset);/*!< in: page number */
|
2006-11-16 08:48:28 +00:00
|
|
|
#ifdef UNIV_DEBUG_FILE_ACCESSES
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Sets file_page_was_freed TRUE if the page is found in the buffer pool.
|
|
|
|
This function should be called when we free a file page and want the
|
|
|
|
debug version to check that it is not accessed any more unless
|
2009-05-25 05:30:14 +00:00
|
|
|
reallocated.
|
|
|
|
@return control block if found in page hash table, otherwise NULL */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-11-29 13:23:28 +00:00
|
|
|
buf_page_t*
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_page_set_file_page_was_freed(
|
|
|
|
/*=============================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset);/*!< in: page number */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Sets file_page_was_freed FALSE if the page is found in the buffer pool.
|
|
|
|
This function should be called when we free a file page and want the
|
|
|
|
debug version to check that it is not accessed any more unless
|
2009-05-25 05:30:14 +00:00
|
|
|
reallocated.
|
|
|
|
@return control block if found in page hash table, otherwise NULL */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-11-29 13:23:28 +00:00
|
|
|
buf_page_t*
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_page_reset_file_page_was_freed(
|
|
|
|
/*===============================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset); /*!< in: page number */
|
2006-11-16 08:48:28 +00:00
|
|
|
#endif /* UNIV_DEBUG_FILE_ACCESSES */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Reads the freed_page_clock of a buffer block.
|
|
|
|
@return freed_page_clock */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_page_get_freed_page_clock(
|
|
|
|
/*==========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: block */
|
2006-11-30 12:27:49 +00:00
|
|
|
__attribute__((pure));
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Reads the freed_page_clock of a buffer block.
|
|
|
|
@return freed_page_clock */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_block_get_freed_page_clock(
|
|
|
|
/*===========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: block */
|
2006-11-30 12:27:49 +00:00
|
|
|
__attribute__((pure));
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Recommends a move of a block to the start of the LRU list if there is danger
|
|
|
|
of dropping from the buffer pool. NOTE: does not reserve the buffer pool
|
2009-05-25 05:30:14 +00:00
|
|
|
mutex.
|
|
|
|
@return TRUE if should be made younger */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
2007-08-01 11:18:43 +00:00
|
|
|
buf_page_peek_if_too_old(
|
|
|
|
/*=====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage); /*!< in: block to make younger */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Returns the current state of is_hashed of a page. FALSE if the page is
|
|
|
|
not in the pool. NOTE that this operation does not fix the page in the
|
2009-05-25 05:30:14 +00:00
|
|
|
pool if it is found there.
|
|
|
|
@return TRUE if page hash index is built in search system */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
buf_page_peek_if_search_hashed(
|
|
|
|
/*===========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset);/*!< in: page number */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Gets the youngest modification log sequence number for a frame.
|
2009-05-25 05:30:14 +00:00
|
|
|
Returns zero if not file page or no modification occurred yet.
|
|
|
|
@return newest modification to page */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
2006-11-29 14:52:16 +00:00
|
|
|
ib_uint64_t
|
2006-11-30 15:09:33 +00:00
|
|
|
buf_page_get_newest_modification(
|
|
|
|
/*=============================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage); /*!< in: block containing the
|
2006-11-30 15:09:33 +00:00
|
|
|
page frame */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Increments the modify clock of a frame by 1. The caller must (1) own the
|
|
|
|
buf_pool mutex and block bufferfix count has to be zero, (2) or own an x-lock
|
|
|
|
on the block. */
|
|
|
|
UNIV_INLINE
|
2006-10-13 11:55:27 +00:00
|
|
|
void
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_block_modify_clock_inc(
|
|
|
|
/*=======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block); /*!< in: block */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2006-02-23 19:25:29 +00:00
|
|
|
Returns the value of the modify clock. The caller must have an s-lock
|
2009-05-25 05:30:14 +00:00
|
|
|
or x-lock on the block.
|
|
|
|
@return value */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
2006-11-29 14:52:16 +00:00
|
|
|
ib_uint64_t
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_block_get_modify_clock(
|
|
|
|
/*=======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block); /*!< in: block */
|
2009-03-23 14:21:34 +00:00
|
|
|
#else /* !UNIV_HOTBACKUP */
|
|
|
|
# define buf_block_modify_clock_inc(block) ((void) 0)
|
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Calculates a page checksum which is stored to the page when it is written
|
|
|
|
to a file. Note that we must be careful to calculate the same value
|
2009-05-25 05:30:14 +00:00
|
|
|
on 32-bit and 64-bit architectures.
|
|
|
|
@return checksum */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
buf_calc_page_new_checksum(
|
|
|
|
/*=======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const byte* page); /*!< in: buffer page */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
In versions < 4.0.14 and < 4.1.1 there was a bug that the checksum only
|
|
|
|
looked at the first few bytes of the page. This calculates that old
|
2006-02-23 19:25:29 +00:00
|
|
|
checksum.
|
2005-10-27 07:29:40 +00:00
|
|
|
NOTE: we must first store the new formula checksum to
|
|
|
|
FIL_PAGE_SPACE_OR_CHKSUM before calculating and storing this old checksum
|
2009-05-25 05:30:14 +00:00
|
|
|
because this takes that field as an input!
|
|
|
|
@return checksum */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
buf_calc_page_old_checksum(
|
|
|
|
/*=======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const byte* page); /*!< in: buffer page */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Checks if a page is corrupt.
|
|
|
|
@return TRUE if corrupted */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
buf_page_is_corrupted(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const byte* read_buf, /*!< in: a database page */
|
|
|
|
ulint zip_size); /*!< in: size of compressed page;
|
2006-10-23 19:14:36 +00:00
|
|
|
0 for uncompressed pages */
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Gets the space id, page offset, and byte offset within page of a
|
|
|
|
pointer pointing to a buffer frame containing a file page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_ptr_get_fsp_addr(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const void* ptr, /*!< in: pointer to a buffer frame */
|
|
|
|
ulint* space, /*!< out: space id */
|
|
|
|
fil_addr_t* addr); /*!< out: page offset and byte offset */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2006-10-13 11:55:27 +00:00
|
|
|
Gets the hash value of a block. This can be used in searches in the
|
2009-05-25 05:30:14 +00:00
|
|
|
lock hash table.
|
|
|
|
@return lock hash value */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
2006-10-13 11:55:27 +00:00
|
|
|
buf_block_get_lock_hash_val(
|
2005-10-27 07:29:40 +00:00
|
|
|
/*========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: block */
|
2006-11-30 12:27:49 +00:00
|
|
|
__attribute__((pure));
|
2006-12-19 22:12:44 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-12-19 22:12:44 +00:00
|
|
|
Finds a block in the buffer pool that points to a
|
2009-05-25 05:30:14 +00:00
|
|
|
given compressed page.
|
|
|
|
@return buffer block pointing to the compressed page, or NULL */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-12-19 22:12:44 +00:00
|
|
|
buf_block_t*
|
|
|
|
buf_pool_contains_zip(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const void* data); /*!< in: pointer to compressed page */
|
2006-12-19 22:12:44 +00:00
|
|
|
#endif /* UNIV_DEBUG */
|
2006-11-16 09:00:30 +00:00
|
|
|
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Validates the buffer pool data structure.
|
|
|
|
@return TRUE */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
buf_validate(void);
|
|
|
|
/*==============*/
|
2006-11-16 09:00:30 +00:00
|
|
|
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
|
|
|
|
#if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Prints info of the buffer pool data structure. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
buf_print(void);
|
|
|
|
/*============*/
|
2006-11-16 09:00:30 +00:00
|
|
|
#endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Prints a page to stderr. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
buf_page_print(
|
|
|
|
/*===========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const byte* read_buf, /*!< in: a database page */
|
|
|
|
ulint zip_size); /*!< in: compressed page size, or
|
2006-10-23 19:14:36 +00:00
|
|
|
0 for uncompressed pages */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Decompress a block.
|
|
|
|
@return TRUE if successful */
|
2009-03-23 14:21:34 +00:00
|
|
|
UNIV_INTERN
|
|
|
|
ibool
|
|
|
|
buf_zip_decompress(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in/out: block */
|
|
|
|
ibool check); /*!< in: TRUE=verify the page checksum */
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
branches/zip: Merge 2437:2485 from branches/5.1:
(r2478 was skipped for the obvious reason)
------------------------------------------------------------------------
r2464 | vasil | 2008-05-19 17:59:42 +0300 (Mon, 19 May 2008) | 9 lines
branches/5.1:
Fix Bug#36600 SHOW STATUS takes a lot of CPU in buf_get_latched_pages_number
by removing the Innodb_buffer_pool_pages_latched variable from
SHOW STATUS output in non-UNIV_DEBUG compilation.
Approved by: Heikki
------------------------------------------------------------------------
r2466 | calvin | 2008-05-20 01:37:14 +0300 (Tue, 20 May 2008) | 12 lines
branches/5.1:
Fix Bug#11894 innodb_file_per_table crashes w/ Windows .sym symbolic
link hack
The crash was due to un-handled error 3 (path not found). In the case
of file per table, change the call to os_file_handle_error_no_exit()
from os_file_handle_error(). Also, checks for full path pattern during
table create (Windows only), which is used in symbolic link and temp
table creation.
Approved by: Heikki
------------------------------------------------------------------------
r2478 | sunny | 2008-05-23 08:29:08 +0300 (Fri, 23 May 2008) | 3 lines
branches/5.1: Fix for bug# 36793. This is a back port from branches/zip. This
code has been tested on a big-endian machine too.
------------------------------------------------------------------------
r2480 | vasil | 2008-05-27 11:40:07 +0300 (Tue, 27 May 2008) | 11 lines
branches/5.1:
Fix Bug#36819 ut_usectime does not handle errors from gettimeofday
by retrying gettimeofday() several times if it fails in ut_usectime().
If it fails on all calls then return error to the caller to be handled
at higher level.
Update the variable innodb_row_lock_time_max in SHOW STATUS output only
if ut_usectime() was successful.
------------------------------------------------------------------------
r2482 | sunny | 2008-05-28 12:18:35 +0300 (Wed, 28 May 2008) | 5 lines
branches/5.1: Fix for Bug#35602, "Failed to read auto-increment value from
storage engine". The test for REPLACE was an error of ommission since it's
classified as a simple INSERT. For REPLACE statements we don't acquire
the special AUTOINC lock for AUTOINC_NEW_STYLE_LOCKING with this fix.
------------------------------------------------------------------------
r2485 | vasil | 2008-05-28 16:01:14 +0300 (Wed, 28 May 2008) | 9 lines
branches/5.1:
Fix Bug#36149 Read buffer overflow in srv0start.c found during "make test"
Use strncmp(3) instead of memcmp(3) to avoid reading past end of the string
if it is empty (*str == '\0'). This bug is _not_ a buffer overflow.
Discussed with: Sunny (via IM)
------------------------------------------------------------------------
2008-06-06 15:24:58 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Returns the number of latched pages in the buffer pool.
|
|
|
|
@return number of latched pages */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
buf_get_latched_pages_number(void);
|
|
|
|
/*==============================*/
|
branches/zip: Merge 2437:2485 from branches/5.1:
(r2478 was skipped for the obvious reason)
------------------------------------------------------------------------
r2464 | vasil | 2008-05-19 17:59:42 +0300 (Mon, 19 May 2008) | 9 lines
branches/5.1:
Fix Bug#36600 SHOW STATUS takes a lot of CPU in buf_get_latched_pages_number
by removing the Innodb_buffer_pool_pages_latched variable from
SHOW STATUS output in non-UNIV_DEBUG compilation.
Approved by: Heikki
------------------------------------------------------------------------
r2466 | calvin | 2008-05-20 01:37:14 +0300 (Tue, 20 May 2008) | 12 lines
branches/5.1:
Fix Bug#11894 innodb_file_per_table crashes w/ Windows .sym symbolic
link hack
The crash was due to un-handled error 3 (path not found). In the case
of file per table, change the call to os_file_handle_error_no_exit()
from os_file_handle_error(). Also, checks for full path pattern during
table create (Windows only), which is used in symbolic link and temp
table creation.
Approved by: Heikki
------------------------------------------------------------------------
r2478 | sunny | 2008-05-23 08:29:08 +0300 (Fri, 23 May 2008) | 3 lines
branches/5.1: Fix for bug# 36793. This is a back port from branches/zip. This
code has been tested on a big-endian machine too.
------------------------------------------------------------------------
r2480 | vasil | 2008-05-27 11:40:07 +0300 (Tue, 27 May 2008) | 11 lines
branches/5.1:
Fix Bug#36819 ut_usectime does not handle errors from gettimeofday
by retrying gettimeofday() several times if it fails in ut_usectime().
If it fails on all calls then return error to the caller to be handled
at higher level.
Update the variable innodb_row_lock_time_max in SHOW STATUS output only
if ut_usectime() was successful.
------------------------------------------------------------------------
r2482 | sunny | 2008-05-28 12:18:35 +0300 (Wed, 28 May 2008) | 5 lines
branches/5.1: Fix for Bug#35602, "Failed to read auto-increment value from
storage engine". The test for REPLACE was an error of ommission since it's
classified as a simple INSERT. For REPLACE statements we don't acquire
the special AUTOINC lock for AUTOINC_NEW_STYLE_LOCKING with this fix.
------------------------------------------------------------------------
r2485 | vasil | 2008-05-28 16:01:14 +0300 (Wed, 28 May 2008) | 9 lines
branches/5.1:
Fix Bug#36149 Read buffer overflow in srv0start.c found during "make test"
Use strncmp(3) instead of memcmp(3) to avoid reading past end of the string
if it is empty (*str == '\0'). This bug is _not_ a buffer overflow.
Discussed with: Sunny (via IM)
------------------------------------------------------------------------
2008-06-06 15:24:58 +00:00
|
|
|
#endif /* UNIV_DEBUG */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Returns the number of pending buf pool ios.
|
|
|
|
@return number of pending I/O operations */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
buf_get_n_pending_ios(void);
|
|
|
|
/*=======================*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Prints info of the buffer i/o. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
buf_print_io(
|
|
|
|
/*=========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
FILE* file); /*!< in: file where to print */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Returns the ratio in percents of modified pages in the buffer pool /
|
2009-05-25 05:30:14 +00:00
|
|
|
database pages in the buffer pool.
|
|
|
|
@return modified page percentage ratio */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
buf_get_modified_ratio_pct(void);
|
|
|
|
/*============================*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Refreshes the statistics used to print per-second averages. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
buf_refresh_io_stats(void);
|
|
|
|
/*======================*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Asserts that all file pages in the buffer are in a replaceable state.
|
|
|
|
@return TRUE */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
buf_all_freed(void);
|
|
|
|
/*===============*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Checks that there currently are no pending i/o-operations for the buffer
|
2009-05-25 05:30:14 +00:00
|
|
|
pool.
|
|
|
|
@return TRUE if there is no pending i/o */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
buf_pool_check_no_pending_io(void);
|
|
|
|
/*==============================*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Invalidates the file pages in the buffer pool when an archive recovery is
|
|
|
|
completed. All the file pages buffered must be in a replaceable state when
|
|
|
|
this function is called: not latched and not modified. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
buf_pool_invalidate(void);
|
|
|
|
/*=====================*/
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/*========================================================================
|
|
|
|
--------------------------- LOWER LEVEL ROUTINES -------------------------
|
|
|
|
=========================================================================*/
|
|
|
|
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Adds latch level info for the rw-lock protecting the buffer frame. This
|
|
|
|
should be called in the debug version after a successful latching of a
|
|
|
|
page if we know the latching order level of the acquired latch. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(
|
|
|
|
/*====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in: buffer page
|
2006-10-12 11:05:22 +00:00
|
|
|
where we have acquired latch */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint level); /*!< in: latching order level */
|
2008-09-22 06:59:58 +00:00
|
|
|
#else /* UNIV_SYNC_DEBUG */
|
|
|
|
# define buf_block_dbg_add_level(block, level) /* nothing */
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the state of a block.
|
|
|
|
@return state */
|
2006-11-23 13:26:01 +00:00
|
|
|
UNIV_INLINE
|
2006-11-24 08:32:18 +00:00
|
|
|
enum buf_page_state
|
2006-11-27 14:12:09 +00:00
|
|
|
buf_page_get_state(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage); /*!< in: pointer to the control block */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the state of a block.
|
|
|
|
@return state */
|
2006-11-27 14:12:09 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
enum buf_page_state
|
2006-11-23 13:26:01 +00:00
|
|
|
buf_block_get_state(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
2006-11-23 13:26:01 +00:00
|
|
|
__attribute__((pure));
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-23 14:12:58 +00:00
|
|
|
Sets the state of a block. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
2006-11-30 12:27:49 +00:00
|
|
|
buf_page_set_state(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* bpage, /*!< in/out: pointer to control block */
|
|
|
|
enum buf_page_state state); /*!< in: state */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-30 12:27:49 +00:00
|
|
|
Sets the state of a block. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
2006-11-23 14:12:58 +00:00
|
|
|
buf_block_set_state(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in/out: pointer to control block */
|
|
|
|
enum buf_page_state state); /*!< in: state */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Determines if a block is mapped to a tablespace.
|
|
|
|
@return TRUE if mapped */
|
2006-11-29 13:23:28 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
buf_page_in_file(
|
|
|
|
/*=============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: pointer to control block */
|
2006-11-29 13:23:28 +00:00
|
|
|
__attribute__((pure));
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Determines if a block should be on unzip_LRU list.
|
|
|
|
@return TRUE if block belongs to unzip_LRU */
|
2008-03-03 12:48:38 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
buf_page_belongs_to_unzip_LRU(
|
|
|
|
/*==========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: pointer to control block */
|
2008-03-03 12:48:38 +00:00
|
|
|
__attribute__((pure));
|
2006-11-30 12:27:49 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the mutex of a block.
|
|
|
|
@return pointer to mutex protecting bpage */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
mutex_t*
|
|
|
|
buf_page_get_mutex(
|
2006-12-05 12:10:30 +00:00
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: pointer to control block */
|
2006-11-30 12:27:49 +00:00
|
|
|
__attribute__((pure));
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Get the flush type of a page.
|
|
|
|
@return flush type */
|
2006-11-27 14:12:09 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
enum buf_flush
|
|
|
|
buf_page_get_flush_type(
|
|
|
|
/*====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: buffer page */
|
2006-11-27 14:12:09 +00:00
|
|
|
__attribute__((pure));
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-27 14:12:09 +00:00
|
|
|
Set the flush type of a page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_set_flush_type(
|
|
|
|
/*====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* bpage, /*!< in: buffer page */
|
|
|
|
enum buf_flush flush_type); /*!< in: flush type */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-23 14:12:58 +00:00
|
|
|
Map a block to a file page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_block_set_file_page(
|
|
|
|
/*====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in/out: pointer to control block */
|
|
|
|
ulint space, /*!< in: tablespace id */
|
|
|
|
ulint page_no);/*!< in: page number */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the io_fix state of a block.
|
|
|
|
@return io_fix state */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
enum buf_io_fix
|
|
|
|
buf_page_get_io_fix(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: pointer to the control block */
|
2006-11-30 12:27:49 +00:00
|
|
|
__attribute__((pure));
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the io_fix state of a block.
|
|
|
|
@return io_fix state */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
enum buf_io_fix
|
|
|
|
buf_block_get_io_fix(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
2006-11-30 12:27:49 +00:00
|
|
|
__attribute__((pure));
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-30 12:27:49 +00:00
|
|
|
Sets the io_fix state of a block. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_set_io_fix(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* bpage, /*!< in/out: control block */
|
|
|
|
enum buf_io_fix io_fix);/*!< in: io_fix state */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-30 12:27:49 +00:00
|
|
|
Sets the io_fix state of a block. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_block_set_io_fix(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in/out: control block */
|
|
|
|
enum buf_io_fix io_fix);/*!< in: io_fix state */
|
2006-11-30 12:27:49 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2007-01-04 21:40:10 +00:00
|
|
|
Determine if a buffer block can be relocated in memory. The block
|
|
|
|
can be dirty, but it must not be I/O-fixed or bufferfixed. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
buf_page_can_relocate(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< control block being relocated */
|
2007-09-28 12:04:04 +00:00
|
|
|
__attribute__((pure));
|
2007-01-04 21:40:10 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Determine if a block has been flagged old.
|
|
|
|
@return TRUE if old */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
buf_page_is_old(
|
|
|
|
/*============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: control block */
|
2006-11-30 12:27:49 +00:00
|
|
|
__attribute__((pure));
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-30 12:27:49 +00:00
|
|
|
Flag a block old. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_set_old(
|
|
|
|
/*=============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* bpage, /*!< in/out: control block */
|
|
|
|
ibool old); /*!< in: old */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-09-09 06:25:00 +00:00
|
|
|
Determine the time of first access of a block in the buffer pool.
|
|
|
|
@return ut_time_ms() at the time of first access, 0 if not accessed */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
unsigned
|
2006-11-30 12:27:49 +00:00
|
|
|
buf_page_is_accessed(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: control block */
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
__attribute__((nonnull, pure));
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-11-30 12:27:49 +00:00
|
|
|
Flag a block accessed. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_set_accessed(
|
|
|
|
/*==================*/
|
2009-09-10 09:47:09 +00:00
|
|
|
buf_page_t* bpage, /*!< in/out: control block */
|
|
|
|
ulint time_ms) /*!< in: ut_time_ms() */
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
__attribute__((nonnull));
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2007-09-28 12:04:04 +00:00
|
|
|
Gets the buf_block_t handle of a buffered file block if an uncompressed
|
2009-05-25 05:30:14 +00:00
|
|
|
page frame exists, or NULL.
|
|
|
|
@return control block, or NULL */
|
2007-09-28 12:04:04 +00:00
|
|
|
UNIV_INLINE
|
2007-10-01 07:32:45 +00:00
|
|
|
buf_block_t*
|
2007-09-28 12:04:04 +00:00
|
|
|
buf_page_get_block(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* bpage) /*!< in: control block, or NULL */
|
2007-09-28 12:04:04 +00:00
|
|
|
__attribute__((pure));
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2007-09-28 06:26:21 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets a pointer to the memory frame of a block.
|
|
|
|
@return pointer to the frame */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
buf_frame_t*
|
|
|
|
buf_block_get_frame(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
2006-11-30 12:27:49 +00:00
|
|
|
__attribute__((pure));
|
2007-09-28 06:26:21 +00:00
|
|
|
#else /* UNIV_DEBUG */
|
2007-10-29 14:03:57 +00:00
|
|
|
# define buf_block_get_frame(block) (block)->frame
|
2007-09-28 06:26:21 +00:00
|
|
|
#endif /* UNIV_DEBUG */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the space id of a block.
|
|
|
|
@return space id */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_page_get_space(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: pointer to the control block */
|
2008-02-29 08:13:55 +00:00
|
|
|
__attribute__((pure));
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the space id of a block.
|
|
|
|
@return space id */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_block_get_space(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
2008-02-29 08:13:55 +00:00
|
|
|
__attribute__((pure));
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the page number of a block.
|
|
|
|
@return page number */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_page_get_page_no(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: pointer to the control block */
|
2008-02-29 08:13:55 +00:00
|
|
|
__attribute__((pure));
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the page number of a block.
|
|
|
|
@return page number */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_block_get_page_no(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
2008-02-29 08:13:55 +00:00
|
|
|
__attribute__((pure));
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the compressed page size of a block.
|
|
|
|
@return compressed page size, or 0 */
|
2006-11-30 12:27:49 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_page_get_zip_size(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_page_t* bpage) /*!< in: pointer to the control block */
|
2008-02-29 08:13:55 +00:00
|
|
|
__attribute__((pure));
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the compressed page size of a block.
|
|
|
|
@return compressed page size, or 0 */
|
2006-10-12 11:05:22 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_block_get_zip_size(
|
|
|
|
/*===================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
2008-02-29 08:13:55 +00:00
|
|
|
__attribute__((pure));
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-10-09 15:37:19 +00:00
|
|
|
Gets the compressed page descriptor corresponding to an uncompressed page
|
|
|
|
if applicable. */
|
2007-10-03 12:22:29 +00:00
|
|
|
#define buf_block_get_page_zip(block) \
|
|
|
|
(UNIV_LIKELY_NULL((block)->page.zip.data) ? &(block)->page.zip : NULL)
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the block to whose frame the pointer is pointing to.
|
|
|
|
@return pointer to block, never NULL */
|
2009-01-26 20:33:20 +00:00
|
|
|
UNIV_INTERN
|
|
|
|
buf_block_t*
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_block_align(
|
|
|
|
/*============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const byte* ptr); /*!< in: pointer to a frame */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2009-03-25 17:18:33 +00:00
|
|
|
Find out if a pointer belongs to a buf_block_t. It can be a pointer to
|
2009-05-25 05:30:14 +00:00
|
|
|
the buf_block_t itself or a member of it
|
|
|
|
@return TRUE if ptr belongs to a buf_block_t struct */
|
2009-03-25 17:18:33 +00:00
|
|
|
UNIV_INTERN
|
|
|
|
ibool
|
|
|
|
buf_pointer_is_block_field(
|
|
|
|
/*=======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const void* ptr); /*!< in: pointer not
|
2009-03-25 17:18:33 +00:00
|
|
|
dereferenced */
|
2009-06-04 05:58:23 +00:00
|
|
|
/** Find out if a pointer corresponds to a buf_block_t::mutex.
|
|
|
|
@param m in: mutex candidate
|
|
|
|
@return TRUE if m is a buf_block_t::mutex */
|
|
|
|
#define buf_pool_is_block_mutex(m) \
|
|
|
|
buf_pointer_is_block_field((const void*)(m))
|
|
|
|
/** Find out if a pointer corresponds to a buf_block_t::lock.
|
|
|
|
@param l in: rw-lock candidate
|
|
|
|
@return TRUE if l is a buf_block_t::lock */
|
|
|
|
#define buf_pool_is_block_lock(l) \
|
|
|
|
buf_pointer_is_block_field((const void*)(l))
|
2009-03-25 17:18:33 +00:00
|
|
|
|
2009-01-26 20:33:20 +00:00
|
|
|
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2006-10-12 11:05:22 +00:00
|
|
|
Gets the compressed page descriptor corresponding to an uncompressed page
|
2009-05-25 05:30:14 +00:00
|
|
|
if applicable.
|
|
|
|
@return compressed page descriptor, or NULL */
|
2006-10-12 11:05:22 +00:00
|
|
|
UNIV_INLINE
|
2007-10-03 12:22:29 +00:00
|
|
|
const page_zip_des_t*
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_frame_get_page_zip(
|
|
|
|
/*===================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const byte* ptr); /*!< in: pointer to the page */
|
2006-10-18 11:39:31 +00:00
|
|
|
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Function which inits a page for read to the buffer buf_pool. If the page is
|
|
|
|
(1) already in buf_pool, or
|
|
|
|
(2) if we specify to read only ibuf pages and the page is not an ibuf page, or
|
|
|
|
(3) if the space is deleted or being deleted,
|
|
|
|
then this function does nothing.
|
|
|
|
Sets the io_fix flag to BUF_IO_READ and sets a non-recursive exclusive lock
|
|
|
|
on the buffer frame. The io-handler must take care that the flag is cleared
|
2009-05-25 05:30:14 +00:00
|
|
|
and the lock released later.
|
|
|
|
@return pointer to the block or NULL */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2007-02-08 12:03:03 +00:00
|
|
|
buf_page_t*
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_page_init_for_read(
|
|
|
|
/*===================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint* err, /*!< out: DB_SUCCESS or DB_TABLESPACE_DELETED */
|
|
|
|
ulint mode, /*!< in: BUF_READ_IBUF_PAGES_ONLY, ... */
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size, or 0 */
|
|
|
|
ibool unzip, /*!< in: TRUE=request uncompressed page */
|
|
|
|
ib_int64_t tablespace_version,/*!< in: prevents reading from a wrong
|
2005-10-27 07:29:40 +00:00
|
|
|
version of the tablespace in case we have done
|
|
|
|
DISCARD + IMPORT */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint offset);/*!< in: page number */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Completes an asynchronous read or write request of a file page to or from
|
|
|
|
the buffer pool. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
buf_page_io_complete(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_page_t* bpage); /*!< in: pointer to the block in question */
|
2009-05-25 09:52:29 +00:00
|
|
|
/********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Calculates a folded value of a file page address to use in the page hash
|
2009-05-25 05:30:14 +00:00
|
|
|
table.
|
|
|
|
@return the folded value */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_page_address_fold(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset) /*!< in: offset of the page within space */
|
2007-01-03 12:34:54 +00:00
|
|
|
__attribute__((const));
|
2009-05-25 09:52:29 +00:00
|
|
|
/******************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Returns the control block of a file page, NULL if not found.
|
|
|
|
@return block, NULL if not found */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
2006-11-29 13:23:28 +00:00
|
|
|
buf_page_t*
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_page_hash_get(
|
|
|
|
/*==============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset);/*!< in: offset of the page within space */
|
2009-05-25 09:52:29 +00:00
|
|
|
/******************************************************************//**
|
2007-10-01 07:32:45 +00:00
|
|
|
Returns the control block of a file page, NULL if not found
|
2009-05-25 05:30:14 +00:00
|
|
|
or an uncompressed page frame does not exist.
|
|
|
|
@return block, NULL if not found */
|
2007-10-01 07:32:45 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
buf_block_t*
|
|
|
|
buf_block_hash_get(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset);/*!< in: offset of the page within space */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the current length of the free list of buffer blocks.
|
|
|
|
@return length of the free list */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
buf_get_free_list_len(void);
|
|
|
|
/*=======================*/
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/** The common buffer control block structure
|
2006-11-24 08:32:18 +00:00
|
|
|
for compressed and uncompressed frames */
|
|
|
|
|
|
|
|
struct buf_page_struct{
|
2009-05-27 06:57:25 +00:00
|
|
|
/** @name General fields
|
|
|
|
None of these bit-fields must be modified without holding
|
|
|
|
buf_page_get_mutex() [buf_block_struct::mutex or
|
|
|
|
buf_pool_zip_mutex], since they can be stored in the same
|
|
|
|
machine word. Some of these fields are additionally protected
|
|
|
|
by buf_pool_mutex. */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
2006-11-30 10:33:35 +00:00
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
unsigned space:32; /*!< tablespace id; also protected
|
2009-01-09 20:27:40 +00:00
|
|
|
by buf_pool_mutex. */
|
2009-05-26 12:28:49 +00:00
|
|
|
unsigned offset:32; /*!< page number; also protected
|
2009-01-09 20:27:40 +00:00
|
|
|
by buf_pool_mutex. */
|
2006-11-30 10:33:35 +00:00
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
unsigned state:3; /*!< state of the control block; also
|
2008-01-10 09:37:13 +00:00
|
|
|
protected by buf_pool_mutex.
|
2006-12-20 15:56:58 +00:00
|
|
|
State transitions from
|
|
|
|
BUF_BLOCK_READY_FOR_USE to
|
|
|
|
BUF_BLOCK_MEMORY need not be
|
2009-05-26 12:28:49 +00:00
|
|
|
protected by buf_page_get_mutex().
|
|
|
|
@see enum buf_page_state */
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-26 12:28:49 +00:00
|
|
|
unsigned flush_type:2; /*!< if this block is currently being
|
2006-11-30 10:33:35 +00:00
|
|
|
flushed to disk, this tells the
|
2009-05-26 12:28:49 +00:00
|
|
|
flush_type.
|
|
|
|
@see enum buf_flush */
|
|
|
|
unsigned io_fix:2; /*!< type of pending I/O operation;
|
|
|
|
also protected by buf_pool_mutex
|
|
|
|
@see enum buf_io_fix */
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
unsigned buf_fix_count:25;/*!< count of how manyfold this block
|
2006-11-30 12:27:49 +00:00
|
|
|
is currently bufferfixed */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @} */
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2009-05-26 12:28:49 +00:00
|
|
|
page_zip_des_t zip; /*!< compressed page; zip.data
|
2006-12-19 12:38:18 +00:00
|
|
|
(but not the data it points to) is
|
2008-01-10 09:37:13 +00:00
|
|
|
also protected by buf_pool_mutex */
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-26 12:28:49 +00:00
|
|
|
buf_page_t* hash; /*!< node used in chaining to
|
2006-12-11 09:54:13 +00:00
|
|
|
buf_pool->page_hash or
|
|
|
|
buf_pool->zip_hash */
|
2007-01-24 10:36:05 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
2009-05-26 12:28:49 +00:00
|
|
|
ibool in_page_hash; /*!< TRUE if in buf_pool->page_hash */
|
|
|
|
ibool in_zip_hash; /*!< TRUE if in buf_pool->zip_hash */
|
2007-01-24 10:36:05 +00:00
|
|
|
#endif /* UNIV_DEBUG */
|
2006-11-27 14:12:09 +00:00
|
|
|
|
2009-05-27 06:57:25 +00:00
|
|
|
/** @name Page flushing fields
|
|
|
|
All these are protected by buf_pool_mutex. */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
2006-11-27 14:12:09 +00:00
|
|
|
|
2006-12-05 12:31:38 +00:00
|
|
|
UT_LIST_NODE_T(buf_page_t) list;
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< based on state, this is a
|
2009-03-24 13:46:12 +00:00
|
|
|
list node, protected only by
|
|
|
|
buf_pool_mutex, in one of the
|
|
|
|
following lists in buf_pool:
|
2006-12-05 12:31:38 +00:00
|
|
|
|
2009-05-27 06:57:25 +00:00
|
|
|
- BUF_BLOCK_NOT_USED: free
|
|
|
|
- BUF_BLOCK_FILE_PAGE: flush_list
|
|
|
|
- BUF_BLOCK_ZIP_DIRTY: flush_list
|
|
|
|
- BUF_BLOCK_ZIP_PAGE: zip_clean
|
2009-08-26 10:25:26 +00:00
|
|
|
- BUF_BLOCK_ZIP_FREE: zip_free[]
|
|
|
|
|
|
|
|
The contents of the list node
|
|
|
|
is undefined if !in_flush_list
|
|
|
|
&& state == BUF_BLOCK_FILE_PAGE,
|
|
|
|
or if state is one of
|
|
|
|
BUF_BLOCK_MEMORY,
|
|
|
|
BUF_BLOCK_REMOVE_HASH or
|
|
|
|
BUF_BLOCK_READY_IN_USE. */
|
|
|
|
|
2006-12-04 12:44:06 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
2009-05-26 12:28:49 +00:00
|
|
|
ibool in_flush_list; /*!< TRUE if in buf_pool->flush_list;
|
2008-01-10 09:37:13 +00:00
|
|
|
when buf_pool_mutex is free, the
|
2007-01-09 12:35:42 +00:00
|
|
|
following should hold: in_flush_list
|
|
|
|
== (state == BUF_BLOCK_FILE_PAGE
|
|
|
|
|| state == BUF_BLOCK_ZIP_DIRTY) */
|
2009-05-26 12:28:49 +00:00
|
|
|
ibool in_free_list; /*!< TRUE if in buf_pool->free; when
|
2008-01-10 09:37:13 +00:00
|
|
|
buf_pool_mutex is free, the following
|
2006-12-07 10:02:23 +00:00
|
|
|
should hold: in_free_list
|
|
|
|
== (state == BUF_BLOCK_NOT_USED) */
|
2006-12-04 12:44:06 +00:00
|
|
|
#endif /* UNIV_DEBUG */
|
2006-11-29 14:52:16 +00:00
|
|
|
ib_uint64_t newest_modification;
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< log sequence number of
|
|
|
|
the youngest modification to
|
|
|
|
this block, zero if not
|
|
|
|
modified */
|
2006-11-29 14:52:16 +00:00
|
|
|
ib_uint64_t oldest_modification;
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< log sequence number of
|
|
|
|
the START of the log entry
|
|
|
|
written of the oldest
|
|
|
|
modification to this block
|
|
|
|
which has not yet been flushed
|
|
|
|
on disk; zero if all
|
|
|
|
modifications are on disk */
|
|
|
|
/* @} */
|
2009-05-27 06:57:25 +00:00
|
|
|
/** @name LRU replacement algorithm fields
|
|
|
|
These fields are protected by buf_pool_mutex only (not
|
|
|
|
buf_pool_zip_mutex or buf_block_struct::mutex). */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
2006-11-30 12:27:49 +00:00
|
|
|
|
|
|
|
UT_LIST_NODE_T(buf_page_t) LRU;
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< node of the LRU list */
|
2006-11-30 12:27:49 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
2009-05-26 12:28:49 +00:00
|
|
|
ibool in_LRU_list; /*!< TRUE if the page is in
|
|
|
|
the LRU list; used in
|
|
|
|
debugging */
|
2006-11-30 12:27:49 +00:00
|
|
|
#endif /* UNIV_DEBUG */
|
2009-05-26 12:28:49 +00:00
|
|
|
unsigned old:1; /*!< TRUE if the block is in the old
|
2009-10-29 11:04:11 +00:00
|
|
|
blocks in buf_pool->LRU_old */
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
unsigned freed_page_clock:31;/*!< the value of
|
2009-05-26 12:28:49 +00:00
|
|
|
buf_pool->freed_page_clock
|
|
|
|
when this block was the last
|
|
|
|
time put to the head of the
|
|
|
|
LRU list; a thread is allowed
|
|
|
|
to read this for heuristic
|
|
|
|
purposes without holding any
|
|
|
|
mutex or latch */
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
unsigned access_time:32; /*!< time of first access, or
|
|
|
|
0 if the block was never accessed
|
|
|
|
in the buffer pool */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @} */
|
2009-05-27 06:57:25 +00:00
|
|
|
# ifdef UNIV_DEBUG_FILE_ACCESSES
|
2006-11-29 13:23:28 +00:00
|
|
|
ibool file_page_was_freed;
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< this is set to TRUE when fsp
|
2006-11-29 13:23:28 +00:00
|
|
|
frees a page in buffer pool */
|
2009-05-27 06:57:25 +00:00
|
|
|
# endif /* UNIV_DEBUG_FILE_ACCESSES */
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2006-11-24 08:32:18 +00:00
|
|
|
};
|
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/** The buffer control block structure */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
struct buf_block_struct{
|
|
|
|
|
2009-05-27 06:57:25 +00:00
|
|
|
/** @name General fields */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
buf_page_t page; /*!< page information; this must
|
2006-11-24 08:32:18 +00:00
|
|
|
be the first field, so that
|
|
|
|
buf_pool->page_hash can point
|
|
|
|
to buf_page_t or buf_block_t */
|
2009-05-26 12:28:49 +00:00
|
|
|
byte* frame; /*!< pointer to buffer frame which
|
2009-03-23 14:21:34 +00:00
|
|
|
is of size UNIV_PAGE_SIZE, and
|
|
|
|
aligned to an address divisible by
|
|
|
|
UNIV_PAGE_SIZE */
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
2008-03-03 12:48:38 +00:00
|
|
|
UT_LIST_NODE_T(buf_block_t) unzip_LRU;
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< node of the decompressed LRU list;
|
2008-03-03 12:48:38 +00:00
|
|
|
a block is in the unzip_LRU list
|
|
|
|
if page.state == BUF_BLOCK_FILE_PAGE
|
|
|
|
and page.zip.data != NULL */
|
|
|
|
#ifdef UNIV_DEBUG
|
2009-05-26 12:28:49 +00:00
|
|
|
ibool in_unzip_LRU_list;/*!< TRUE if the page is in the
|
2008-03-03 12:48:38 +00:00
|
|
|
decompressed LRU list;
|
|
|
|
used in debugging */
|
|
|
|
#endif /* UNIV_DEBUG */
|
2009-05-26 12:28:49 +00:00
|
|
|
mutex_t mutex; /*!< mutex protecting this block:
|
2006-11-10 11:15:59 +00:00
|
|
|
state (also protected by the buffer
|
|
|
|
pool mutex), io_fix, buf_fix_count,
|
|
|
|
and accessed; we introduce this new
|
|
|
|
mutex in InnoDB-5.1 to relieve
|
|
|
|
contention on the buffer pool mutex */
|
2009-05-26 12:28:49 +00:00
|
|
|
rw_lock_t lock; /*!< read-write lock of the buffer
|
2005-10-27 07:29:40 +00:00
|
|
|
frame */
|
2009-05-26 12:28:49 +00:00
|
|
|
unsigned lock_hash_val:32;/*!< hashed value of the page address
|
2006-11-24 08:32:18 +00:00
|
|
|
in the record lock hash table */
|
2006-12-08 15:55:59 +00:00
|
|
|
unsigned check_index_page_at_flush:1;
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< TRUE if we know that this is
|
2005-10-27 07:29:40 +00:00
|
|
|
an index page, and want the database
|
|
|
|
to check its consistency before flush;
|
|
|
|
note that there may be pages in the
|
|
|
|
buffer pool which are index pages,
|
|
|
|
but this flag is not set because
|
|
|
|
we do not keep track of all pages */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @} */
|
2009-05-27 06:57:25 +00:00
|
|
|
/** @name Optimistic search field */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
ib_uint64_t modify_clock; /*!< this clock is incremented every
|
2005-10-27 07:29:40 +00:00
|
|
|
time a pointer to a record on the
|
|
|
|
page may become obsolete; this is
|
|
|
|
used in the optimistic cursor
|
|
|
|
positioning: if the modify clock has
|
|
|
|
not changed, we know that the pointer
|
|
|
|
is still valid; this field may be
|
|
|
|
changed if the thread (1) owns the
|
|
|
|
pool mutex and the page is not
|
|
|
|
bufferfixed, or (2) the thread has an
|
|
|
|
x-latch on the block */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @} */
|
2009-05-27 06:57:25 +00:00
|
|
|
/** @name Hash search fields (unprotected)
|
|
|
|
NOTE that these fields are NOT protected by any semaphore! */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
ulint n_hash_helps; /*!< counter which controls building
|
2005-10-27 07:29:40 +00:00
|
|
|
of a new hash index for the page */
|
2009-05-26 12:28:49 +00:00
|
|
|
ulint n_fields; /*!< recommended prefix length for hash
|
2005-10-27 07:29:40 +00:00
|
|
|
search: number of full fields */
|
2009-05-26 12:28:49 +00:00
|
|
|
ulint n_bytes; /*!< recommended prefix: number of bytes
|
2005-10-27 07:29:40 +00:00
|
|
|
in an incomplete field */
|
2009-05-26 12:28:49 +00:00
|
|
|
ibool left_side; /*!< TRUE or FALSE, depending on
|
2005-10-27 07:29:40 +00:00
|
|
|
whether the leftmost record of several
|
|
|
|
records with the same prefix should be
|
|
|
|
indexed in the hash index */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @} */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2009-05-27 06:57:25 +00:00
|
|
|
/** @name Hash search fields
|
2009-05-26 12:28:49 +00:00
|
|
|
These 6 fields may only be modified when we have
|
2005-11-29 12:30:46 +00:00
|
|
|
an x-latch on btr_search_latch AND
|
2009-05-27 06:57:25 +00:00
|
|
|
- we are holding an s-latch or x-latch on buf_block_struct::lock or
|
|
|
|
- we know that buf_block_struct::buf_fix_count == 0.
|
2005-11-29 12:30:46 +00:00
|
|
|
|
|
|
|
An exception to this is when we init or create a page
|
|
|
|
in the buffer pool in buf0buf.c. */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
|
|
|
|
2008-12-17 09:19:56 +00:00
|
|
|
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
|
2009-05-26 12:28:49 +00:00
|
|
|
ulint n_pointers; /*!< used in debugging: the number of
|
2005-10-27 07:29:40 +00:00
|
|
|
pointers in the adaptive hash index
|
|
|
|
pointing to this frame */
|
2008-12-17 09:19:56 +00:00
|
|
|
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
|
2009-05-26 12:28:49 +00:00
|
|
|
unsigned is_hashed:1; /*!< TRUE if hash index has
|
|
|
|
already been built on this
|
|
|
|
page; note that it does not
|
|
|
|
guarantee that the index is
|
|
|
|
complete, though: there may
|
|
|
|
have been hash collisions,
|
|
|
|
record deletions, etc. */
|
|
|
|
unsigned curr_n_fields:10;/*!< prefix length for hash indexing:
|
2005-10-27 07:29:40 +00:00
|
|
|
number of full fields */
|
2009-05-26 12:28:49 +00:00
|
|
|
unsigned curr_n_bytes:15;/*!< number of bytes in hash
|
|
|
|
indexing */
|
|
|
|
unsigned curr_left_side:1;/*!< TRUE or FALSE in hash indexing */
|
|
|
|
dict_index_t* index; /*!< Index for which the adaptive
|
2005-11-29 12:30:46 +00:00
|
|
|
hash index has been created. */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @} */
|
2009-05-27 06:57:25 +00:00
|
|
|
# ifdef UNIV_SYNC_DEBUG
|
|
|
|
/** @name Debug fields */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
|
|
|
rw_lock_t debug_latch; /*!< in the debug version, each thread
|
2005-10-27 07:29:40 +00:00
|
|
|
which bufferfixes the block acquires
|
|
|
|
an s-latch here; so we can use the
|
|
|
|
debug utilities in sync0rw */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @} */
|
2009-05-27 06:57:25 +00:00
|
|
|
# endif
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2005-10-27 07:29:40 +00:00
|
|
|
};
|
|
|
|
|
2009-05-25 12:09:24 +00:00
|
|
|
/** Check if a buf_block_t object is in a valid state
|
|
|
|
@param block buffer block
|
|
|
|
@return TRUE if valid */
|
2006-12-07 10:02:23 +00:00
|
|
|
#define buf_block_state_valid(block) \
|
2006-11-23 15:14:45 +00:00
|
|
|
(buf_block_get_state(block) >= BUF_BLOCK_NOT_USED \
|
|
|
|
&& (buf_block_get_state(block) <= BUF_BLOCK_REMOVE_HASH))
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2007-01-05 10:49:56 +00:00
|
|
|
Compute the hash fold value for blocks in buf_pool->zip_hash. */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
2007-01-05 10:49:56 +00:00
|
|
|
#define BUF_POOL_ZIP_FOLD_PTR(ptr) ((ulint) (ptr) / UNIV_PAGE_SIZE)
|
|
|
|
#define BUF_POOL_ZIP_FOLD(b) BUF_POOL_ZIP_FOLD_PTR((b)->frame)
|
|
|
|
#define BUF_POOL_ZIP_FOLD_BPAGE(b) BUF_POOL_ZIP_FOLD((buf_block_t*) (b))
|
2009-05-27 06:57:25 +00:00
|
|
|
/* @} */
|
2007-01-05 10:49:56 +00:00
|
|
|
|
2009-08-27 15:00:27 +00:00
|
|
|
/** @brief The buffer pool statistics structure. */
|
|
|
|
struct buf_pool_stat_struct{
|
|
|
|
ulint n_page_gets; /*!< number of page gets performed;
|
|
|
|
also successful searches through
|
|
|
|
the adaptive hash index are
|
|
|
|
counted as page gets; this field
|
|
|
|
is NOT protected by the buffer
|
|
|
|
pool mutex */
|
|
|
|
ulint n_pages_read; /*!< number read operations */
|
|
|
|
ulint n_pages_written;/*!< number write operations */
|
|
|
|
ulint n_pages_created;/*!< number of pages created
|
|
|
|
in the pool with no read */
|
|
|
|
ulint n_ra_pages_read;/*!< number of pages read in
|
|
|
|
as part of read ahead */
|
|
|
|
ulint n_ra_pages_evicted;/*!< number of read ahead
|
|
|
|
pages that are evicted without
|
|
|
|
being accessed */
|
|
|
|
ulint n_pages_made_young; /*!< number of pages made young, in
|
|
|
|
calls to buf_LRU_make_block_young() */
|
|
|
|
ulint n_pages_not_made_young; /*!< number of pages not made
|
|
|
|
young because the first access
|
|
|
|
was not long enough ago, in
|
|
|
|
buf_page_peek_if_too_old() */
|
|
|
|
};
|
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/** @brief The buffer pool structure.
|
|
|
|
|
|
|
|
NOTE! The definition appears here only for other modules of this
|
|
|
|
directory (buf) to see it. Do not use from outside! */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
struct buf_pool_struct{
|
|
|
|
|
2009-05-27 06:57:25 +00:00
|
|
|
/** @name General fields */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
ulint n_chunks; /*!< number of buffer pool chunks */
|
|
|
|
buf_chunk_t* chunks; /*!< buffer pool chunks */
|
|
|
|
ulint curr_size; /*!< current pool size in pages */
|
|
|
|
hash_table_t* page_hash; /*!< hash table of buf_page_t or
|
2006-12-11 09:54:13 +00:00
|
|
|
buf_block_t file pages,
|
|
|
|
buf_page_in_file() == TRUE,
|
|
|
|
indexed by (space_id, offset) */
|
2009-05-26 12:28:49 +00:00
|
|
|
hash_table_t* zip_hash; /*!< hash table of buf_block_t blocks
|
2006-12-11 09:54:13 +00:00
|
|
|
whose frames are allocated to the
|
|
|
|
zip buddy system,
|
|
|
|
indexed by block->frame */
|
2009-05-26 12:28:49 +00:00
|
|
|
ulint n_pend_reads; /*!< number of pending read operations */
|
|
|
|
ulint n_pend_unzip; /*!< number of pending decompressions */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
time_t last_printout_time;
|
|
|
|
/*!< when buf_print_io was last time
|
2005-10-27 07:29:40 +00:00
|
|
|
called */
|
2009-08-27 15:00:27 +00:00
|
|
|
buf_pool_stat_t stat; /*!< current statistics */
|
|
|
|
buf_pool_stat_t old_stat; /*!< old statistics */
|
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @} */
|
2009-08-27 15:00:27 +00:00
|
|
|
|
2009-05-27 06:57:25 +00:00
|
|
|
/** @name Page flushing algorithm fields */
|
2009-08-27 15:00:27 +00:00
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-11-27 14:12:09 +00:00
|
|
|
UT_LIST_BASE_NODE_T(buf_page_t) flush_list;
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< base node of the modified block
|
2005-10-27 07:29:40 +00:00
|
|
|
list */
|
2006-11-27 14:12:09 +00:00
|
|
|
ibool init_flush[BUF_FLUSH_N_TYPES];
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< this is TRUE when a flush of the
|
2005-10-27 07:29:40 +00:00
|
|
|
given type is being initialized */
|
2006-11-27 14:12:09 +00:00
|
|
|
ulint n_flush[BUF_FLUSH_N_TYPES];
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< this is the number of pending
|
2005-10-27 07:29:40 +00:00
|
|
|
writes in the given flush type */
|
2006-11-27 14:12:09 +00:00
|
|
|
os_event_t no_flush[BUF_FLUSH_N_TYPES];
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< this is in the set state
|
|
|
|
when there is no flush batch
|
|
|
|
of the given type running */
|
|
|
|
ulint freed_page_clock;/*!< a sequence number used
|
|
|
|
to count the number of buffer
|
|
|
|
blocks removed from the end of
|
|
|
|
the LRU list; NOTE that this
|
|
|
|
counter may wrap around at 4
|
|
|
|
billion! A thread is allowed
|
|
|
|
to read this for heuristic
|
|
|
|
purposes without holding any
|
|
|
|
mutex or latch */
|
|
|
|
ulint LRU_flush_ended;/*!< when an LRU flush ends for a page,
|
2005-10-27 07:29:40 +00:00
|
|
|
this is incremented by one; this is
|
|
|
|
set to zero when a buffer block is
|
|
|
|
allocated */
|
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @} */
|
2009-05-27 06:57:25 +00:00
|
|
|
/** @name LRU replacement algorithm fields */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-12-04 12:44:06 +00:00
|
|
|
UT_LIST_BASE_NODE_T(buf_page_t) free;
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< base node of the free
|
|
|
|
block list */
|
2006-11-30 12:27:49 +00:00
|
|
|
UT_LIST_BASE_NODE_T(buf_page_t) LRU;
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< base node of the LRU list */
|
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.
ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?
buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.
bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.
bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.
buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct
buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.
buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old. Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.
buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.
buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young. This function is only for crash
diagnostics.
buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.
rb://129 approved by Heikki Tuuri. This addresses Bug #45015.
2009-08-27 06:25:00 +00:00
|
|
|
buf_page_t* LRU_old; /*!< pointer to the about
|
|
|
|
buf_LRU_old_ratio/BUF_LRU_OLD_RATIO_DIV
|
|
|
|
oldest blocks in the LRU list;
|
|
|
|
NULL if LRU length less than
|
|
|
|
BUF_LRU_OLD_MIN_LEN;
|
2008-08-08 13:01:02 +00:00
|
|
|
NOTE: when LRU_old != NULL, its length
|
|
|
|
should always equal LRU_old_len */
|
2009-05-26 12:28:49 +00:00
|
|
|
ulint LRU_old_len; /*!< length of the LRU list from
|
2005-10-27 07:29:40 +00:00
|
|
|
the block to which LRU_old points
|
|
|
|
onward, including that block;
|
|
|
|
see buf0lru.c for the restrictions
|
2009-10-29 11:04:11 +00:00
|
|
|
on this value; 0 if LRU_old == NULL;
|
2008-08-08 13:01:02 +00:00
|
|
|
NOTE: LRU_old_len must be adjusted
|
|
|
|
whenever LRU_old shrinks or grows! */
|
2006-12-07 13:29:04 +00:00
|
|
|
|
2008-03-03 12:48:38 +00:00
|
|
|
UT_LIST_BASE_NODE_T(buf_block_t) unzip_LRU;
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< base node of the
|
|
|
|
unzip_LRU list */
|
2008-03-03 12:48:38 +00:00
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @} */
|
2009-05-27 06:57:25 +00:00
|
|
|
/** @name Buddy allocator fields
|
|
|
|
The buddy allocator is used for allocating compressed page
|
|
|
|
frames and buf_page_t descriptors of blocks that exist
|
|
|
|
in the buffer pool only in compressed form. */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
2006-12-07 13:29:04 +00:00
|
|
|
UT_LIST_BASE_NODE_T(buf_page_t) zip_clean;
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< unmodified compressed pages */
|
2006-12-07 13:29:04 +00:00
|
|
|
UT_LIST_BASE_NODE_T(buf_page_t) zip_free[BUF_BUDDY_SIZES];
|
2009-05-26 12:28:49 +00:00
|
|
|
/*!< buddy free lists */
|
2006-12-07 15:20:53 +00:00
|
|
|
#if BUF_BUDDY_HIGH != UNIV_PAGE_SIZE
|
|
|
|
# error "BUF_BUDDY_HIGH != UNIV_PAGE_SIZE"
|
2006-12-07 13:29:04 +00:00
|
|
|
#endif
|
|
|
|
#if BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE
|
|
|
|
# error "BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE"
|
|
|
|
#endif
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @} */
|
2005-10-27 07:29:40 +00:00
|
|
|
};
|
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/** mutex protecting the buffer pool struct and control blocks, except the
|
2008-01-10 09:37:13 +00:00
|
|
|
read-write lock in them */
|
|
|
|
extern mutex_t buf_pool_mutex;
|
2009-05-26 12:28:49 +00:00
|
|
|
/** mutex protecting the control blocks of compressed-only pages
|
2008-01-10 09:37:13 +00:00
|
|
|
(of type buf_page_t, not buf_block_t) */
|
|
|
|
extern mutex_t buf_pool_zip_mutex;
|
|
|
|
|
2009-05-27 06:57:25 +00:00
|
|
|
/** @name Accessors for buf_pool_mutex.
|
|
|
|
Use these instead of accessing buf_pool_mutex directly. */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
2008-01-10 09:37:13 +00:00
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/** Test if buf_pool_mutex is owned. */
|
2008-01-10 09:37:13 +00:00
|
|
|
#define buf_pool_mutex_own() mutex_own(&buf_pool_mutex)
|
2009-05-26 12:28:49 +00:00
|
|
|
/** Acquire the buffer pool mutex. */
|
2008-01-10 09:37:13 +00:00
|
|
|
#define buf_pool_mutex_enter() do { \
|
|
|
|
ut_ad(!mutex_own(&buf_pool_zip_mutex)); \
|
|
|
|
mutex_enter(&buf_pool_mutex); \
|
|
|
|
} while (0)
|
2008-01-10 09:51:57 +00:00
|
|
|
|
|
|
|
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
|
|
|
|
/** Flag to forbid the release of the buffer pool mutex.
|
|
|
|
Protected by buf_pool_mutex. */
|
|
|
|
extern ulint buf_pool_mutex_exit_forbidden;
|
2009-05-26 12:28:49 +00:00
|
|
|
/** Forbid the release of the buffer pool mutex. */
|
2008-01-10 09:51:57 +00:00
|
|
|
# define buf_pool_mutex_exit_forbid() do { \
|
|
|
|
ut_ad(buf_pool_mutex_own()); \
|
|
|
|
buf_pool_mutex_exit_forbidden++; \
|
|
|
|
} while (0)
|
2009-05-26 12:28:49 +00:00
|
|
|
/** Allow the release of the buffer pool mutex. */
|
2008-01-10 09:51:57 +00:00
|
|
|
# define buf_pool_mutex_exit_allow() do { \
|
|
|
|
ut_ad(buf_pool_mutex_own()); \
|
|
|
|
ut_a(buf_pool_mutex_exit_forbidden); \
|
|
|
|
buf_pool_mutex_exit_forbidden--; \
|
|
|
|
} while (0)
|
2009-05-26 12:28:49 +00:00
|
|
|
/** Release the buffer pool mutex. */
|
2008-01-10 09:51:57 +00:00
|
|
|
# define buf_pool_mutex_exit() do { \
|
|
|
|
ut_a(!buf_pool_mutex_exit_forbidden); \
|
|
|
|
mutex_exit(&buf_pool_mutex); \
|
|
|
|
} while (0)
|
|
|
|
#else
|
2009-05-26 12:28:49 +00:00
|
|
|
/** Forbid the release of the buffer pool mutex. */
|
2008-01-10 09:51:57 +00:00
|
|
|
# define buf_pool_mutex_exit_forbid() ((void) 0)
|
2009-05-26 12:28:49 +00:00
|
|
|
/** Allow the release of the buffer pool mutex. */
|
2008-01-10 09:51:57 +00:00
|
|
|
# define buf_pool_mutex_exit_allow() ((void) 0)
|
2009-05-26 12:28:49 +00:00
|
|
|
/** Release the buffer pool mutex. */
|
2008-01-10 09:51:57 +00:00
|
|
|
# define buf_pool_mutex_exit() mutex_exit(&buf_pool_mutex)
|
|
|
|
#endif
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @} */
|
2008-01-10 09:37:13 +00:00
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/**********************************************************************
|
2005-10-27 07:29:40 +00:00
|
|
|
Let us list the consistency conditions for different control block states.
|
|
|
|
|
|
|
|
NOT_USED: is in free list, not in LRU list, not in flush list, nor
|
|
|
|
page hash table
|
|
|
|
READY_FOR_USE: is not in free list, LRU list, or flush list, nor page
|
|
|
|
hash table
|
|
|
|
MEMORY: is not in free list, LRU list, or flush list, nor page
|
|
|
|
hash table
|
|
|
|
FILE_PAGE: space and offset are defined, is in page hash table
|
|
|
|
if io_fix == BUF_IO_WRITE,
|
2006-11-28 11:08:33 +00:00
|
|
|
pool: no_flush[flush_type] is in reset state,
|
|
|
|
pool: n_flush[flush_type] > 0
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
(1) if buf_fix_count == 0, then
|
|
|
|
is in LRU list, not in free list
|
|
|
|
is in flush list,
|
|
|
|
if and only if oldest_modification > 0
|
|
|
|
is x-locked,
|
|
|
|
if and only if io_fix == BUF_IO_READ
|
|
|
|
is s-locked,
|
|
|
|
if and only if io_fix == BUF_IO_WRITE
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
(2) if buf_fix_count > 0, then
|
|
|
|
is not in LRU list, not in free list
|
|
|
|
is in flush list,
|
|
|
|
if and only if oldest_modification > 0
|
2006-02-23 19:25:29 +00:00
|
|
|
if io_fix == BUF_IO_READ,
|
2005-10-27 07:29:40 +00:00
|
|
|
is x-locked
|
|
|
|
if io_fix == BUF_IO_WRITE,
|
|
|
|
is s-locked
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
State transitions:
|
|
|
|
|
|
|
|
NOT_USED => READY_FOR_USE
|
|
|
|
READY_FOR_USE => MEMORY
|
|
|
|
READY_FOR_USE => FILE_PAGE
|
|
|
|
MEMORY => NOT_USED
|
2006-02-23 19:25:29 +00:00
|
|
|
FILE_PAGE => NOT_USED NOTE: This transition is allowed if and only if
|
2005-10-27 07:29:40 +00:00
|
|
|
(1) buf_fix_count == 0,
|
|
|
|
(2) oldest_modification == 0, and
|
|
|
|
(3) io_fix == 0.
|
2009-05-25 05:54:17 +00:00
|
|
|
*/
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
#ifndef UNIV_NONINL
|
|
|
|
#include "buf0buf.ic"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|