2009-05-27 15:15:59 +05:30
|
|
|
/*****************************************************************************
|
|
|
|
|
2010-04-01 15:59:25 +04:00
|
|
|
Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
|
2009-05-27 15:15:59 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/**************************************************//**
|
|
|
|
@file include/buf0buf.h
|
|
|
|
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"
|
|
|
|
#include "page0types.h"
|
2010-04-01 16:56:22 +04:00
|
|
|
#include "ut0rbt.h"
|
2009-05-27 15:15:59 +05:30
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
|
|
#include "os0proc.h"
|
|
|
|
|
2009-07-30 17:42:56 +05:00
|
|
|
/** @name Modes for buf_page_get_gen */
|
2009-05-27 15:15:59 +05:30
|
|
|
/* @{ */
|
|
|
|
#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-07-30 17:42:56 +05:00
|
|
|
/** @name Modes for buf_page_get_known_nowait */
|
2009-05-27 15:15:59 +05:30
|
|
|
/* @{ */
|
|
|
|
#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 */
|
|
|
|
#ifdef UNIV_DEBUG
|
|
|
|
extern ibool buf_debug_prints;/*!< If this is set TRUE, the program
|
|
|
|
prints info whenever read or flush
|
|
|
|
occurs */
|
|
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
extern ulint srv_buf_pool_write_requests; /*!< variable to count write request
|
|
|
|
issued */
|
|
|
|
#else /* !UNIV_HOTBACKUP */
|
|
|
|
extern buf_block_t* back_block1; /*!< first block, for --apply-log */
|
|
|
|
extern buf_block_t* back_block2; /*!< second block, for page reorganize */
|
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
|
|
|
|
/** Magic value to use instead of checksums when they are disabled */
|
|
|
|
#define BUF_NO_CHECKSUM_MAGIC 0xDEADBEEFUL
|
|
|
|
|
|
|
|
/** @brief States of a control block
|
|
|
|
@see buf_page_struct
|
|
|
|
|
|
|
|
The enumeration values must be 0..7. */
|
|
|
|
enum buf_page_state {
|
|
|
|
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 */
|
|
|
|
|
|
|
|
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
|
|
|
|
before putting to the free list */
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
|
|
/********************************************************************//**
|
|
|
|
Creates the buffer pool.
|
|
|
|
@return own: buf_pool object, NULL if not enough memory or error */
|
|
|
|
UNIV_INTERN
|
|
|
|
buf_pool_t*
|
|
|
|
buf_pool_init(void);
|
|
|
|
/*===============*/
|
|
|
|
/********************************************************************//**
|
|
|
|
Frees the buffer pool at shutdown. This must not be invoked before
|
|
|
|
freeing all mutexes. */
|
|
|
|
UNIV_INTERN
|
|
|
|
void
|
|
|
|
buf_pool_free(void);
|
|
|
|
/*===============*/
|
|
|
|
|
|
|
|
/********************************************************************//**
|
|
|
|
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);
|
|
|
|
/*==========================*/
|
|
|
|
|
|
|
|
/********************************************************************//**
|
|
|
|
Relocate a buffer control block. Relocates the block on the LRU list
|
|
|
|
and in buf_pool->page_hash. Does not relocate bpage->list.
|
|
|
|
The caller must take care of relocating bpage->list. */
|
|
|
|
UNIV_INTERN
|
|
|
|
void
|
|
|
|
buf_relocate(
|
|
|
|
/*=========*/
|
|
|
|
buf_page_t* bpage, /*!< in/out: control block being relocated;
|
|
|
|
buf_page_get_state(bpage) must be
|
|
|
|
BUF_BLOCK_ZIP_DIRTY or BUF_BLOCK_ZIP_PAGE */
|
|
|
|
buf_page_t* dpage) /*!< in/out: destination control block */
|
|
|
|
__attribute__((nonnull));
|
|
|
|
/********************************************************************//**
|
|
|
|
Resizes the buffer pool. */
|
|
|
|
UNIV_INTERN
|
|
|
|
void
|
|
|
|
buf_pool_resize(void);
|
|
|
|
/*=================*/
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the current size of buffer buf_pool in bytes.
|
|
|
|
@return size in bytes */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_pool_get_curr_size(void);
|
|
|
|
/*========================*/
|
|
|
|
/********************************************************************//**
|
|
|
|
Gets the smallest oldest_modification lsn for any page in the pool. Returns
|
|
|
|
zero if all modified pages have been flushed to disk.
|
|
|
|
@return oldest modification in pool, zero if none */
|
|
|
|
UNIV_INLINE
|
|
|
|
ib_uint64_t
|
|
|
|
buf_pool_get_oldest_modification(void);
|
|
|
|
/*==================================*/
|
|
|
|
/********************************************************************//**
|
|
|
|
Allocates a buffer block.
|
|
|
|
@return own: the allocated block, in state BUF_BLOCK_MEMORY */
|
|
|
|
UNIV_INLINE
|
|
|
|
buf_block_t*
|
|
|
|
buf_block_alloc(
|
|
|
|
/*============*/
|
|
|
|
ulint zip_size); /*!< in: compressed page size in bytes,
|
|
|
|
or 0 if uncompressed tablespace */
|
|
|
|
/********************************************************************//**
|
|
|
|
Frees a buffer block which does not contain a file page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_block_free(
|
|
|
|
/*===========*/
|
|
|
|
buf_block_t* block); /*!< in, own: block to be freed */
|
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
/*********************************************************************//**
|
|
|
|
Copies contents of a buffer frame to a given buffer.
|
|
|
|
@return buf */
|
|
|
|
UNIV_INLINE
|
|
|
|
byte*
|
|
|
|
buf_frame_copy(
|
|
|
|
/*===========*/
|
|
|
|
byte* buf, /*!< in: buffer to copy to */
|
|
|
|
const buf_frame_t* frame); /*!< in: buffer frame */
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
|
|
/**************************************************************//**
|
|
|
|
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! */
|
|
|
|
#define buf_page_get(SP, ZS, OF, LA, MTR) buf_page_get_gen(\
|
|
|
|
SP, ZS, OF, LA, NULL,\
|
|
|
|
BUF_GET, __FILE__, __LINE__, MTR)
|
|
|
|
/**************************************************************//**
|
|
|
|
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. */
|
|
|
|
#define buf_page_get_with_no_latch(SP, ZS, OF, MTR) buf_page_get_gen(\
|
|
|
|
SP, ZS, OF, RW_NO_LATCH, NULL,\
|
|
|
|
BUF_GET_NO_LATCH, __FILE__, __LINE__, MTR)
|
|
|
|
/********************************************************************//**
|
|
|
|
This is the general function used to get optimistic access to a database
|
|
|
|
page.
|
|
|
|
@return TRUE if success */
|
|
|
|
UNIV_INTERN
|
|
|
|
ibool
|
Applying InnoDB snapshot
Detailed revision comments:
r6559 | marko | 2010-02-04 13:21:18 +0200 (Thu, 04 Feb 2010) | 14 lines
branches/zip: Pass the file name and line number of the caller of the
b-tree cursor functions to the buffer pool requests, in order to make
the latch diagnostics more accurate.
buf_page_optimistic_get_func(): Renamed to buf_page_optimistic_get().
btr_page_get_father_node_ptr(), btr_insert_on_non_leaf_level(),
btr_pcur_open(), btr_pcur_open_with_no_init(), btr_pcur_open_on_user_rec(),
btr_pcur_open_at_rnd_pos(), btr_pcur_restore_position(),
btr_cur_open_at_index_side(), btr_cur_open_at_rnd_pos():
Rename the function to _func and add the parameters file, line.
Define wrapper macros with __FILE__, __LINE__.
btr_cur_search_to_nth_level(): Add the parameters file, line.
2010-04-01 15:37:45 +04:00
|
|
|
buf_page_optimistic_get(
|
|
|
|
/*====================*/
|
2009-05-27 15:15:59 +05:30
|
|
|
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
|
|
|
|
..._GUESS_ON_CLOCK */
|
|
|
|
const char* file, /*!< in: file name */
|
|
|
|
ulint line, /*!< in: line where called */
|
|
|
|
mtr_t* mtr); /*!< in: mini-transaction */
|
|
|
|
/********************************************************************//**
|
|
|
|
This is used to get access to a known database page, when no waiting can be
|
|
|
|
done.
|
|
|
|
@return TRUE if success */
|
|
|
|
UNIV_INTERN
|
|
|
|
ibool
|
|
|
|
buf_page_get_known_nowait(
|
|
|
|
/*======================*/
|
|
|
|
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 */
|
|
|
|
|
|
|
|
/*******************************************************************//**
|
|
|
|
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-07-30 17:42:56 +05:00
|
|
|
UNIV_INTERN
|
2009-05-27 15:15:59 +05:30
|
|
|
const buf_block_t*
|
|
|
|
buf_page_try_get_func(
|
|
|
|
/*==================*/
|
|
|
|
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 */
|
|
|
|
|
2009-07-30 17:42:56 +05: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 */
|
2009-05-27 15:15:59 +05:30
|
|
|
#define buf_page_try_get(space_id, page_no, mtr) \
|
|
|
|
buf_page_try_get_func(space_id, page_no, __FILE__, __LINE__, mtr);
|
|
|
|
|
|
|
|
/********************************************************************//**
|
|
|
|
Get read access to a compressed page (usually of type
|
|
|
|
FIL_PAGE_TYPE_ZBLOB or FIL_PAGE_TYPE_ZBLOB2).
|
|
|
|
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
|
|
|
|
the same set of mutexes or latches.
|
|
|
|
@return pointer to the block, or NULL if not compressed */
|
|
|
|
UNIV_INTERN
|
|
|
|
buf_page_t*
|
|
|
|
buf_page_get_zip(
|
|
|
|
/*=============*/
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size */
|
|
|
|
ulint offset);/*!< in: page number */
|
|
|
|
/********************************************************************//**
|
|
|
|
This is the general function used to get access to a database page.
|
|
|
|
@return pointer to the block or NULL */
|
|
|
|
UNIV_INTERN
|
|
|
|
buf_block_t*
|
|
|
|
buf_page_get_gen(
|
|
|
|
/*=============*/
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
|
|
|
or 0 for uncompressed pages */
|
|
|
|
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,
|
|
|
|
BUF_GET_NO_LATCH */
|
|
|
|
const char* file, /*!< in: file name */
|
|
|
|
ulint line, /*!< in: line where called */
|
|
|
|
mtr_t* mtr); /*!< in: mini-transaction */
|
|
|
|
/********************************************************************//**
|
|
|
|
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 =>
|
|
|
|
FILE_PAGE (the other is buf_page_get_gen).
|
|
|
|
@return pointer to the block, page bufferfixed */
|
|
|
|
UNIV_INTERN
|
|
|
|
buf_block_t*
|
|
|
|
buf_page_create(
|
|
|
|
/*============*/
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset, /*!< in: offset of the page within space in units of
|
|
|
|
a page */
|
|
|
|
ulint zip_size,/*!< in: compressed page size, or 0 */
|
|
|
|
mtr_t* mtr); /*!< in: mini-transaction handle */
|
|
|
|
#else /* !UNIV_HOTBACKUP */
|
|
|
|
/********************************************************************//**
|
|
|
|
Inits a page to the buffer buf_pool, for use in ibbackup --restore. */
|
|
|
|
UNIV_INTERN
|
|
|
|
void
|
|
|
|
buf_page_init_for_backup_restore(
|
|
|
|
/*=============================*/
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset, /*!< in: offset of the page within space
|
|
|
|
in units of a page */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
|
|
|
or 0 for uncompressed pages */
|
|
|
|
buf_block_t* block); /*!< in: block to init */
|
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
|
|
/********************************************************************//**
|
|
|
|
Releases a compressed-only page acquired with buf_page_get_zip(). */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_release_zip(
|
|
|
|
/*=================*/
|
|
|
|
buf_page_t* bpage); /*!< in: buffer block */
|
|
|
|
/********************************************************************//**
|
|
|
|
Decrements the bufferfix count of a buffer control block and releases
|
|
|
|
a latch, if specified. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_release(
|
|
|
|
/*=============*/
|
|
|
|
buf_block_t* block, /*!< in: buffer block */
|
|
|
|
ulint rw_latch, /*!< in: RW_S_LATCH, RW_X_LATCH,
|
|
|
|
RW_NO_LATCH */
|
|
|
|
mtr_t* mtr); /*!< in: mtr */
|
|
|
|
/********************************************************************//**
|
|
|
|
Moves a page to the start of the buffer pool LRU list. This high-level
|
Applying InnoDB Plugin 1.0.5 snapshot, part 7
From revisions r5792 to r5864
Detailed revision comments:
r5792 | vasil | 2009-09-09 08:35:58 -0500 (Wed, 09 Sep 2009) | 32 lines
branches/zip:
Fix a bug in manipulating the variable innodb_old_blocks_pct:
for any value assigned it got that value -1, except for 75. When
assigned 75, it got 75.
mysql> set global innodb_old_blocks_pct=15;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'innodb_old_blocks_pct';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| innodb_old_blocks_pct | 14 |
+-----------------------+-------+
1 row in set (0.00 sec)
mysql> set global innodb_old_blocks_pct=75;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'innodb_old_blocks_pct';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| innodb_old_blocks_pct | 75 |
+-----------------------+-------+
After the fix it gets exactly what was assigned.
Approved by: Marko (via IM)
r5798 | calvin | 2009-09-09 10:28:10 -0500 (Wed, 09 Sep 2009) | 5 lines
branches/zip:
HA_ERR_TOO_MANY_CONCURRENT_TRXS is added in 5.1.38.
But the plugin should still work with previous versions
of MySQL.
r5804 | marko | 2009-09-10 00:29:31 -0500 (Thu, 10 Sep 2009) | 1 line
branches/zip: trx_cleanup_at_db_startup(): Fix a typo in comment.
r5822 | marko | 2009-09-10 05:10:20 -0500 (Thu, 10 Sep 2009) | 1 line
branches/zip: buf_page_release(): De-stutter the function comment.
r5825 | marko | 2009-09-10 05:47:09 -0500 (Thu, 10 Sep 2009) | 20 lines
branches/zip: Reduce mutex contention that was introduced when
addressing Bug #45015 (Issue #316), in r5703.
buf_page_set_accessed_make_young(): New auxiliary function, called by
buf_page_get_zip(), buf_page_get_gen(),
buf_page_optimistic_get_func(). Call ut_time_ms() outside of
buf_pool_mutex. Use cached access_time.
buf_page_set_accessed(): Add the parameter time_ms, so that
ut_time_ms() need not be called while holding buf_pool_mutex.
buf_page_optimistic_get_func(), buf_page_get_known_nowait(): Read
buf_page_t::access_time without holding buf_pool_mutex. This should be
OK, because the field is only used for heuristic purposes.
buf_page_peek_if_too_old(): If buf_pool->freed_page_clock == 0, return
FALSE, so that we will not waste time moving blocks in the LRU list in
the warm-up phase or when the workload fits in the buffer pool.
rb://156 approved by Sunny Bains
r5826 | marko | 2009-09-10 06:29:46 -0500 (Thu, 10 Sep 2009) | 12 lines
branches/zip: Roll back recovered dictionary transactions before
dropping incomplete indexes (Issue #337).
trx_rollback_or_clean_recovered(ibool all): New function, split from
trx_rollback_or_clean_all_recovered(). all==FALSE will only roll back
dictionary transactions.
recv_recovery_from_checkpoint_finish(): Call
trx_rollback_or_clean_recovered(FALSE) before
row_merge_drop_temp_indexes().
rb://158 approved by Sunny Bains
r5858 | vasil | 2009-09-11 12:46:47 -0500 (Fri, 11 Sep 2009) | 4 lines
branches/zip:
Fix the indentation of the closing bracket.
r5863 | vasil | 2009-09-12 02:07:08 -0500 (Sat, 12 Sep 2009) | 10 lines
branches/zip:
Check that pthread_t can indeed be passed to Solaris atomic functions, instead
of assuming that it can be passed if 0 can be assigned to it. It could be that:
* 0 can be assigned, but pthread_t cannot be passed and
* 0 cannot be assigned but pthread_t can be passed
Better to check what we are interested in, not something else and make
assumptions.
r5864 | vasil | 2009-09-12 02:22:55 -0500 (Sat, 12 Sep 2009) | 4 lines
branches/zip:
Include string.h which is needed for memset().
2009-10-08 18:35:59 +05:30
|
|
|
function can be used to prevent an important page from slipping out of
|
2009-05-27 15:15:59 +05:30
|
|
|
the buffer pool. */
|
|
|
|
UNIV_INTERN
|
|
|
|
void
|
|
|
|
buf_page_make_young(
|
|
|
|
/*================*/
|
|
|
|
buf_page_t* bpage); /*!< in: buffer block of a file page */
|
|
|
|
/********************************************************************//**
|
|
|
|
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 */
|
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
buf_page_peek(
|
|
|
|
/*==========*/
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset);/*!< in: page number */
|
|
|
|
/********************************************************************//**
|
|
|
|
Resets the check_index_page_at_flush field of a page if found in the buffer
|
|
|
|
pool. */
|
|
|
|
UNIV_INTERN
|
|
|
|
void
|
|
|
|
buf_reset_check_index_page_at_flush(
|
|
|
|
/*================================*/
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset);/*!< in: page number */
|
|
|
|
#ifdef UNIV_DEBUG_FILE_ACCESSES
|
|
|
|
/********************************************************************//**
|
|
|
|
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
|
|
|
|
reallocated.
|
|
|
|
@return control block if found in page hash table, otherwise NULL */
|
|
|
|
UNIV_INTERN
|
|
|
|
buf_page_t*
|
|
|
|
buf_page_set_file_page_was_freed(
|
|
|
|
/*=============================*/
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset);/*!< in: page number */
|
|
|
|
/********************************************************************//**
|
|
|
|
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
|
|
|
|
reallocated.
|
|
|
|
@return control block if found in page hash table, otherwise NULL */
|
|
|
|
UNIV_INTERN
|
|
|
|
buf_page_t*
|
|
|
|
buf_page_reset_file_page_was_freed(
|
|
|
|
/*===============================*/
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset); /*!< in: page number */
|
|
|
|
#endif /* UNIV_DEBUG_FILE_ACCESSES */
|
|
|
|
/********************************************************************//**
|
|
|
|
Reads the freed_page_clock of a buffer block.
|
|
|
|
@return freed_page_clock */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_page_get_freed_page_clock(
|
|
|
|
/*==========================*/
|
|
|
|
const buf_page_t* bpage) /*!< in: block */
|
|
|
|
__attribute__((pure));
|
|
|
|
/********************************************************************//**
|
|
|
|
Reads the freed_page_clock of a buffer block.
|
|
|
|
@return freed_page_clock */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_block_get_freed_page_clock(
|
|
|
|
/*===========================*/
|
|
|
|
const buf_block_t* block) /*!< in: block */
|
|
|
|
__attribute__((pure));
|
|
|
|
|
|
|
|
/********************************************************************//**
|
|
|
|
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
|
|
|
|
mutex.
|
|
|
|
@return TRUE if should be made younger */
|
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
buf_page_peek_if_too_old(
|
|
|
|
/*=====================*/
|
|
|
|
const buf_page_t* bpage); /*!< in: block to make younger */
|
|
|
|
/********************************************************************//**
|
|
|
|
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
|
|
|
|
pool if it is found there.
|
|
|
|
@return TRUE if page hash index is built in search system */
|
|
|
|
UNIV_INTERN
|
|
|
|
ibool
|
|
|
|
buf_page_peek_if_search_hashed(
|
|
|
|
/*===========================*/
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset);/*!< in: page number */
|
|
|
|
/********************************************************************//**
|
|
|
|
Gets the youngest modification log sequence number for a frame.
|
|
|
|
Returns zero if not file page or no modification occurred yet.
|
|
|
|
@return newest modification to page */
|
|
|
|
UNIV_INLINE
|
|
|
|
ib_uint64_t
|
|
|
|
buf_page_get_newest_modification(
|
|
|
|
/*=============================*/
|
|
|
|
const buf_page_t* bpage); /*!< in: block containing the
|
|
|
|
page frame */
|
|
|
|
/********************************************************************//**
|
|
|
|
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
|
|
|
|
void
|
|
|
|
buf_block_modify_clock_inc(
|
|
|
|
/*=======================*/
|
|
|
|
buf_block_t* block); /*!< in: block */
|
|
|
|
/********************************************************************//**
|
|
|
|
Returns the value of the modify clock. The caller must have an s-lock
|
|
|
|
or x-lock on the block.
|
|
|
|
@return value */
|
|
|
|
UNIV_INLINE
|
|
|
|
ib_uint64_t
|
|
|
|
buf_block_get_modify_clock(
|
|
|
|
/*=======================*/
|
|
|
|
buf_block_t* block); /*!< in: block */
|
|
|
|
#else /* !UNIV_HOTBACKUP */
|
|
|
|
# define buf_block_modify_clock_inc(block) ((void) 0)
|
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
/********************************************************************//**
|
|
|
|
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
|
|
|
|
on 32-bit and 64-bit architectures.
|
|
|
|
@return checksum */
|
|
|
|
UNIV_INTERN
|
|
|
|
ulint
|
|
|
|
buf_calc_page_new_checksum(
|
|
|
|
/*=======================*/
|
|
|
|
const byte* page); /*!< in: buffer page */
|
|
|
|
/********************************************************************//**
|
|
|
|
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
|
|
|
|
checksum.
|
|
|
|
NOTE: we must first store the new formula checksum to
|
|
|
|
FIL_PAGE_SPACE_OR_CHKSUM before calculating and storing this old checksum
|
|
|
|
because this takes that field as an input!
|
|
|
|
@return checksum */
|
|
|
|
UNIV_INTERN
|
|
|
|
ulint
|
|
|
|
buf_calc_page_old_checksum(
|
|
|
|
/*=======================*/
|
|
|
|
const byte* page); /*!< in: buffer page */
|
|
|
|
/********************************************************************//**
|
|
|
|
Checks if a page is corrupt.
|
|
|
|
@return TRUE if corrupted */
|
|
|
|
UNIV_INTERN
|
|
|
|
ibool
|
|
|
|
buf_page_is_corrupted(
|
|
|
|
/*==================*/
|
|
|
|
const byte* read_buf, /*!< in: a database page */
|
|
|
|
ulint zip_size); /*!< in: size of compressed page;
|
|
|
|
0 for uncompressed pages */
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
|
|
/**********************************************************************//**
|
|
|
|
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(
|
|
|
|
/*=================*/
|
|
|
|
const void* ptr, /*!< in: pointer to a buffer frame */
|
|
|
|
ulint* space, /*!< out: space id */
|
|
|
|
fil_addr_t* addr); /*!< out: page offset and byte offset */
|
|
|
|
/**********************************************************************//**
|
|
|
|
Gets the hash value of a block. This can be used in searches in the
|
|
|
|
lock hash table.
|
|
|
|
@return lock hash value */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_block_get_lock_hash_val(
|
|
|
|
/*========================*/
|
|
|
|
const buf_block_t* block) /*!< in: block */
|
|
|
|
__attribute__((pure));
|
|
|
|
#ifdef UNIV_DEBUG
|
|
|
|
/*********************************************************************//**
|
|
|
|
Finds a block in the buffer pool that points to a
|
|
|
|
given compressed page.
|
|
|
|
@return buffer block pointing to the compressed page, or NULL */
|
|
|
|
UNIV_INTERN
|
|
|
|
buf_block_t*
|
|
|
|
buf_pool_contains_zip(
|
|
|
|
/*==================*/
|
|
|
|
const void* data); /*!< in: pointer to compressed page */
|
|
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
|
|
|
|
/*********************************************************************//**
|
|
|
|
Validates the buffer pool data structure.
|
|
|
|
@return TRUE */
|
|
|
|
UNIV_INTERN
|
|
|
|
ibool
|
|
|
|
buf_validate(void);
|
|
|
|
/*==============*/
|
|
|
|
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
|
|
|
|
#if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
|
|
|
|
/*********************************************************************//**
|
|
|
|
Prints info of the buffer pool data structure. */
|
|
|
|
UNIV_INTERN
|
|
|
|
void
|
|
|
|
buf_print(void);
|
|
|
|
/*============*/
|
|
|
|
#endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
|
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
/********************************************************************//**
|
|
|
|
Prints a page to stderr. */
|
|
|
|
UNIV_INTERN
|
|
|
|
void
|
|
|
|
buf_page_print(
|
|
|
|
/*===========*/
|
|
|
|
const byte* read_buf, /*!< in: a database page */
|
|
|
|
ulint zip_size); /*!< in: compressed page size, or
|
|
|
|
0 for uncompressed pages */
|
|
|
|
/********************************************************************//**
|
|
|
|
Decompress a block.
|
|
|
|
@return TRUE if successful */
|
|
|
|
UNIV_INTERN
|
|
|
|
ibool
|
|
|
|
buf_zip_decompress(
|
|
|
|
/*===============*/
|
|
|
|
buf_block_t* block, /*!< in/out: block */
|
|
|
|
ibool check); /*!< in: TRUE=verify the page checksum */
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
|
|
#ifdef UNIV_DEBUG
|
|
|
|
/*********************************************************************//**
|
|
|
|
Returns the number of latched pages in the buffer pool.
|
|
|
|
@return number of latched pages */
|
|
|
|
UNIV_INTERN
|
|
|
|
ulint
|
|
|
|
buf_get_latched_pages_number(void);
|
|
|
|
/*==============================*/
|
|
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
/*********************************************************************//**
|
|
|
|
Returns the number of pending buf pool ios.
|
|
|
|
@return number of pending I/O operations */
|
|
|
|
UNIV_INTERN
|
|
|
|
ulint
|
|
|
|
buf_get_n_pending_ios(void);
|
|
|
|
/*=======================*/
|
|
|
|
/*********************************************************************//**
|
|
|
|
Prints info of the buffer i/o. */
|
|
|
|
UNIV_INTERN
|
|
|
|
void
|
|
|
|
buf_print_io(
|
|
|
|
/*=========*/
|
|
|
|
FILE* file); /*!< in: file where to print */
|
|
|
|
/*********************************************************************//**
|
|
|
|
Returns the ratio in percents of modified pages in the buffer pool /
|
|
|
|
database pages in the buffer pool.
|
|
|
|
@return modified page percentage ratio */
|
|
|
|
UNIV_INTERN
|
|
|
|
ulint
|
|
|
|
buf_get_modified_ratio_pct(void);
|
|
|
|
/*============================*/
|
|
|
|
/**********************************************************************//**
|
|
|
|
Refreshes the statistics used to print per-second averages. */
|
|
|
|
UNIV_INTERN
|
|
|
|
void
|
|
|
|
buf_refresh_io_stats(void);
|
|
|
|
/*======================*/
|
|
|
|
/*********************************************************************//**
|
|
|
|
Asserts that all file pages in the buffer are in a replaceable state.
|
|
|
|
@return TRUE */
|
|
|
|
UNIV_INTERN
|
|
|
|
ibool
|
|
|
|
buf_all_freed(void);
|
|
|
|
/*===============*/
|
|
|
|
/*********************************************************************//**
|
|
|
|
Checks that there currently are no pending i/o-operations for the buffer
|
|
|
|
pool.
|
|
|
|
@return TRUE if there is no pending i/o */
|
|
|
|
UNIV_INTERN
|
|
|
|
ibool
|
|
|
|
buf_pool_check_no_pending_io(void);
|
|
|
|
/*==============================*/
|
|
|
|
/*********************************************************************//**
|
|
|
|
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. */
|
|
|
|
UNIV_INTERN
|
|
|
|
void
|
|
|
|
buf_pool_invalidate(void);
|
|
|
|
/*=====================*/
|
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
|
|
|
|
/*========================================================================
|
|
|
|
--------------------------- LOWER LEVEL ROUTINES -------------------------
|
|
|
|
=========================================================================*/
|
|
|
|
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
/*********************************************************************//**
|
|
|
|
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
|
|
|
|
buf_block_dbg_add_level(
|
|
|
|
/*====================*/
|
|
|
|
buf_block_t* block, /*!< in: buffer page
|
|
|
|
where we have acquired latch */
|
|
|
|
ulint level); /*!< in: latching order level */
|
|
|
|
#else /* UNIV_SYNC_DEBUG */
|
|
|
|
# define buf_block_dbg_add_level(block, level) /* nothing */
|
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the state of a block.
|
|
|
|
@return state */
|
|
|
|
UNIV_INLINE
|
|
|
|
enum buf_page_state
|
|
|
|
buf_page_get_state(
|
|
|
|
/*===============*/
|
|
|
|
const buf_page_t* bpage); /*!< in: pointer to the control block */
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the state of a block.
|
|
|
|
@return state */
|
|
|
|
UNIV_INLINE
|
|
|
|
enum buf_page_state
|
|
|
|
buf_block_get_state(
|
|
|
|
/*================*/
|
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
|
|
|
__attribute__((pure));
|
|
|
|
/*********************************************************************//**
|
|
|
|
Sets the state of a block. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_set_state(
|
|
|
|
/*===============*/
|
|
|
|
buf_page_t* bpage, /*!< in/out: pointer to control block */
|
|
|
|
enum buf_page_state state); /*!< in: state */
|
|
|
|
/*********************************************************************//**
|
|
|
|
Sets the state of a block. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_block_set_state(
|
|
|
|
/*================*/
|
|
|
|
buf_block_t* block, /*!< in/out: pointer to control block */
|
|
|
|
enum buf_page_state state); /*!< in: state */
|
|
|
|
/*********************************************************************//**
|
|
|
|
Determines if a block is mapped to a tablespace.
|
|
|
|
@return TRUE if mapped */
|
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
buf_page_in_file(
|
|
|
|
/*=============*/
|
|
|
|
const buf_page_t* bpage) /*!< in: pointer to control block */
|
|
|
|
__attribute__((pure));
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
|
|
/*********************************************************************//**
|
|
|
|
Determines if a block should be on unzip_LRU list.
|
|
|
|
@return TRUE if block belongs to unzip_LRU */
|
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
buf_page_belongs_to_unzip_LRU(
|
|
|
|
/*==========================*/
|
|
|
|
const buf_page_t* bpage) /*!< in: pointer to control block */
|
|
|
|
__attribute__((pure));
|
|
|
|
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the mutex of a block.
|
|
|
|
@return pointer to mutex protecting bpage */
|
|
|
|
UNIV_INLINE
|
|
|
|
mutex_t*
|
|
|
|
buf_page_get_mutex(
|
|
|
|
/*===============*/
|
|
|
|
const buf_page_t* bpage) /*!< in: pointer to control block */
|
|
|
|
__attribute__((pure));
|
|
|
|
|
|
|
|
/*********************************************************************//**
|
|
|
|
Get the flush type of a page.
|
|
|
|
@return flush type */
|
|
|
|
UNIV_INLINE
|
|
|
|
enum buf_flush
|
|
|
|
buf_page_get_flush_type(
|
|
|
|
/*====================*/
|
|
|
|
const buf_page_t* bpage) /*!< in: buffer page */
|
|
|
|
__attribute__((pure));
|
|
|
|
/*********************************************************************//**
|
|
|
|
Set the flush type of a page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_set_flush_type(
|
|
|
|
/*====================*/
|
|
|
|
buf_page_t* bpage, /*!< in: buffer page */
|
|
|
|
enum buf_flush flush_type); /*!< in: flush type */
|
|
|
|
/*********************************************************************//**
|
|
|
|
Map a block to a file page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_block_set_file_page(
|
|
|
|
/*====================*/
|
|
|
|
buf_block_t* block, /*!< in/out: pointer to control block */
|
|
|
|
ulint space, /*!< in: tablespace id */
|
|
|
|
ulint page_no);/*!< in: page number */
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the io_fix state of a block.
|
|
|
|
@return io_fix state */
|
|
|
|
UNIV_INLINE
|
|
|
|
enum buf_io_fix
|
|
|
|
buf_page_get_io_fix(
|
|
|
|
/*================*/
|
|
|
|
const buf_page_t* bpage) /*!< in: pointer to the control block */
|
|
|
|
__attribute__((pure));
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the io_fix state of a block.
|
|
|
|
@return io_fix state */
|
|
|
|
UNIV_INLINE
|
|
|
|
enum buf_io_fix
|
|
|
|
buf_block_get_io_fix(
|
|
|
|
/*================*/
|
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
|
|
|
__attribute__((pure));
|
|
|
|
/*********************************************************************//**
|
|
|
|
Sets the io_fix state of a block. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_set_io_fix(
|
|
|
|
/*================*/
|
|
|
|
buf_page_t* bpage, /*!< in/out: control block */
|
|
|
|
enum buf_io_fix io_fix);/*!< in: io_fix state */
|
|
|
|
/*********************************************************************//**
|
|
|
|
Sets the io_fix state of a block. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_block_set_io_fix(
|
|
|
|
/*=================*/
|
|
|
|
buf_block_t* block, /*!< in/out: control block */
|
|
|
|
enum buf_io_fix io_fix);/*!< in: io_fix state */
|
|
|
|
|
|
|
|
/********************************************************************//**
|
|
|
|
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(
|
|
|
|
/*==================*/
|
|
|
|
const buf_page_t* bpage) /*!< control block being relocated */
|
|
|
|
__attribute__((pure));
|
|
|
|
|
|
|
|
/*********************************************************************//**
|
|
|
|
Determine if a block has been flagged old.
|
|
|
|
@return TRUE if old */
|
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
buf_page_is_old(
|
|
|
|
/*============*/
|
|
|
|
const buf_page_t* bpage) /*!< in: control block */
|
|
|
|
__attribute__((pure));
|
|
|
|
/*********************************************************************//**
|
|
|
|
Flag a block old. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_set_old(
|
|
|
|
/*=============*/
|
|
|
|
buf_page_t* bpage, /*!< in/out: control block */
|
|
|
|
ibool old); /*!< in: old */
|
|
|
|
/*********************************************************************//**
|
Applying InnoDB Plugin 1.0.5 snapshot, part 6
From revision r5748 to r5783
Detailed revision comments:
r5748 | marko | 2009-09-03 06:05:44 -0500 (Thu, 03 Sep 2009) | 1 line
branches/zip: MLOG_MULTI_REC_END: Correct the comment.
r5751 | marko | 2009-09-03 09:36:15 -0500 (Thu, 03 Sep 2009) | 7 lines
branches/zip: row_merge(): Remove a bogus debug assertion
that was triggered when creating an index on an empty table.
row_merge_sort(): Add debug assertions and comments that justify
the loop termination condition.
The bogus assertion ut_ad(ihalf > 0) was reported by Michael.
r5752 | marko | 2009-09-03 09:55:51 -0500 (Thu, 03 Sep 2009) | 10 lines
branches/zip: recv_recover_page_func(): Write the log sequence number
to the compressed page, if there is one. Previously, the function only
wrote the LSN to the uncompressed page.
It is not clear why recv_recover_page_func() is updating FIL_PAGE_LSN
in the buffer pool. The log sequence number will be stamped on the
page when it is flushed to disk, in buf_flush_init_for_writing().
I noticed this inconsistency when analyzing Issue #313, but this patch
does not fix it. That is no surprise, since FIL_PAGE_LSN should only
matter on disk files, not in the buffer pool.
r5775 | calvin | 2009-09-07 16:15:05 -0500 (Mon, 07 Sep 2009) | 13 lines
branches/zip: Build InnoDB on Windows with UNIV_HOTBACKUP
The changes are non-functional changes for normal InnoDB,
but needed for building the Hot Backup on Windows (with
UNIV_HOTBACKUP defined).
- Define os_aio_use_native_aio for HB.
- Do not acquire seek mutexes for backup since HB is single threaded.
- Do not use srv_flush_log_at_trx_commit for HB build
rb://155
Approved by: Marko
r5777 | marko | 2009-09-08 10:50:25 -0500 (Tue, 08 Sep 2009) | 2 lines
branches/zip: Remove BUF_LRU_INITIAL_RATIO, which should have been removed
together with buf_LRU_get_recent_limit().
r5779 | marko | 2009-09-09 01:17:19 -0500 (Wed, 09 Sep 2009) | 2 lines
branches/zip: buf_page_peek_if_too_old(): Make the bitmasking work when
buf_pool->freed_page_clock is wider than 32 bits.
r5780 | marko | 2009-09-09 01:50:50 -0500 (Wed, 09 Sep 2009) | 1 line
branches/zip: ut_time_ms(): Return ulint, not uint.
r5782 | marko | 2009-09-09 02:00:59 -0500 (Wed, 09 Sep 2009) | 2 lines
branches/zip: buf_page_peek_if_too_old(): Silence a compiler warning
that was introduced in r5779 on 32-bit systems.
r5783 | marko | 2009-09-09 02:25:00 -0500 (Wed, 09 Sep 2009) | 1 line
branches/zip: buf_page_is_accessed(): Correct the function comment.
2009-10-08 18:22:21 +05:30
|
|
|
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 */
|
2009-05-27 15:15:59 +05:30
|
|
|
UNIV_INLINE
|
Applying InnoDB Plugin 1.0.5 snapshot, part 4
From revision r5703 to r5716
Detailed revision comments:
r5703 | marko | 2009-08-27 02:25:00 -0500 (Thu, 27 Aug 2009) | 41 lines
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.
r5704 | marko | 2009-08-27 03:31:17 -0500 (Thu, 27 Aug 2009) | 32 lines
branches/zip: Fix a critical bug in fast index creation that could
corrupt the created indexes.
row_merge(): Make "half" an in/out parameter. Determine the offset of
half the output file. Copy the last blocks record-by-record instead of
block-by-block, so that the records can be counted. Check that the
input and output have matching n_rec.
row_merge_sort(): Do not assume that two blocks of size N are merged
into a block of size 2*N. The output block can be shorter than the
input if the last page of each input block is almost empty. Use an
accurate termination condition, based on the "half" computed by
row_merge().
row_merge_read(), row_merge_write(), row_merge_blocks(): Add debug output.
merge_file_t, row_merge_file_create(): Add n_rec, the number of records
in the merge file.
row_merge_read_clustered_index(): Update n_rec.
row_merge_blocks(): Update and check n_rec.
row_merge_blocks_copy(): New function, for copying the last blocks in
row_merge(). Update and check n_rec.
This bug was discovered with a user-supplied test case that creates an
index where the initial temporary file is 249 one-megabyte blocks and
the merged files become smaller. In the test, possible merge record
sizes are 10, 18, and 26 bytes.
rb://150 approved by Sunny Bains. This addresses Issue #320.
r5705 | marko | 2009-08-27 06:56:24 -0500 (Thu, 27 Aug 2009) | 11 lines
branches/zip: dict_index_find_cols(): On column name lookup failure,
return DB_CORRUPTION (HA_ERR_CRASHED) instead of abnormally
terminating the server. Also, disable the previously added diagnostic
output to the error log, because mysql-test-run does not like extra
output in the error log. (Bug #44571)
dict_index_add_to_cache(): Handle errors from dict_index_find_cols().
mysql-test/innodb_bug44571.test: A test case for triggering the bug.
rb://135 approved by Sunny Bains.
r5706 | inaam | 2009-08-27 11:00:27 -0500 (Thu, 27 Aug 2009) | 20 lines
branches/zip rb://147
Done away with following two status variables:
innodb_buffer_pool_read_ahead_rnd
innodb_buffer_pool_read_ahead_seq
Introduced two new status variables:
innodb_buffer_pool_read_ahead = number of pages read as part of
readahead since server startup
innodb_buffer_pool_read_ahead_evicted = number of pages that are read
in as readahead but were evicted before ever being accessed since
server startup i.e.: a measure of how badly our readahead is
performing
SHOW INNODB STATUS will show two extra numbers in buffer pool section:
pages read ahead/sec and pages evicted without access/sec
Approved by: Marko
r5707 | inaam | 2009-08-27 11:20:35 -0500 (Thu, 27 Aug 2009) | 6 lines
branches/zip
Remove unused macros as we erased the random readahead code in r5703.
Also fixed some comments.
r5708 | inaam | 2009-08-27 17:43:32 -0500 (Thu, 27 Aug 2009) | 4 lines
branches/zip
Remove redundant TRUE : FALSE from the return statement
r5709 | inaam | 2009-08-28 01:22:46 -0500 (Fri, 28 Aug 2009) | 5 lines
branches/zip rb://152
Disable display of deprecated parameter innodb_file_io_threads in
'show variables'.
r5714 | marko | 2009-08-31 01:10:10 -0500 (Mon, 31 Aug 2009) | 5 lines
branches/zip: buf_chunk_not_freed(): Do not acquire block->mutex unless
block->page.state == BUF_BLOCK_FILE_PAGE. Check that block->page.state
makes sense.
Approved by Sunny Bains over the IM.
r5716 | vasil | 2009-08-31 02:47:49 -0500 (Mon, 31 Aug 2009) | 9 lines
branches/zip:
Fix Bug#46718 InnoDB plugin incompatible with gcc 4.1 (at least: on PPC): "Undefined symbol"
by implementing our own check in plug.in instead of using the result from
the check from MySQL because it is insufficient.
Approved by: Marko (rb://154)
2009-10-08 16:58:37 +05:30
|
|
|
unsigned
|
2009-05-27 15:15:59 +05:30
|
|
|
buf_page_is_accessed(
|
|
|
|
/*=================*/
|
|
|
|
const buf_page_t* bpage) /*!< in: control block */
|
Applying InnoDB Plugin 1.0.5 snapshot, part 4
From revision r5703 to r5716
Detailed revision comments:
r5703 | marko | 2009-08-27 02:25:00 -0500 (Thu, 27 Aug 2009) | 41 lines
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.
r5704 | marko | 2009-08-27 03:31:17 -0500 (Thu, 27 Aug 2009) | 32 lines
branches/zip: Fix a critical bug in fast index creation that could
corrupt the created indexes.
row_merge(): Make "half" an in/out parameter. Determine the offset of
half the output file. Copy the last blocks record-by-record instead of
block-by-block, so that the records can be counted. Check that the
input and output have matching n_rec.
row_merge_sort(): Do not assume that two blocks of size N are merged
into a block of size 2*N. The output block can be shorter than the
input if the last page of each input block is almost empty. Use an
accurate termination condition, based on the "half" computed by
row_merge().
row_merge_read(), row_merge_write(), row_merge_blocks(): Add debug output.
merge_file_t, row_merge_file_create(): Add n_rec, the number of records
in the merge file.
row_merge_read_clustered_index(): Update n_rec.
row_merge_blocks(): Update and check n_rec.
row_merge_blocks_copy(): New function, for copying the last blocks in
row_merge(). Update and check n_rec.
This bug was discovered with a user-supplied test case that creates an
index where the initial temporary file is 249 one-megabyte blocks and
the merged files become smaller. In the test, possible merge record
sizes are 10, 18, and 26 bytes.
rb://150 approved by Sunny Bains. This addresses Issue #320.
r5705 | marko | 2009-08-27 06:56:24 -0500 (Thu, 27 Aug 2009) | 11 lines
branches/zip: dict_index_find_cols(): On column name lookup failure,
return DB_CORRUPTION (HA_ERR_CRASHED) instead of abnormally
terminating the server. Also, disable the previously added diagnostic
output to the error log, because mysql-test-run does not like extra
output in the error log. (Bug #44571)
dict_index_add_to_cache(): Handle errors from dict_index_find_cols().
mysql-test/innodb_bug44571.test: A test case for triggering the bug.
rb://135 approved by Sunny Bains.
r5706 | inaam | 2009-08-27 11:00:27 -0500 (Thu, 27 Aug 2009) | 20 lines
branches/zip rb://147
Done away with following two status variables:
innodb_buffer_pool_read_ahead_rnd
innodb_buffer_pool_read_ahead_seq
Introduced two new status variables:
innodb_buffer_pool_read_ahead = number of pages read as part of
readahead since server startup
innodb_buffer_pool_read_ahead_evicted = number of pages that are read
in as readahead but were evicted before ever being accessed since
server startup i.e.: a measure of how badly our readahead is
performing
SHOW INNODB STATUS will show two extra numbers in buffer pool section:
pages read ahead/sec and pages evicted without access/sec
Approved by: Marko
r5707 | inaam | 2009-08-27 11:20:35 -0500 (Thu, 27 Aug 2009) | 6 lines
branches/zip
Remove unused macros as we erased the random readahead code in r5703.
Also fixed some comments.
r5708 | inaam | 2009-08-27 17:43:32 -0500 (Thu, 27 Aug 2009) | 4 lines
branches/zip
Remove redundant TRUE : FALSE from the return statement
r5709 | inaam | 2009-08-28 01:22:46 -0500 (Fri, 28 Aug 2009) | 5 lines
branches/zip rb://152
Disable display of deprecated parameter innodb_file_io_threads in
'show variables'.
r5714 | marko | 2009-08-31 01:10:10 -0500 (Mon, 31 Aug 2009) | 5 lines
branches/zip: buf_chunk_not_freed(): Do not acquire block->mutex unless
block->page.state == BUF_BLOCK_FILE_PAGE. Check that block->page.state
makes sense.
Approved by Sunny Bains over the IM.
r5716 | vasil | 2009-08-31 02:47:49 -0500 (Mon, 31 Aug 2009) | 9 lines
branches/zip:
Fix Bug#46718 InnoDB plugin incompatible with gcc 4.1 (at least: on PPC): "Undefined symbol"
by implementing our own check in plug.in instead of using the result from
the check from MySQL because it is insufficient.
Approved by: Marko (rb://154)
2009-10-08 16:58:37 +05:30
|
|
|
__attribute__((nonnull, pure));
|
2009-05-27 15:15:59 +05:30
|
|
|
/*********************************************************************//**
|
|
|
|
Flag a block accessed. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
buf_page_set_accessed(
|
|
|
|
/*==================*/
|
Applying InnoDB Plugin 1.0.5 snapshot, part 7
From revisions r5792 to r5864
Detailed revision comments:
r5792 | vasil | 2009-09-09 08:35:58 -0500 (Wed, 09 Sep 2009) | 32 lines
branches/zip:
Fix a bug in manipulating the variable innodb_old_blocks_pct:
for any value assigned it got that value -1, except for 75. When
assigned 75, it got 75.
mysql> set global innodb_old_blocks_pct=15;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'innodb_old_blocks_pct';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| innodb_old_blocks_pct | 14 |
+-----------------------+-------+
1 row in set (0.00 sec)
mysql> set global innodb_old_blocks_pct=75;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'innodb_old_blocks_pct';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| innodb_old_blocks_pct | 75 |
+-----------------------+-------+
After the fix it gets exactly what was assigned.
Approved by: Marko (via IM)
r5798 | calvin | 2009-09-09 10:28:10 -0500 (Wed, 09 Sep 2009) | 5 lines
branches/zip:
HA_ERR_TOO_MANY_CONCURRENT_TRXS is added in 5.1.38.
But the plugin should still work with previous versions
of MySQL.
r5804 | marko | 2009-09-10 00:29:31 -0500 (Thu, 10 Sep 2009) | 1 line
branches/zip: trx_cleanup_at_db_startup(): Fix a typo in comment.
r5822 | marko | 2009-09-10 05:10:20 -0500 (Thu, 10 Sep 2009) | 1 line
branches/zip: buf_page_release(): De-stutter the function comment.
r5825 | marko | 2009-09-10 05:47:09 -0500 (Thu, 10 Sep 2009) | 20 lines
branches/zip: Reduce mutex contention that was introduced when
addressing Bug #45015 (Issue #316), in r5703.
buf_page_set_accessed_make_young(): New auxiliary function, called by
buf_page_get_zip(), buf_page_get_gen(),
buf_page_optimistic_get_func(). Call ut_time_ms() outside of
buf_pool_mutex. Use cached access_time.
buf_page_set_accessed(): Add the parameter time_ms, so that
ut_time_ms() need not be called while holding buf_pool_mutex.
buf_page_optimistic_get_func(), buf_page_get_known_nowait(): Read
buf_page_t::access_time without holding buf_pool_mutex. This should be
OK, because the field is only used for heuristic purposes.
buf_page_peek_if_too_old(): If buf_pool->freed_page_clock == 0, return
FALSE, so that we will not waste time moving blocks in the LRU list in
the warm-up phase or when the workload fits in the buffer pool.
rb://156 approved by Sunny Bains
r5826 | marko | 2009-09-10 06:29:46 -0500 (Thu, 10 Sep 2009) | 12 lines
branches/zip: Roll back recovered dictionary transactions before
dropping incomplete indexes (Issue #337).
trx_rollback_or_clean_recovered(ibool all): New function, split from
trx_rollback_or_clean_all_recovered(). all==FALSE will only roll back
dictionary transactions.
recv_recovery_from_checkpoint_finish(): Call
trx_rollback_or_clean_recovered(FALSE) before
row_merge_drop_temp_indexes().
rb://158 approved by Sunny Bains
r5858 | vasil | 2009-09-11 12:46:47 -0500 (Fri, 11 Sep 2009) | 4 lines
branches/zip:
Fix the indentation of the closing bracket.
r5863 | vasil | 2009-09-12 02:07:08 -0500 (Sat, 12 Sep 2009) | 10 lines
branches/zip:
Check that pthread_t can indeed be passed to Solaris atomic functions, instead
of assuming that it can be passed if 0 can be assigned to it. It could be that:
* 0 can be assigned, but pthread_t cannot be passed and
* 0 cannot be assigned but pthread_t can be passed
Better to check what we are interested in, not something else and make
assumptions.
r5864 | vasil | 2009-09-12 02:22:55 -0500 (Sat, 12 Sep 2009) | 4 lines
branches/zip:
Include string.h which is needed for memset().
2009-10-08 18:35:59 +05:30
|
|
|
buf_page_t* bpage, /*!< in/out: control block */
|
|
|
|
ulint time_ms) /*!< in: ut_time_ms() */
|
Applying InnoDB Plugin 1.0.5 snapshot, part 4
From revision r5703 to r5716
Detailed revision comments:
r5703 | marko | 2009-08-27 02:25:00 -0500 (Thu, 27 Aug 2009) | 41 lines
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.
r5704 | marko | 2009-08-27 03:31:17 -0500 (Thu, 27 Aug 2009) | 32 lines
branches/zip: Fix a critical bug in fast index creation that could
corrupt the created indexes.
row_merge(): Make "half" an in/out parameter. Determine the offset of
half the output file. Copy the last blocks record-by-record instead of
block-by-block, so that the records can be counted. Check that the
input and output have matching n_rec.
row_merge_sort(): Do not assume that two blocks of size N are merged
into a block of size 2*N. The output block can be shorter than the
input if the last page of each input block is almost empty. Use an
accurate termination condition, based on the "half" computed by
row_merge().
row_merge_read(), row_merge_write(), row_merge_blocks(): Add debug output.
merge_file_t, row_merge_file_create(): Add n_rec, the number of records
in the merge file.
row_merge_read_clustered_index(): Update n_rec.
row_merge_blocks(): Update and check n_rec.
row_merge_blocks_copy(): New function, for copying the last blocks in
row_merge(). Update and check n_rec.
This bug was discovered with a user-supplied test case that creates an
index where the initial temporary file is 249 one-megabyte blocks and
the merged files become smaller. In the test, possible merge record
sizes are 10, 18, and 26 bytes.
rb://150 approved by Sunny Bains. This addresses Issue #320.
r5705 | marko | 2009-08-27 06:56:24 -0500 (Thu, 27 Aug 2009) | 11 lines
branches/zip: dict_index_find_cols(): On column name lookup failure,
return DB_CORRUPTION (HA_ERR_CRASHED) instead of abnormally
terminating the server. Also, disable the previously added diagnostic
output to the error log, because mysql-test-run does not like extra
output in the error log. (Bug #44571)
dict_index_add_to_cache(): Handle errors from dict_index_find_cols().
mysql-test/innodb_bug44571.test: A test case for triggering the bug.
rb://135 approved by Sunny Bains.
r5706 | inaam | 2009-08-27 11:00:27 -0500 (Thu, 27 Aug 2009) | 20 lines
branches/zip rb://147
Done away with following two status variables:
innodb_buffer_pool_read_ahead_rnd
innodb_buffer_pool_read_ahead_seq
Introduced two new status variables:
innodb_buffer_pool_read_ahead = number of pages read as part of
readahead since server startup
innodb_buffer_pool_read_ahead_evicted = number of pages that are read
in as readahead but were evicted before ever being accessed since
server startup i.e.: a measure of how badly our readahead is
performing
SHOW INNODB STATUS will show two extra numbers in buffer pool section:
pages read ahead/sec and pages evicted without access/sec
Approved by: Marko
r5707 | inaam | 2009-08-27 11:20:35 -0500 (Thu, 27 Aug 2009) | 6 lines
branches/zip
Remove unused macros as we erased the random readahead code in r5703.
Also fixed some comments.
r5708 | inaam | 2009-08-27 17:43:32 -0500 (Thu, 27 Aug 2009) | 4 lines
branches/zip
Remove redundant TRUE : FALSE from the return statement
r5709 | inaam | 2009-08-28 01:22:46 -0500 (Fri, 28 Aug 2009) | 5 lines
branches/zip rb://152
Disable display of deprecated parameter innodb_file_io_threads in
'show variables'.
r5714 | marko | 2009-08-31 01:10:10 -0500 (Mon, 31 Aug 2009) | 5 lines
branches/zip: buf_chunk_not_freed(): Do not acquire block->mutex unless
block->page.state == BUF_BLOCK_FILE_PAGE. Check that block->page.state
makes sense.
Approved by Sunny Bains over the IM.
r5716 | vasil | 2009-08-31 02:47:49 -0500 (Mon, 31 Aug 2009) | 9 lines
branches/zip:
Fix Bug#46718 InnoDB plugin incompatible with gcc 4.1 (at least: on PPC): "Undefined symbol"
by implementing our own check in plug.in instead of using the result from
the check from MySQL because it is insufficient.
Approved by: Marko (rb://154)
2009-10-08 16:58:37 +05:30
|
|
|
__attribute__((nonnull));
|
2009-05-27 15:15:59 +05:30
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the buf_block_t handle of a buffered file block if an uncompressed
|
|
|
|
page frame exists, or NULL.
|
|
|
|
@return control block, or NULL */
|
|
|
|
UNIV_INLINE
|
|
|
|
buf_block_t*
|
|
|
|
buf_page_get_block(
|
|
|
|
/*===============*/
|
|
|
|
buf_page_t* bpage) /*!< in: control block, or NULL */
|
|
|
|
__attribute__((pure));
|
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
#ifdef UNIV_DEBUG
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets a pointer to the memory frame of a block.
|
|
|
|
@return pointer to the frame */
|
|
|
|
UNIV_INLINE
|
|
|
|
buf_frame_t*
|
|
|
|
buf_block_get_frame(
|
|
|
|
/*================*/
|
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
|
|
|
__attribute__((pure));
|
|
|
|
#else /* UNIV_DEBUG */
|
|
|
|
# define buf_block_get_frame(block) (block)->frame
|
|
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the space id of a block.
|
|
|
|
@return space id */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_page_get_space(
|
|
|
|
/*===============*/
|
|
|
|
const buf_page_t* bpage) /*!< in: pointer to the control block */
|
|
|
|
__attribute__((pure));
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the space id of a block.
|
|
|
|
@return space id */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_block_get_space(
|
|
|
|
/*================*/
|
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
|
|
|
__attribute__((pure));
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the page number of a block.
|
|
|
|
@return page number */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_page_get_page_no(
|
|
|
|
/*=================*/
|
|
|
|
const buf_page_t* bpage) /*!< in: pointer to the control block */
|
|
|
|
__attribute__((pure));
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the page number of a block.
|
|
|
|
@return page number */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_block_get_page_no(
|
|
|
|
/*==================*/
|
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
|
|
|
__attribute__((pure));
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the compressed page size of a block.
|
|
|
|
@return compressed page size, or 0 */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_page_get_zip_size(
|
|
|
|
/*==================*/
|
|
|
|
const buf_page_t* bpage) /*!< in: pointer to the control block */
|
|
|
|
__attribute__((pure));
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the compressed page size of a block.
|
|
|
|
@return compressed page size, or 0 */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_block_get_zip_size(
|
|
|
|
/*===================*/
|
|
|
|
const buf_block_t* block) /*!< in: pointer to the control block */
|
|
|
|
__attribute__((pure));
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the compressed page descriptor corresponding to an uncompressed page
|
|
|
|
if applicable. */
|
|
|
|
#define buf_block_get_page_zip(block) \
|
|
|
|
(UNIV_LIKELY_NULL((block)->page.zip.data) ? &(block)->page.zip : NULL)
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
|
|
/*******************************************************************//**
|
|
|
|
Gets the block to whose frame the pointer is pointing to.
|
|
|
|
@return pointer to block, never NULL */
|
|
|
|
UNIV_INTERN
|
|
|
|
buf_block_t*
|
|
|
|
buf_block_align(
|
|
|
|
/*============*/
|
|
|
|
const byte* ptr); /*!< in: pointer to a frame */
|
|
|
|
/********************************************************************//**
|
|
|
|
Find out if a pointer belongs to a buf_block_t. It can be a pointer to
|
|
|
|
the buf_block_t itself or a member of it
|
|
|
|
@return TRUE if ptr belongs to a buf_block_t struct */
|
|
|
|
UNIV_INTERN
|
|
|
|
ibool
|
|
|
|
buf_pointer_is_block_field(
|
|
|
|
/*=======================*/
|
|
|
|
const void* ptr); /*!< in: pointer not
|
|
|
|
dereferenced */
|
2009-07-30 17:42:56 +05: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-05-27 15:15:59 +05:30
|
|
|
|
|
|
|
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the compressed page descriptor corresponding to an uncompressed page
|
|
|
|
if applicable.
|
|
|
|
@return compressed page descriptor, or NULL */
|
|
|
|
UNIV_INLINE
|
|
|
|
const page_zip_des_t*
|
|
|
|
buf_frame_get_page_zip(
|
|
|
|
/*===================*/
|
|
|
|
const byte* ptr); /*!< in: pointer to the page */
|
|
|
|
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
|
|
|
|
/********************************************************************//**
|
|
|
|
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
|
|
|
|
and the lock released later.
|
|
|
|
@return pointer to the block or NULL */
|
|
|
|
UNIV_INTERN
|
|
|
|
buf_page_t*
|
|
|
|
buf_page_init_for_read(
|
|
|
|
/*===================*/
|
|
|
|
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
|
|
|
|
version of the tablespace in case we have done
|
|
|
|
DISCARD + IMPORT */
|
|
|
|
ulint offset);/*!< in: page number */
|
|
|
|
/********************************************************************//**
|
|
|
|
Completes an asynchronous read or write request of a file page to or from
|
|
|
|
the buffer pool. */
|
|
|
|
UNIV_INTERN
|
|
|
|
void
|
|
|
|
buf_page_io_complete(
|
|
|
|
/*=================*/
|
|
|
|
buf_page_t* bpage); /*!< in: pointer to the block in question */
|
|
|
|
/********************************************************************//**
|
|
|
|
Calculates a folded value of a file page address to use in the page hash
|
|
|
|
table.
|
|
|
|
@return the folded value */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
buf_page_address_fold(
|
|
|
|
/*==================*/
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset) /*!< in: offset of the page within space */
|
|
|
|
__attribute__((const));
|
|
|
|
/******************************************************************//**
|
|
|
|
Returns the control block of a file page, NULL if not found.
|
|
|
|
@return block, NULL if not found */
|
|
|
|
UNIV_INLINE
|
|
|
|
buf_page_t*
|
|
|
|
buf_page_hash_get(
|
|
|
|
/*==============*/
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset);/*!< in: offset of the page within space */
|
|
|
|
/******************************************************************//**
|
|
|
|
Returns the control block of a file page, NULL if not found
|
|
|
|
or an uncompressed page frame does not exist.
|
|
|
|
@return block, NULL if not found */
|
|
|
|
UNIV_INLINE
|
|
|
|
buf_block_t*
|
|
|
|
buf_block_hash_get(
|
|
|
|
/*===============*/
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint offset);/*!< in: offset of the page within space */
|
|
|
|
/*********************************************************************//**
|
|
|
|
Gets the current length of the free list of buffer blocks.
|
|
|
|
@return length of the free list */
|
|
|
|
UNIV_INTERN
|
|
|
|
ulint
|
|
|
|
buf_get_free_list_len(void);
|
|
|
|
/*=======================*/
|
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
|
|
|
|
|
|
|
|
/** The common buffer control block structure
|
|
|
|
for compressed and uncompressed frames */
|
|
|
|
|
|
|
|
struct buf_page_struct{
|
2009-07-30 17:42:56 +05: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-27 15:15:59 +05:30
|
|
|
/* @{ */
|
|
|
|
|
|
|
|
unsigned space:32; /*!< tablespace id; also protected
|
|
|
|
by buf_pool_mutex. */
|
|
|
|
unsigned offset:32; /*!< page number; also protected
|
|
|
|
by buf_pool_mutex. */
|
|
|
|
|
|
|
|
unsigned state:3; /*!< state of the control block; also
|
|
|
|
protected by buf_pool_mutex.
|
|
|
|
State transitions from
|
|
|
|
BUF_BLOCK_READY_FOR_USE to
|
|
|
|
BUF_BLOCK_MEMORY need not be
|
|
|
|
protected by buf_page_get_mutex().
|
|
|
|
@see enum buf_page_state */
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
|
|
unsigned flush_type:2; /*!< if this block is currently being
|
|
|
|
flushed to disk, this tells the
|
|
|
|
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 */
|
Applying InnoDB Plugin 1.0.5 snapshot, part 4
From revision r5703 to r5716
Detailed revision comments:
r5703 | marko | 2009-08-27 02:25:00 -0500 (Thu, 27 Aug 2009) | 41 lines
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.
r5704 | marko | 2009-08-27 03:31:17 -0500 (Thu, 27 Aug 2009) | 32 lines
branches/zip: Fix a critical bug in fast index creation that could
corrupt the created indexes.
row_merge(): Make "half" an in/out parameter. Determine the offset of
half the output file. Copy the last blocks record-by-record instead of
block-by-block, so that the records can be counted. Check that the
input and output have matching n_rec.
row_merge_sort(): Do not assume that two blocks of size N are merged
into a block of size 2*N. The output block can be shorter than the
input if the last page of each input block is almost empty. Use an
accurate termination condition, based on the "half" computed by
row_merge().
row_merge_read(), row_merge_write(), row_merge_blocks(): Add debug output.
merge_file_t, row_merge_file_create(): Add n_rec, the number of records
in the merge file.
row_merge_read_clustered_index(): Update n_rec.
row_merge_blocks(): Update and check n_rec.
row_merge_blocks_copy(): New function, for copying the last blocks in
row_merge(). Update and check n_rec.
This bug was discovered with a user-supplied test case that creates an
index where the initial temporary file is 249 one-megabyte blocks and
the merged files become smaller. In the test, possible merge record
sizes are 10, 18, and 26 bytes.
rb://150 approved by Sunny Bains. This addresses Issue #320.
r5705 | marko | 2009-08-27 06:56:24 -0500 (Thu, 27 Aug 2009) | 11 lines
branches/zip: dict_index_find_cols(): On column name lookup failure,
return DB_CORRUPTION (HA_ERR_CRASHED) instead of abnormally
terminating the server. Also, disable the previously added diagnostic
output to the error log, because mysql-test-run does not like extra
output in the error log. (Bug #44571)
dict_index_add_to_cache(): Handle errors from dict_index_find_cols().
mysql-test/innodb_bug44571.test: A test case for triggering the bug.
rb://135 approved by Sunny Bains.
r5706 | inaam | 2009-08-27 11:00:27 -0500 (Thu, 27 Aug 2009) | 20 lines
branches/zip rb://147
Done away with following two status variables:
innodb_buffer_pool_read_ahead_rnd
innodb_buffer_pool_read_ahead_seq
Introduced two new status variables:
innodb_buffer_pool_read_ahead = number of pages read as part of
readahead since server startup
innodb_buffer_pool_read_ahead_evicted = number of pages that are read
in as readahead but were evicted before ever being accessed since
server startup i.e.: a measure of how badly our readahead is
performing
SHOW INNODB STATUS will show two extra numbers in buffer pool section:
pages read ahead/sec and pages evicted without access/sec
Approved by: Marko
r5707 | inaam | 2009-08-27 11:20:35 -0500 (Thu, 27 Aug 2009) | 6 lines
branches/zip
Remove unused macros as we erased the random readahead code in r5703.
Also fixed some comments.
r5708 | inaam | 2009-08-27 17:43:32 -0500 (Thu, 27 Aug 2009) | 4 lines
branches/zip
Remove redundant TRUE : FALSE from the return statement
r5709 | inaam | 2009-08-28 01:22:46 -0500 (Fri, 28 Aug 2009) | 5 lines
branches/zip rb://152
Disable display of deprecated parameter innodb_file_io_threads in
'show variables'.
r5714 | marko | 2009-08-31 01:10:10 -0500 (Mon, 31 Aug 2009) | 5 lines
branches/zip: buf_chunk_not_freed(): Do not acquire block->mutex unless
block->page.state == BUF_BLOCK_FILE_PAGE. Check that block->page.state
makes sense.
Approved by Sunny Bains over the IM.
r5716 | vasil | 2009-08-31 02:47:49 -0500 (Mon, 31 Aug 2009) | 9 lines
branches/zip:
Fix Bug#46718 InnoDB plugin incompatible with gcc 4.1 (at least: on PPC): "Undefined symbol"
by implementing our own check in plug.in instead of using the result from
the check from MySQL because it is insufficient.
Approved by: Marko (rb://154)
2009-10-08 16:58:37 +05:30
|
|
|
unsigned buf_fix_count:25;/*!< count of how manyfold this block
|
2009-05-27 15:15:59 +05:30
|
|
|
is currently bufferfixed */
|
|
|
|
/* @} */
|
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
page_zip_des_t zip; /*!< compressed page; zip.data
|
|
|
|
(but not the data it points to) is
|
|
|
|
also protected by buf_pool_mutex */
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
|
|
buf_page_t* hash; /*!< node used in chaining to
|
|
|
|
buf_pool->page_hash or
|
|
|
|
buf_pool->zip_hash */
|
|
|
|
#ifdef UNIV_DEBUG
|
|
|
|
ibool in_page_hash; /*!< TRUE if in buf_pool->page_hash */
|
|
|
|
ibool in_zip_hash; /*!< TRUE if in buf_pool->zip_hash */
|
|
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
|
2009-07-30 17:42:56 +05:00
|
|
|
/** @name Page flushing fields
|
|
|
|
All these are protected by buf_pool_mutex. */
|
2009-05-27 15:15:59 +05:30
|
|
|
/* @{ */
|
|
|
|
|
|
|
|
UT_LIST_NODE_T(buf_page_t) list;
|
|
|
|
/*!< based on state, this is a
|
|
|
|
list node, protected only by
|
|
|
|
buf_pool_mutex, in one of the
|
|
|
|
following lists in buf_pool:
|
|
|
|
|
2009-07-30 17:42:56 +05: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-10-08 16:08:57 +05:30
|
|
|
- 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. */
|
|
|
|
|
2009-05-27 15:15:59 +05:30
|
|
|
#ifdef UNIV_DEBUG
|
|
|
|
ibool in_flush_list; /*!< TRUE if in buf_pool->flush_list;
|
|
|
|
when buf_pool_mutex is free, the
|
|
|
|
following should hold: in_flush_list
|
|
|
|
== (state == BUF_BLOCK_FILE_PAGE
|
|
|
|
|| state == BUF_BLOCK_ZIP_DIRTY) */
|
|
|
|
ibool in_free_list; /*!< TRUE if in buf_pool->free; when
|
|
|
|
buf_pool_mutex is free, the following
|
|
|
|
should hold: in_free_list
|
|
|
|
== (state == BUF_BLOCK_NOT_USED) */
|
|
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
ib_uint64_t newest_modification;
|
|
|
|
/*!< log sequence number of
|
|
|
|
the youngest modification to
|
|
|
|
this block, zero if not
|
|
|
|
modified */
|
|
|
|
ib_uint64_t oldest_modification;
|
|
|
|
/*!< 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-07-30 17:42:56 +05: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-27 15:15:59 +05:30
|
|
|
/* @{ */
|
|
|
|
|
|
|
|
UT_LIST_NODE_T(buf_page_t) LRU;
|
|
|
|
/*!< node of the LRU list */
|
|
|
|
#ifdef UNIV_DEBUG
|
|
|
|
ibool in_LRU_list; /*!< TRUE if the page is in
|
|
|
|
the LRU list; used in
|
|
|
|
debugging */
|
|
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
unsigned old:1; /*!< TRUE if the block is in the old
|
2009-11-03 14:26:07 +04:00
|
|
|
blocks in buf_pool->LRU_old */
|
Applying InnoDB Plugin 1.0.5 snapshot, part 4
From revision r5703 to r5716
Detailed revision comments:
r5703 | marko | 2009-08-27 02:25:00 -0500 (Thu, 27 Aug 2009) | 41 lines
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.
r5704 | marko | 2009-08-27 03:31:17 -0500 (Thu, 27 Aug 2009) | 32 lines
branches/zip: Fix a critical bug in fast index creation that could
corrupt the created indexes.
row_merge(): Make "half" an in/out parameter. Determine the offset of
half the output file. Copy the last blocks record-by-record instead of
block-by-block, so that the records can be counted. Check that the
input and output have matching n_rec.
row_merge_sort(): Do not assume that two blocks of size N are merged
into a block of size 2*N. The output block can be shorter than the
input if the last page of each input block is almost empty. Use an
accurate termination condition, based on the "half" computed by
row_merge().
row_merge_read(), row_merge_write(), row_merge_blocks(): Add debug output.
merge_file_t, row_merge_file_create(): Add n_rec, the number of records
in the merge file.
row_merge_read_clustered_index(): Update n_rec.
row_merge_blocks(): Update and check n_rec.
row_merge_blocks_copy(): New function, for copying the last blocks in
row_merge(). Update and check n_rec.
This bug was discovered with a user-supplied test case that creates an
index where the initial temporary file is 249 one-megabyte blocks and
the merged files become smaller. In the test, possible merge record
sizes are 10, 18, and 26 bytes.
rb://150 approved by Sunny Bains. This addresses Issue #320.
r5705 | marko | 2009-08-27 06:56:24 -0500 (Thu, 27 Aug 2009) | 11 lines
branches/zip: dict_index_find_cols(): On column name lookup failure,
return DB_CORRUPTION (HA_ERR_CRASHED) instead of abnormally
terminating the server. Also, disable the previously added diagnostic
output to the error log, because mysql-test-run does not like extra
output in the error log. (Bug #44571)
dict_index_add_to_cache(): Handle errors from dict_index_find_cols().
mysql-test/innodb_bug44571.test: A test case for triggering the bug.
rb://135 approved by Sunny Bains.
r5706 | inaam | 2009-08-27 11:00:27 -0500 (Thu, 27 Aug 2009) | 20 lines
branches/zip rb://147
Done away with following two status variables:
innodb_buffer_pool_read_ahead_rnd
innodb_buffer_pool_read_ahead_seq
Introduced two new status variables:
innodb_buffer_pool_read_ahead = number of pages read as part of
readahead since server startup
innodb_buffer_pool_read_ahead_evicted = number of pages that are read
in as readahead but were evicted before ever being accessed since
server startup i.e.: a measure of how badly our readahead is
performing
SHOW INNODB STATUS will show two extra numbers in buffer pool section:
pages read ahead/sec and pages evicted without access/sec
Approved by: Marko
r5707 | inaam | 2009-08-27 11:20:35 -0500 (Thu, 27 Aug 2009) | 6 lines
branches/zip
Remove unused macros as we erased the random readahead code in r5703.
Also fixed some comments.
r5708 | inaam | 2009-08-27 17:43:32 -0500 (Thu, 27 Aug 2009) | 4 lines
branches/zip
Remove redundant TRUE : FALSE from the return statement
r5709 | inaam | 2009-08-28 01:22:46 -0500 (Fri, 28 Aug 2009) | 5 lines
branches/zip rb://152
Disable display of deprecated parameter innodb_file_io_threads in
'show variables'.
r5714 | marko | 2009-08-31 01:10:10 -0500 (Mon, 31 Aug 2009) | 5 lines
branches/zip: buf_chunk_not_freed(): Do not acquire block->mutex unless
block->page.state == BUF_BLOCK_FILE_PAGE. Check that block->page.state
makes sense.
Approved by Sunny Bains over the IM.
r5716 | vasil | 2009-08-31 02:47:49 -0500 (Mon, 31 Aug 2009) | 9 lines
branches/zip:
Fix Bug#46718 InnoDB plugin incompatible with gcc 4.1 (at least: on PPC): "Undefined symbol"
by implementing our own check in plug.in instead of using the result from
the check from MySQL because it is insufficient.
Approved by: Marko (rb://154)
2009-10-08 16:58:37 +05:30
|
|
|
unsigned freed_page_clock:31;/*!< the value of
|
2009-05-27 15:15:59 +05:30
|
|
|
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 */
|
Applying InnoDB Plugin 1.0.5 snapshot, part 4
From revision r5703 to r5716
Detailed revision comments:
r5703 | marko | 2009-08-27 02:25:00 -0500 (Thu, 27 Aug 2009) | 41 lines
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.
r5704 | marko | 2009-08-27 03:31:17 -0500 (Thu, 27 Aug 2009) | 32 lines
branches/zip: Fix a critical bug in fast index creation that could
corrupt the created indexes.
row_merge(): Make "half" an in/out parameter. Determine the offset of
half the output file. Copy the last blocks record-by-record instead of
block-by-block, so that the records can be counted. Check that the
input and output have matching n_rec.
row_merge_sort(): Do not assume that two blocks of size N are merged
into a block of size 2*N. The output block can be shorter than the
input if the last page of each input block is almost empty. Use an
accurate termination condition, based on the "half" computed by
row_merge().
row_merge_read(), row_merge_write(), row_merge_blocks(): Add debug output.
merge_file_t, row_merge_file_create(): Add n_rec, the number of records
in the merge file.
row_merge_read_clustered_index(): Update n_rec.
row_merge_blocks(): Update and check n_rec.
row_merge_blocks_copy(): New function, for copying the last blocks in
row_merge(). Update and check n_rec.
This bug was discovered with a user-supplied test case that creates an
index where the initial temporary file is 249 one-megabyte blocks and
the merged files become smaller. In the test, possible merge record
sizes are 10, 18, and 26 bytes.
rb://150 approved by Sunny Bains. This addresses Issue #320.
r5705 | marko | 2009-08-27 06:56:24 -0500 (Thu, 27 Aug 2009) | 11 lines
branches/zip: dict_index_find_cols(): On column name lookup failure,
return DB_CORRUPTION (HA_ERR_CRASHED) instead of abnormally
terminating the server. Also, disable the previously added diagnostic
output to the error log, because mysql-test-run does not like extra
output in the error log. (Bug #44571)
dict_index_add_to_cache(): Handle errors from dict_index_find_cols().
mysql-test/innodb_bug44571.test: A test case for triggering the bug.
rb://135 approved by Sunny Bains.
r5706 | inaam | 2009-08-27 11:00:27 -0500 (Thu, 27 Aug 2009) | 20 lines
branches/zip rb://147
Done away with following two status variables:
innodb_buffer_pool_read_ahead_rnd
innodb_buffer_pool_read_ahead_seq
Introduced two new status variables:
innodb_buffer_pool_read_ahead = number of pages read as part of
readahead since server startup
innodb_buffer_pool_read_ahead_evicted = number of pages that are read
in as readahead but were evicted before ever being accessed since
server startup i.e.: a measure of how badly our readahead is
performing
SHOW INNODB STATUS will show two extra numbers in buffer pool section:
pages read ahead/sec and pages evicted without access/sec
Approved by: Marko
r5707 | inaam | 2009-08-27 11:20:35 -0500 (Thu, 27 Aug 2009) | 6 lines
branches/zip
Remove unused macros as we erased the random readahead code in r5703.
Also fixed some comments.
r5708 | inaam | 2009-08-27 17:43:32 -0500 (Thu, 27 Aug 2009) | 4 lines
branches/zip
Remove redundant TRUE : FALSE from the return statement
r5709 | inaam | 2009-08-28 01:22:46 -0500 (Fri, 28 Aug 2009) | 5 lines
branches/zip rb://152
Disable display of deprecated parameter innodb_file_io_threads in
'show variables'.
r5714 | marko | 2009-08-31 01:10:10 -0500 (Mon, 31 Aug 2009) | 5 lines
branches/zip: buf_chunk_not_freed(): Do not acquire block->mutex unless
block->page.state == BUF_BLOCK_FILE_PAGE. Check that block->page.state
makes sense.
Approved by Sunny Bains over the IM.
r5716 | vasil | 2009-08-31 02:47:49 -0500 (Mon, 31 Aug 2009) | 9 lines
branches/zip:
Fix Bug#46718 InnoDB plugin incompatible with gcc 4.1 (at least: on PPC): "Undefined symbol"
by implementing our own check in plug.in instead of using the result from
the check from MySQL because it is insufficient.
Approved by: Marko (rb://154)
2009-10-08 16:58:37 +05:30
|
|
|
unsigned access_time:32; /*!< time of first access, or
|
|
|
|
0 if the block was never accessed
|
|
|
|
in the buffer pool */
|
2009-05-27 15:15:59 +05:30
|
|
|
/* @} */
|
2009-07-30 17:42:56 +05:00
|
|
|
# ifdef UNIV_DEBUG_FILE_ACCESSES
|
2009-05-27 15:15:59 +05:30
|
|
|
ibool file_page_was_freed;
|
|
|
|
/*!< this is set to TRUE when fsp
|
|
|
|
frees a page in buffer pool */
|
2009-07-30 17:42:56 +05:00
|
|
|
# endif /* UNIV_DEBUG_FILE_ACCESSES */
|
2009-05-27 15:15:59 +05:30
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
};
|
|
|
|
|
|
|
|
/** The buffer control block structure */
|
|
|
|
|
|
|
|
struct buf_block_struct{
|
|
|
|
|
2009-07-30 17:42:56 +05:00
|
|
|
/** @name General fields */
|
2009-05-27 15:15:59 +05:30
|
|
|
/* @{ */
|
|
|
|
|
|
|
|
buf_page_t page; /*!< page information; this must
|
|
|
|
be the first field, so that
|
|
|
|
buf_pool->page_hash can point
|
|
|
|
to buf_page_t or buf_block_t */
|
|
|
|
byte* frame; /*!< pointer to buffer frame which
|
|
|
|
is of size UNIV_PAGE_SIZE, and
|
|
|
|
aligned to an address divisible by
|
|
|
|
UNIV_PAGE_SIZE */
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
|
|
UT_LIST_NODE_T(buf_block_t) unzip_LRU;
|
|
|
|
/*!< node of the decompressed LRU list;
|
|
|
|
a block is in the unzip_LRU list
|
|
|
|
if page.state == BUF_BLOCK_FILE_PAGE
|
|
|
|
and page.zip.data != NULL */
|
|
|
|
#ifdef UNIV_DEBUG
|
|
|
|
ibool in_unzip_LRU_list;/*!< TRUE if the page is in the
|
|
|
|
decompressed LRU list;
|
|
|
|
used in debugging */
|
|
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
mutex_t mutex; /*!< mutex protecting this block:
|
|
|
|
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 */
|
|
|
|
rw_lock_t lock; /*!< read-write lock of the buffer
|
|
|
|
frame */
|
|
|
|
unsigned lock_hash_val:32;/*!< hashed value of the page address
|
2010-04-01 16:21:00 +04:00
|
|
|
in the record lock hash table;
|
|
|
|
protected by buf_block_t::lock
|
|
|
|
(or buf_block_t::mutex, buf_pool_mutex
|
|
|
|
in buf_page_get_gen(),
|
|
|
|
buf_page_init_for_read()
|
|
|
|
and buf_page_create()) */
|
|
|
|
ibool check_index_page_at_flush;
|
2009-05-27 15:15:59 +05:30
|
|
|
/*!< TRUE if we know that this is
|
|
|
|
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
|
2010-04-01 16:21:00 +04:00
|
|
|
we do not keep track of all pages;
|
|
|
|
NOT protected by any mutex */
|
2009-05-27 15:15:59 +05:30
|
|
|
/* @} */
|
2009-07-30 17:42:56 +05:00
|
|
|
/** @name Optimistic search field */
|
2009-05-27 15:15:59 +05:30
|
|
|
/* @{ */
|
|
|
|
|
|
|
|
ib_uint64_t modify_clock; /*!< this clock is incremented every
|
|
|
|
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-07-30 17:42:56 +05:00
|
|
|
/** @name Hash search fields (unprotected)
|
|
|
|
NOTE that these fields are NOT protected by any semaphore! */
|
2009-05-27 15:15:59 +05:30
|
|
|
/* @{ */
|
|
|
|
|
|
|
|
ulint n_hash_helps; /*!< counter which controls building
|
|
|
|
of a new hash index for the page */
|
|
|
|
ulint n_fields; /*!< recommended prefix length for hash
|
|
|
|
search: number of full fields */
|
|
|
|
ulint n_bytes; /*!< recommended prefix: number of bytes
|
|
|
|
in an incomplete field */
|
|
|
|
ibool left_side; /*!< TRUE or FALSE, depending on
|
|
|
|
whether the leftmost record of several
|
|
|
|
records with the same prefix should be
|
|
|
|
indexed in the hash index */
|
|
|
|
/* @} */
|
|
|
|
|
2009-07-30 17:42:56 +05:00
|
|
|
/** @name Hash search fields
|
2009-05-27 15:15:59 +05:30
|
|
|
These 6 fields may only be modified when we have
|
|
|
|
an x-latch on btr_search_latch AND
|
2009-07-30 17:42:56 +05: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.
|
2009-05-27 15:15:59 +05:30
|
|
|
|
|
|
|
An exception to this is when we init or create a page
|
|
|
|
in the buffer pool in buf0buf.c. */
|
|
|
|
|
|
|
|
/* @{ */
|
|
|
|
|
|
|
|
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
|
|
|
|
ulint n_pointers; /*!< used in debugging: the number of
|
|
|
|
pointers in the adaptive hash index
|
|
|
|
pointing to this frame */
|
|
|
|
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
|
|
|
|
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:
|
|
|
|
number of full fields */
|
|
|
|
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
|
|
|
|
hash index has been created. */
|
|
|
|
/* @} */
|
2009-07-30 17:42:56 +05:00
|
|
|
# ifdef UNIV_SYNC_DEBUG
|
|
|
|
/** @name Debug fields */
|
2009-05-27 15:15:59 +05:30
|
|
|
/* @{ */
|
|
|
|
rw_lock_t debug_latch; /*!< in the debug version, each thread
|
|
|
|
which bufferfixes the block acquires
|
|
|
|
an s-latch here; so we can use the
|
|
|
|
debug utilities in sync0rw */
|
|
|
|
/* @} */
|
2009-07-30 17:42:56 +05:00
|
|
|
# endif
|
2009-05-27 15:15:59 +05:30
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Check if a buf_block_t object is in a valid state
|
|
|
|
@param block buffer block
|
|
|
|
@return TRUE if valid */
|
|
|
|
#define buf_block_state_valid(block) \
|
|
|
|
(buf_block_get_state(block) >= BUF_BLOCK_NOT_USED \
|
|
|
|
&& (buf_block_get_state(block) <= BUF_BLOCK_REMOVE_HASH))
|
|
|
|
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
|
|
/**********************************************************************//**
|
|
|
|
Compute the hash fold value for blocks in buf_pool->zip_hash. */
|
|
|
|
/* @{ */
|
|
|
|
#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-07-30 17:42:56 +05:00
|
|
|
/* @} */
|
2009-05-27 15:15:59 +05:30
|
|
|
|
Applying InnoDB Plugin 1.0.5 snapshot, part 4
From revision r5703 to r5716
Detailed revision comments:
r5703 | marko | 2009-08-27 02:25:00 -0500 (Thu, 27 Aug 2009) | 41 lines
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.
r5704 | marko | 2009-08-27 03:31:17 -0500 (Thu, 27 Aug 2009) | 32 lines
branches/zip: Fix a critical bug in fast index creation that could
corrupt the created indexes.
row_merge(): Make "half" an in/out parameter. Determine the offset of
half the output file. Copy the last blocks record-by-record instead of
block-by-block, so that the records can be counted. Check that the
input and output have matching n_rec.
row_merge_sort(): Do not assume that two blocks of size N are merged
into a block of size 2*N. The output block can be shorter than the
input if the last page of each input block is almost empty. Use an
accurate termination condition, based on the "half" computed by
row_merge().
row_merge_read(), row_merge_write(), row_merge_blocks(): Add debug output.
merge_file_t, row_merge_file_create(): Add n_rec, the number of records
in the merge file.
row_merge_read_clustered_index(): Update n_rec.
row_merge_blocks(): Update and check n_rec.
row_merge_blocks_copy(): New function, for copying the last blocks in
row_merge(). Update and check n_rec.
This bug was discovered with a user-supplied test case that creates an
index where the initial temporary file is 249 one-megabyte blocks and
the merged files become smaller. In the test, possible merge record
sizes are 10, 18, and 26 bytes.
rb://150 approved by Sunny Bains. This addresses Issue #320.
r5705 | marko | 2009-08-27 06:56:24 -0500 (Thu, 27 Aug 2009) | 11 lines
branches/zip: dict_index_find_cols(): On column name lookup failure,
return DB_CORRUPTION (HA_ERR_CRASHED) instead of abnormally
terminating the server. Also, disable the previously added diagnostic
output to the error log, because mysql-test-run does not like extra
output in the error log. (Bug #44571)
dict_index_add_to_cache(): Handle errors from dict_index_find_cols().
mysql-test/innodb_bug44571.test: A test case for triggering the bug.
rb://135 approved by Sunny Bains.
r5706 | inaam | 2009-08-27 11:00:27 -0500 (Thu, 27 Aug 2009) | 20 lines
branches/zip rb://147
Done away with following two status variables:
innodb_buffer_pool_read_ahead_rnd
innodb_buffer_pool_read_ahead_seq
Introduced two new status variables:
innodb_buffer_pool_read_ahead = number of pages read as part of
readahead since server startup
innodb_buffer_pool_read_ahead_evicted = number of pages that are read
in as readahead but were evicted before ever being accessed since
server startup i.e.: a measure of how badly our readahead is
performing
SHOW INNODB STATUS will show two extra numbers in buffer pool section:
pages read ahead/sec and pages evicted without access/sec
Approved by: Marko
r5707 | inaam | 2009-08-27 11:20:35 -0500 (Thu, 27 Aug 2009) | 6 lines
branches/zip
Remove unused macros as we erased the random readahead code in r5703.
Also fixed some comments.
r5708 | inaam | 2009-08-27 17:43:32 -0500 (Thu, 27 Aug 2009) | 4 lines
branches/zip
Remove redundant TRUE : FALSE from the return statement
r5709 | inaam | 2009-08-28 01:22:46 -0500 (Fri, 28 Aug 2009) | 5 lines
branches/zip rb://152
Disable display of deprecated parameter innodb_file_io_threads in
'show variables'.
r5714 | marko | 2009-08-31 01:10:10 -0500 (Mon, 31 Aug 2009) | 5 lines
branches/zip: buf_chunk_not_freed(): Do not acquire block->mutex unless
block->page.state == BUF_BLOCK_FILE_PAGE. Check that block->page.state
makes sense.
Approved by Sunny Bains over the IM.
r5716 | vasil | 2009-08-31 02:47:49 -0500 (Mon, 31 Aug 2009) | 9 lines
branches/zip:
Fix Bug#46718 InnoDB plugin incompatible with gcc 4.1 (at least: on PPC): "Undefined symbol"
by implementing our own check in plug.in instead of using the result from
the check from MySQL because it is insufficient.
Approved by: Marko (rb://154)
2009-10-08 16:58:37 +05:30
|
|
|
/** @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-27 15:15:59 +05:30
|
|
|
/** @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! */
|
|
|
|
|
|
|
|
struct buf_pool_struct{
|
|
|
|
|
2009-07-30 17:42:56 +05:00
|
|
|
/** @name General fields */
|
2009-05-27 15:15:59 +05:30
|
|
|
/* @{ */
|
|
|
|
|
|
|
|
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
|
|
|
|
buf_block_t file pages,
|
|
|
|
buf_page_in_file() == TRUE,
|
|
|
|
indexed by (space_id, offset) */
|
|
|
|
hash_table_t* zip_hash; /*!< hash table of buf_block_t blocks
|
|
|
|
whose frames are allocated to the
|
|
|
|
zip buddy system,
|
|
|
|
indexed by block->frame */
|
|
|
|
ulint n_pend_reads; /*!< number of pending read operations */
|
|
|
|
ulint n_pend_unzip; /*!< number of pending decompressions */
|
|
|
|
|
Applying InnoDB Plugin 1.0.5 snapshot, part 4
From revision r5703 to r5716
Detailed revision comments:
r5703 | marko | 2009-08-27 02:25:00 -0500 (Thu, 27 Aug 2009) | 41 lines
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.
r5704 | marko | 2009-08-27 03:31:17 -0500 (Thu, 27 Aug 2009) | 32 lines
branches/zip: Fix a critical bug in fast index creation that could
corrupt the created indexes.
row_merge(): Make "half" an in/out parameter. Determine the offset of
half the output file. Copy the last blocks record-by-record instead of
block-by-block, so that the records can be counted. Check that the
input and output have matching n_rec.
row_merge_sort(): Do not assume that two blocks of size N are merged
into a block of size 2*N. The output block can be shorter than the
input if the last page of each input block is almost empty. Use an
accurate termination condition, based on the "half" computed by
row_merge().
row_merge_read(), row_merge_write(), row_merge_blocks(): Add debug output.
merge_file_t, row_merge_file_create(): Add n_rec, the number of records
in the merge file.
row_merge_read_clustered_index(): Update n_rec.
row_merge_blocks(): Update and check n_rec.
row_merge_blocks_copy(): New function, for copying the last blocks in
row_merge(). Update and check n_rec.
This bug was discovered with a user-supplied test case that creates an
index where the initial temporary file is 249 one-megabyte blocks and
the merged files become smaller. In the test, possible merge record
sizes are 10, 18, and 26 bytes.
rb://150 approved by Sunny Bains. This addresses Issue #320.
r5705 | marko | 2009-08-27 06:56:24 -0500 (Thu, 27 Aug 2009) | 11 lines
branches/zip: dict_index_find_cols(): On column name lookup failure,
return DB_CORRUPTION (HA_ERR_CRASHED) instead of abnormally
terminating the server. Also, disable the previously added diagnostic
output to the error log, because mysql-test-run does not like extra
output in the error log. (Bug #44571)
dict_index_add_to_cache(): Handle errors from dict_index_find_cols().
mysql-test/innodb_bug44571.test: A test case for triggering the bug.
rb://135 approved by Sunny Bains.
r5706 | inaam | 2009-08-27 11:00:27 -0500 (Thu, 27 Aug 2009) | 20 lines
branches/zip rb://147
Done away with following two status variables:
innodb_buffer_pool_read_ahead_rnd
innodb_buffer_pool_read_ahead_seq
Introduced two new status variables:
innodb_buffer_pool_read_ahead = number of pages read as part of
readahead since server startup
innodb_buffer_pool_read_ahead_evicted = number of pages that are read
in as readahead but were evicted before ever being accessed since
server startup i.e.: a measure of how badly our readahead is
performing
SHOW INNODB STATUS will show two extra numbers in buffer pool section:
pages read ahead/sec and pages evicted without access/sec
Approved by: Marko
r5707 | inaam | 2009-08-27 11:20:35 -0500 (Thu, 27 Aug 2009) | 6 lines
branches/zip
Remove unused macros as we erased the random readahead code in r5703.
Also fixed some comments.
r5708 | inaam | 2009-08-27 17:43:32 -0500 (Thu, 27 Aug 2009) | 4 lines
branches/zip
Remove redundant TRUE : FALSE from the return statement
r5709 | inaam | 2009-08-28 01:22:46 -0500 (Fri, 28 Aug 2009) | 5 lines
branches/zip rb://152
Disable display of deprecated parameter innodb_file_io_threads in
'show variables'.
r5714 | marko | 2009-08-31 01:10:10 -0500 (Mon, 31 Aug 2009) | 5 lines
branches/zip: buf_chunk_not_freed(): Do not acquire block->mutex unless
block->page.state == BUF_BLOCK_FILE_PAGE. Check that block->page.state
makes sense.
Approved by Sunny Bains over the IM.
r5716 | vasil | 2009-08-31 02:47:49 -0500 (Mon, 31 Aug 2009) | 9 lines
branches/zip:
Fix Bug#46718 InnoDB plugin incompatible with gcc 4.1 (at least: on PPC): "Undefined symbol"
by implementing our own check in plug.in instead of using the result from
the check from MySQL because it is insufficient.
Approved by: Marko (rb://154)
2009-10-08 16:58:37 +05:30
|
|
|
time_t last_printout_time;
|
|
|
|
/*!< when buf_print_io was last time
|
2009-05-27 15:15:59 +05:30
|
|
|
called */
|
Applying InnoDB Plugin 1.0.5 snapshot, part 4
From revision r5703 to r5716
Detailed revision comments:
r5703 | marko | 2009-08-27 02:25:00 -0500 (Thu, 27 Aug 2009) | 41 lines
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.
r5704 | marko | 2009-08-27 03:31:17 -0500 (Thu, 27 Aug 2009) | 32 lines
branches/zip: Fix a critical bug in fast index creation that could
corrupt the created indexes.
row_merge(): Make "half" an in/out parameter. Determine the offset of
half the output file. Copy the last blocks record-by-record instead of
block-by-block, so that the records can be counted. Check that the
input and output have matching n_rec.
row_merge_sort(): Do not assume that two blocks of size N are merged
into a block of size 2*N. The output block can be shorter than the
input if the last page of each input block is almost empty. Use an
accurate termination condition, based on the "half" computed by
row_merge().
row_merge_read(), row_merge_write(), row_merge_blocks(): Add debug output.
merge_file_t, row_merge_file_create(): Add n_rec, the number of records
in the merge file.
row_merge_read_clustered_index(): Update n_rec.
row_merge_blocks(): Update and check n_rec.
row_merge_blocks_copy(): New function, for copying the last blocks in
row_merge(). Update and check n_rec.
This bug was discovered with a user-supplied test case that creates an
index where the initial temporary file is 249 one-megabyte blocks and
the merged files become smaller. In the test, possible merge record
sizes are 10, 18, and 26 bytes.
rb://150 approved by Sunny Bains. This addresses Issue #320.
r5705 | marko | 2009-08-27 06:56:24 -0500 (Thu, 27 Aug 2009) | 11 lines
branches/zip: dict_index_find_cols(): On column name lookup failure,
return DB_CORRUPTION (HA_ERR_CRASHED) instead of abnormally
terminating the server. Also, disable the previously added diagnostic
output to the error log, because mysql-test-run does not like extra
output in the error log. (Bug #44571)
dict_index_add_to_cache(): Handle errors from dict_index_find_cols().
mysql-test/innodb_bug44571.test: A test case for triggering the bug.
rb://135 approved by Sunny Bains.
r5706 | inaam | 2009-08-27 11:00:27 -0500 (Thu, 27 Aug 2009) | 20 lines
branches/zip rb://147
Done away with following two status variables:
innodb_buffer_pool_read_ahead_rnd
innodb_buffer_pool_read_ahead_seq
Introduced two new status variables:
innodb_buffer_pool_read_ahead = number of pages read as part of
readahead since server startup
innodb_buffer_pool_read_ahead_evicted = number of pages that are read
in as readahead but were evicted before ever being accessed since
server startup i.e.: a measure of how badly our readahead is
performing
SHOW INNODB STATUS will show two extra numbers in buffer pool section:
pages read ahead/sec and pages evicted without access/sec
Approved by: Marko
r5707 | inaam | 2009-08-27 11:20:35 -0500 (Thu, 27 Aug 2009) | 6 lines
branches/zip
Remove unused macros as we erased the random readahead code in r5703.
Also fixed some comments.
r5708 | inaam | 2009-08-27 17:43:32 -0500 (Thu, 27 Aug 2009) | 4 lines
branches/zip
Remove redundant TRUE : FALSE from the return statement
r5709 | inaam | 2009-08-28 01:22:46 -0500 (Fri, 28 Aug 2009) | 5 lines
branches/zip rb://152
Disable display of deprecated parameter innodb_file_io_threads in
'show variables'.
r5714 | marko | 2009-08-31 01:10:10 -0500 (Mon, 31 Aug 2009) | 5 lines
branches/zip: buf_chunk_not_freed(): Do not acquire block->mutex unless
block->page.state == BUF_BLOCK_FILE_PAGE. Check that block->page.state
makes sense.
Approved by Sunny Bains over the IM.
r5716 | vasil | 2009-08-31 02:47:49 -0500 (Mon, 31 Aug 2009) | 9 lines
branches/zip:
Fix Bug#46718 InnoDB plugin incompatible with gcc 4.1 (at least: on PPC): "Undefined symbol"
by implementing our own check in plug.in instead of using the result from
the check from MySQL because it is insufficient.
Approved by: Marko (rb://154)
2009-10-08 16:58:37 +05:30
|
|
|
buf_pool_stat_t stat; /*!< current statistics */
|
|
|
|
buf_pool_stat_t old_stat; /*!< old statistics */
|
|
|
|
|
2009-05-27 15:15:59 +05:30
|
|
|
/* @} */
|
Applying InnoDB Plugin 1.0.5 snapshot, part 4
From revision r5703 to r5716
Detailed revision comments:
r5703 | marko | 2009-08-27 02:25:00 -0500 (Thu, 27 Aug 2009) | 41 lines
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.
r5704 | marko | 2009-08-27 03:31:17 -0500 (Thu, 27 Aug 2009) | 32 lines
branches/zip: Fix a critical bug in fast index creation that could
corrupt the created indexes.
row_merge(): Make "half" an in/out parameter. Determine the offset of
half the output file. Copy the last blocks record-by-record instead of
block-by-block, so that the records can be counted. Check that the
input and output have matching n_rec.
row_merge_sort(): Do not assume that two blocks of size N are merged
into a block of size 2*N. The output block can be shorter than the
input if the last page of each input block is almost empty. Use an
accurate termination condition, based on the "half" computed by
row_merge().
row_merge_read(), row_merge_write(), row_merge_blocks(): Add debug output.
merge_file_t, row_merge_file_create(): Add n_rec, the number of records
in the merge file.
row_merge_read_clustered_index(): Update n_rec.
row_merge_blocks(): Update and check n_rec.
row_merge_blocks_copy(): New function, for copying the last blocks in
row_merge(). Update and check n_rec.
This bug was discovered with a user-supplied test case that creates an
index where the initial temporary file is 249 one-megabyte blocks and
the merged files become smaller. In the test, possible merge record
sizes are 10, 18, and 26 bytes.
rb://150 approved by Sunny Bains. This addresses Issue #320.
r5705 | marko | 2009-08-27 06:56:24 -0500 (Thu, 27 Aug 2009) | 11 lines
branches/zip: dict_index_find_cols(): On column name lookup failure,
return DB_CORRUPTION (HA_ERR_CRASHED) instead of abnormally
terminating the server. Also, disable the previously added diagnostic
output to the error log, because mysql-test-run does not like extra
output in the error log. (Bug #44571)
dict_index_add_to_cache(): Handle errors from dict_index_find_cols().
mysql-test/innodb_bug44571.test: A test case for triggering the bug.
rb://135 approved by Sunny Bains.
r5706 | inaam | 2009-08-27 11:00:27 -0500 (Thu, 27 Aug 2009) | 20 lines
branches/zip rb://147
Done away with following two status variables:
innodb_buffer_pool_read_ahead_rnd
innodb_buffer_pool_read_ahead_seq
Introduced two new status variables:
innodb_buffer_pool_read_ahead = number of pages read as part of
readahead since server startup
innodb_buffer_pool_read_ahead_evicted = number of pages that are read
in as readahead but were evicted before ever being accessed since
server startup i.e.: a measure of how badly our readahead is
performing
SHOW INNODB STATUS will show two extra numbers in buffer pool section:
pages read ahead/sec and pages evicted without access/sec
Approved by: Marko
r5707 | inaam | 2009-08-27 11:20:35 -0500 (Thu, 27 Aug 2009) | 6 lines
branches/zip
Remove unused macros as we erased the random readahead code in r5703.
Also fixed some comments.
r5708 | inaam | 2009-08-27 17:43:32 -0500 (Thu, 27 Aug 2009) | 4 lines
branches/zip
Remove redundant TRUE : FALSE from the return statement
r5709 | inaam | 2009-08-28 01:22:46 -0500 (Fri, 28 Aug 2009) | 5 lines
branches/zip rb://152
Disable display of deprecated parameter innodb_file_io_threads in
'show variables'.
r5714 | marko | 2009-08-31 01:10:10 -0500 (Mon, 31 Aug 2009) | 5 lines
branches/zip: buf_chunk_not_freed(): Do not acquire block->mutex unless
block->page.state == BUF_BLOCK_FILE_PAGE. Check that block->page.state
makes sense.
Approved by Sunny Bains over the IM.
r5716 | vasil | 2009-08-31 02:47:49 -0500 (Mon, 31 Aug 2009) | 9 lines
branches/zip:
Fix Bug#46718 InnoDB plugin incompatible with gcc 4.1 (at least: on PPC): "Undefined symbol"
by implementing our own check in plug.in instead of using the result from
the check from MySQL because it is insufficient.
Approved by: Marko (rb://154)
2009-10-08 16:58:37 +05:30
|
|
|
|
2009-07-30 17:42:56 +05:00
|
|
|
/** @name Page flushing algorithm fields */
|
Applying InnoDB Plugin 1.0.5 snapshot, part 4
From revision r5703 to r5716
Detailed revision comments:
r5703 | marko | 2009-08-27 02:25:00 -0500 (Thu, 27 Aug 2009) | 41 lines
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.
r5704 | marko | 2009-08-27 03:31:17 -0500 (Thu, 27 Aug 2009) | 32 lines
branches/zip: Fix a critical bug in fast index creation that could
corrupt the created indexes.
row_merge(): Make "half" an in/out parameter. Determine the offset of
half the output file. Copy the last blocks record-by-record instead of
block-by-block, so that the records can be counted. Check that the
input and output have matching n_rec.
row_merge_sort(): Do not assume that two blocks of size N are merged
into a block of size 2*N. The output block can be shorter than the
input if the last page of each input block is almost empty. Use an
accurate termination condition, based on the "half" computed by
row_merge().
row_merge_read(), row_merge_write(), row_merge_blocks(): Add debug output.
merge_file_t, row_merge_file_create(): Add n_rec, the number of records
in the merge file.
row_merge_read_clustered_index(): Update n_rec.
row_merge_blocks(): Update and check n_rec.
row_merge_blocks_copy(): New function, for copying the last blocks in
row_merge(). Update and check n_rec.
This bug was discovered with a user-supplied test case that creates an
index where the initial temporary file is 249 one-megabyte blocks and
the merged files become smaller. In the test, possible merge record
sizes are 10, 18, and 26 bytes.
rb://150 approved by Sunny Bains. This addresses Issue #320.
r5705 | marko | 2009-08-27 06:56:24 -0500 (Thu, 27 Aug 2009) | 11 lines
branches/zip: dict_index_find_cols(): On column name lookup failure,
return DB_CORRUPTION (HA_ERR_CRASHED) instead of abnormally
terminating the server. Also, disable the previously added diagnostic
output to the error log, because mysql-test-run does not like extra
output in the error log. (Bug #44571)
dict_index_add_to_cache(): Handle errors from dict_index_find_cols().
mysql-test/innodb_bug44571.test: A test case for triggering the bug.
rb://135 approved by Sunny Bains.
r5706 | inaam | 2009-08-27 11:00:27 -0500 (Thu, 27 Aug 2009) | 20 lines
branches/zip rb://147
Done away with following two status variables:
innodb_buffer_pool_read_ahead_rnd
innodb_buffer_pool_read_ahead_seq
Introduced two new status variables:
innodb_buffer_pool_read_ahead = number of pages read as part of
readahead since server startup
innodb_buffer_pool_read_ahead_evicted = number of pages that are read
in as readahead but were evicted before ever being accessed since
server startup i.e.: a measure of how badly our readahead is
performing
SHOW INNODB STATUS will show two extra numbers in buffer pool section:
pages read ahead/sec and pages evicted without access/sec
Approved by: Marko
r5707 | inaam | 2009-08-27 11:20:35 -0500 (Thu, 27 Aug 2009) | 6 lines
branches/zip
Remove unused macros as we erased the random readahead code in r5703.
Also fixed some comments.
r5708 | inaam | 2009-08-27 17:43:32 -0500 (Thu, 27 Aug 2009) | 4 lines
branches/zip
Remove redundant TRUE : FALSE from the return statement
r5709 | inaam | 2009-08-28 01:22:46 -0500 (Fri, 28 Aug 2009) | 5 lines
branches/zip rb://152
Disable display of deprecated parameter innodb_file_io_threads in
'show variables'.
r5714 | marko | 2009-08-31 01:10:10 -0500 (Mon, 31 Aug 2009) | 5 lines
branches/zip: buf_chunk_not_freed(): Do not acquire block->mutex unless
block->page.state == BUF_BLOCK_FILE_PAGE. Check that block->page.state
makes sense.
Approved by Sunny Bains over the IM.
r5716 | vasil | 2009-08-31 02:47:49 -0500 (Mon, 31 Aug 2009) | 9 lines
branches/zip:
Fix Bug#46718 InnoDB plugin incompatible with gcc 4.1 (at least: on PPC): "Undefined symbol"
by implementing our own check in plug.in instead of using the result from
the check from MySQL because it is insufficient.
Approved by: Marko (rb://154)
2009-10-08 16:58:37 +05:30
|
|
|
|
2009-05-27 15:15:59 +05:30
|
|
|
/* @{ */
|
|
|
|
|
|
|
|
UT_LIST_BASE_NODE_T(buf_page_t) flush_list;
|
|
|
|
/*!< base node of the modified block
|
|
|
|
list */
|
|
|
|
ibool init_flush[BUF_FLUSH_N_TYPES];
|
|
|
|
/*!< this is TRUE when a flush of the
|
|
|
|
given type is being initialized */
|
|
|
|
ulint n_flush[BUF_FLUSH_N_TYPES];
|
|
|
|
/*!< this is the number of pending
|
|
|
|
writes in the given flush type */
|
|
|
|
os_event_t no_flush[BUF_FLUSH_N_TYPES];
|
|
|
|
/*!< this is in the set state
|
|
|
|
when there is no flush batch
|
|
|
|
of the given type running */
|
2010-04-01 16:56:22 +04:00
|
|
|
ib_rbt_t* flush_rbt; /* !< a red-black tree is used
|
|
|
|
exclusively during recovery to
|
|
|
|
speed up insertions in the
|
|
|
|
flush_list. This tree contains
|
|
|
|
blocks in order of
|
|
|
|
oldest_modification LSN and is
|
|
|
|
kept in sync with the
|
|
|
|
flush_list.
|
|
|
|
Each member of the tree MUST
|
|
|
|
also be on the flush_list.
|
|
|
|
This tree is relevant only in
|
|
|
|
recovery and is set to NULL
|
|
|
|
once the recovery is over. */
|
2009-05-27 15:15:59 +05:30
|
|
|
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,
|
|
|
|
this is incremented by one; this is
|
|
|
|
set to zero when a buffer block is
|
|
|
|
allocated */
|
|
|
|
|
|
|
|
/* @} */
|
2009-07-30 17:42:56 +05:00
|
|
|
/** @name LRU replacement algorithm fields */
|
2009-05-27 15:15:59 +05:30
|
|
|
/* @{ */
|
|
|
|
|
|
|
|
UT_LIST_BASE_NODE_T(buf_page_t) free;
|
|
|
|
/*!< base node of the free
|
|
|
|
block list */
|
|
|
|
UT_LIST_BASE_NODE_T(buf_page_t) LRU;
|
|
|
|
/*!< base node of the LRU list */
|
Applying InnoDB Plugin 1.0.5 snapshot, part 4
From revision r5703 to r5716
Detailed revision comments:
r5703 | marko | 2009-08-27 02:25:00 -0500 (Thu, 27 Aug 2009) | 41 lines
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.
r5704 | marko | 2009-08-27 03:31:17 -0500 (Thu, 27 Aug 2009) | 32 lines
branches/zip: Fix a critical bug in fast index creation that could
corrupt the created indexes.
row_merge(): Make "half" an in/out parameter. Determine the offset of
half the output file. Copy the last blocks record-by-record instead of
block-by-block, so that the records can be counted. Check that the
input and output have matching n_rec.
row_merge_sort(): Do not assume that two blocks of size N are merged
into a block of size 2*N. The output block can be shorter than the
input if the last page of each input block is almost empty. Use an
accurate termination condition, based on the "half" computed by
row_merge().
row_merge_read(), row_merge_write(), row_merge_blocks(): Add debug output.
merge_file_t, row_merge_file_create(): Add n_rec, the number of records
in the merge file.
row_merge_read_clustered_index(): Update n_rec.
row_merge_blocks(): Update and check n_rec.
row_merge_blocks_copy(): New function, for copying the last blocks in
row_merge(). Update and check n_rec.
This bug was discovered with a user-supplied test case that creates an
index where the initial temporary file is 249 one-megabyte blocks and
the merged files become smaller. In the test, possible merge record
sizes are 10, 18, and 26 bytes.
rb://150 approved by Sunny Bains. This addresses Issue #320.
r5705 | marko | 2009-08-27 06:56:24 -0500 (Thu, 27 Aug 2009) | 11 lines
branches/zip: dict_index_find_cols(): On column name lookup failure,
return DB_CORRUPTION (HA_ERR_CRASHED) instead of abnormally
terminating the server. Also, disable the previously added diagnostic
output to the error log, because mysql-test-run does not like extra
output in the error log. (Bug #44571)
dict_index_add_to_cache(): Handle errors from dict_index_find_cols().
mysql-test/innodb_bug44571.test: A test case for triggering the bug.
rb://135 approved by Sunny Bains.
r5706 | inaam | 2009-08-27 11:00:27 -0500 (Thu, 27 Aug 2009) | 20 lines
branches/zip rb://147
Done away with following two status variables:
innodb_buffer_pool_read_ahead_rnd
innodb_buffer_pool_read_ahead_seq
Introduced two new status variables:
innodb_buffer_pool_read_ahead = number of pages read as part of
readahead since server startup
innodb_buffer_pool_read_ahead_evicted = number of pages that are read
in as readahead but were evicted before ever being accessed since
server startup i.e.: a measure of how badly our readahead is
performing
SHOW INNODB STATUS will show two extra numbers in buffer pool section:
pages read ahead/sec and pages evicted without access/sec
Approved by: Marko
r5707 | inaam | 2009-08-27 11:20:35 -0500 (Thu, 27 Aug 2009) | 6 lines
branches/zip
Remove unused macros as we erased the random readahead code in r5703.
Also fixed some comments.
r5708 | inaam | 2009-08-27 17:43:32 -0500 (Thu, 27 Aug 2009) | 4 lines
branches/zip
Remove redundant TRUE : FALSE from the return statement
r5709 | inaam | 2009-08-28 01:22:46 -0500 (Fri, 28 Aug 2009) | 5 lines
branches/zip rb://152
Disable display of deprecated parameter innodb_file_io_threads in
'show variables'.
r5714 | marko | 2009-08-31 01:10:10 -0500 (Mon, 31 Aug 2009) | 5 lines
branches/zip: buf_chunk_not_freed(): Do not acquire block->mutex unless
block->page.state == BUF_BLOCK_FILE_PAGE. Check that block->page.state
makes sense.
Approved by Sunny Bains over the IM.
r5716 | vasil | 2009-08-31 02:47:49 -0500 (Mon, 31 Aug 2009) | 9 lines
branches/zip:
Fix Bug#46718 InnoDB plugin incompatible with gcc 4.1 (at least: on PPC): "Undefined symbol"
by implementing our own check in plug.in instead of using the result from
the check from MySQL because it is insufficient.
Approved by: Marko (rb://154)
2009-10-08 16:58:37 +05:30
|
|
|
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;
|
2009-05-27 15:15:59 +05:30
|
|
|
NOTE: when LRU_old != NULL, its length
|
|
|
|
should always equal LRU_old_len */
|
|
|
|
ulint LRU_old_len; /*!< length of the LRU list from
|
|
|
|
the block to which LRU_old points
|
|
|
|
onward, including that block;
|
|
|
|
see buf0lru.c for the restrictions
|
2009-11-03 14:26:07 +04:00
|
|
|
on this value; 0 if LRU_old == NULL;
|
2009-05-27 15:15:59 +05:30
|
|
|
NOTE: LRU_old_len must be adjusted
|
|
|
|
whenever LRU_old shrinks or grows! */
|
|
|
|
|
|
|
|
UT_LIST_BASE_NODE_T(buf_block_t) unzip_LRU;
|
|
|
|
/*!< base node of the
|
|
|
|
unzip_LRU list */
|
|
|
|
|
|
|
|
/* @} */
|
2009-07-30 17:42:56 +05: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-27 15:15:59 +05:30
|
|
|
/* @{ */
|
|
|
|
UT_LIST_BASE_NODE_T(buf_page_t) zip_clean;
|
|
|
|
/*!< unmodified compressed pages */
|
|
|
|
UT_LIST_BASE_NODE_T(buf_page_t) zip_free[BUF_BUDDY_SIZES];
|
|
|
|
/*!< buddy free lists */
|
|
|
|
#if BUF_BUDDY_HIGH != UNIV_PAGE_SIZE
|
|
|
|
# error "BUF_BUDDY_HIGH != UNIV_PAGE_SIZE"
|
|
|
|
#endif
|
|
|
|
#if BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE
|
|
|
|
# error "BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE"
|
|
|
|
#endif
|
|
|
|
/* @} */
|
|
|
|
};
|
|
|
|
|
|
|
|
/** mutex protecting the buffer pool struct and control blocks, except the
|
|
|
|
read-write lock in them */
|
|
|
|
extern mutex_t buf_pool_mutex;
|
|
|
|
/** mutex protecting the control blocks of compressed-only pages
|
|
|
|
(of type buf_page_t, not buf_block_t) */
|
|
|
|
extern mutex_t buf_pool_zip_mutex;
|
|
|
|
|
2009-07-30 17:42:56 +05:00
|
|
|
/** @name Accessors for buf_pool_mutex.
|
|
|
|
Use these instead of accessing buf_pool_mutex directly. */
|
2009-05-27 15:15:59 +05:30
|
|
|
/* @{ */
|
|
|
|
|
|
|
|
/** Test if buf_pool_mutex is owned. */
|
|
|
|
#define buf_pool_mutex_own() mutex_own(&buf_pool_mutex)
|
|
|
|
/** Acquire the buffer pool mutex. */
|
|
|
|
#define buf_pool_mutex_enter() do { \
|
|
|
|
ut_ad(!mutex_own(&buf_pool_zip_mutex)); \
|
|
|
|
mutex_enter(&buf_pool_mutex); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#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;
|
|
|
|
/** Forbid the release of the buffer pool mutex. */
|
|
|
|
# define buf_pool_mutex_exit_forbid() do { \
|
|
|
|
ut_ad(buf_pool_mutex_own()); \
|
|
|
|
buf_pool_mutex_exit_forbidden++; \
|
|
|
|
} while (0)
|
|
|
|
/** Allow the release of the buffer pool mutex. */
|
|
|
|
# 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)
|
|
|
|
/** Release the buffer pool mutex. */
|
|
|
|
# define buf_pool_mutex_exit() do { \
|
|
|
|
ut_a(!buf_pool_mutex_exit_forbidden); \
|
|
|
|
mutex_exit(&buf_pool_mutex); \
|
|
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
/** Forbid the release of the buffer pool mutex. */
|
|
|
|
# define buf_pool_mutex_exit_forbid() ((void) 0)
|
|
|
|
/** Allow the release of the buffer pool mutex. */
|
|
|
|
# define buf_pool_mutex_exit_allow() ((void) 0)
|
|
|
|
/** Release the buffer pool mutex. */
|
|
|
|
# define buf_pool_mutex_exit() mutex_exit(&buf_pool_mutex)
|
|
|
|
#endif
|
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
/* @} */
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
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,
|
|
|
|
pool: no_flush[flush_type] is in reset state,
|
|
|
|
pool: n_flush[flush_type] > 0
|
|
|
|
|
|
|
|
(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
|
|
|
|
|
|
|
|
(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
|
|
|
|
if io_fix == BUF_IO_READ,
|
|
|
|
is x-locked
|
|
|
|
if io_fix == BUF_IO_WRITE,
|
|
|
|
is s-locked
|
|
|
|
|
|
|
|
State transitions:
|
|
|
|
|
|
|
|
NOT_USED => READY_FOR_USE
|
|
|
|
READY_FOR_USE => MEMORY
|
|
|
|
READY_FOR_USE => FILE_PAGE
|
|
|
|
MEMORY => NOT_USED
|
|
|
|
FILE_PAGE => NOT_USED NOTE: This transition is allowed if and only if
|
|
|
|
(1) buf_fix_count == 0,
|
|
|
|
(2) oldest_modification == 0, and
|
|
|
|
(3) io_fix == 0.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef UNIV_NONINL
|
|
|
|
#include "buf0buf.ic"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|