mirror of
https://github.com/MariaDB/server.git
synced 2025-12-16 22:03:23 +03:00
Fixes: - Bug #24712: SHOW TABLE STATUS for file-per-table showing incorrect time fields - Bug #24386: Performance degradation caused by instrumentation in mutex_struct - Bug #24190: many exportable definitions of field_in_record_is_null - Bug #21468: InnoDB crash during recovery with corrupted data pages: XA bug? storage/innobase/buf/buf0buf.c: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1045: buf_page_init_for_read(): Correct the indentation. storage/innobase/buf/buf0flu.c: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1038: Port r983 from branches/zip: Enclose some more debug code in #ifdef UNIV_SYNC_DEBUG to allow the code to be built with UNIV_DEBUG but without UNIV_SYNC_DEBUG. storage/innobase/dict/dict0dict.c: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1124: Unify dict_table_get_and_increment_handle_count() with dict_table_get() by adding a second parameter, adjust callers. storage/innobase/ha/ha0ha.c: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1039: Port r1034 from branches/zip: Remove some instrumentation and reduce the output of SHOW MUTEX STATUS in non-debug builds. (Bug #24386) storage/innobase/ha/hash0hash.c: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1039: Port r1034 from branches/zip: Remove some instrumentation and reduce the output of SHOW MUTEX STATUS in non-debug builds. (Bug #24386) storage/innobase/handler/ha_innodb.cc: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1028: Merge a change from MySQL AB. ChangeSet 2006/11/10 17:22:43+02:00 aelkin@dsl-hkibras-fe30f900-107.dhcp.inet.fi Bug #24190 many exportable definitions of field_in_record_is_null mysql had several(2) exportable definitions of field_in_record_is_null function. Fixed with adding static. storage/innobase/handler/ha_innodb.cc 2006/11/10 17:22:36+02:00 aelkin@dsl-hkibras-fe30f900-107.dhcp.inet.fi +1 -1 made static Revision r1008: Minor cleanup. ha_innobase::rnd_pos(): Use correct format in DBUG_PRINT statements. buf_page_release(): Remove the local variable buf_fix_count. Revision r1039: Port r1034 from branches/zip: Remove some instrumentation and reduce the output of SHOW MUTEX STATUS in non-debug builds. (Bug #24386) Revision r1124: Unify dict_table_get_and_increment_handle_count() with dict_table_get() by adding a second parameter, adjust callers. Revision r1134: Fix a potential bug in ha_innodb.cc:innobase_query_is_update() where the function can be called with "current_thd == NULL". Minor non-functional fix in log0recv.c Revision r1098: Fix bug #24712: SHOW TABLE STATUS for file-per-table showing incorrect time fields Revision r1109: ha_innodb.cc: Remove unused define MAX_ULONG_BIT. storage/innobase/include/btr0sea.h: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1088: Replace the Latin abbreviation "cf." in comments. storage/innobase/include/buf0buf.ic: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1008: Minor cleanup. ha_innobase::rnd_pos(): Use correct format in DBUG_PRINT statements. buf_page_release(): Remove the local variable buf_fix_count. storage/innobase/include/data0type.ic: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1088: Replace the Latin abbreviation "cf." in comments. storage/innobase/include/dict0dict.h: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1124: Unify dict_table_get_and_increment_handle_count() with dict_table_get() by adding a second parameter, adjust callers. storage/innobase/include/ha0ha.h: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1039: Port r1034 from branches/zip: Remove some instrumentation and reduce the output of SHOW MUTEX STATUS in non-debug builds. (Bug #24386) storage/innobase/include/hash0hash.h: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1039: Port r1034 from branches/zip: Remove some instrumentation and reduce the output of SHOW MUTEX STATUS in non-debug builds. (Bug #24386) storage/innobase/include/sync0rw.h: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1039: Port r1034 from branches/zip: Remove some instrumentation and reduce the output of SHOW MUTEX STATUS in non-debug builds. (Bug #24386) storage/innobase/include/sync0sync.h: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1038: Port r983 from branches/zip: Enclose some more debug code in #ifdef UNIV_SYNC_DEBUG to allow the code to be built with UNIV_DEBUG but without UNIV_SYNC_DEBUG. Revision r1037: Port r972 from branches/zip: Enclose some debug code in #ifdef UNIV_SYNC_DEBUG. The code was previously unused in non-debug builds. Revision r1039: Port r1034 from branches/zip: Remove some instrumentation and reduce the output of SHOW MUTEX STATUS in non-debug builds. (Bug #24386) Revision r1084: Remove the unused constants SYNC_INFINITE_TIME and SYNC_TIME_EXCEEDED. storage/innobase/include/sync0sync.ic: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1039: Port r1034 from branches/zip: Remove some instrumentation and reduce the output of SHOW MUTEX STATUS in non-debug builds. (Bug #24386) storage/innobase/include/univ.i: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1006: Introduce #define UNIV_LIST_DEBUG for enabling the debug code in UT_LIST_REMOVE_CLEAR(). Revision r1088: Replace the Latin abbreviation "cf." in comments. Revision r1083: univ.i: Document the debug flags (UNIV_DEBUG et al). storage/innobase/include/ut0lst.h: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1006: Introduce #define UNIV_LIST_DEBUG for enabling the debug code in UT_LIST_REMOVE_CLEAR(). storage/innobase/lock/lock0lock.c: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1009: Remove duplicate printing of row lock counts in SHOW INNODB STATUS, and in the remaining print, add a comma so it doesn't get combined with the heap size. Both problems were introduced in r383. storage/innobase/log/log0recv.c: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1134: Fix a potential bug in ha_innodb.cc:innobase_query_is_update() where the function can be called with "current_thd == NULL". Minor non-functional fix in log0recv.c Revision r1078: Merge r1067:1077 from branches/5.0: innobase_start_or_create_for_mysql(): Remove unnecessary delay now that we moved the setting sync_order_checks_on=TRUE to log0recv.c, to the start of the rollback phase in crash recovery. Fix assertion failure sync0sync.c line 1239 (the latter ut_error in sync_thread_reset_level()) in crash recovery when UNIV_SYNC_DEBUG is enabled. Revision r1080: Merge r1079 from branches/5.0: recv_recovery_from_checkpoint_finish(): Add 1 sec delay before switching on the sync order checks in crash recovery, so that file I/O threads have time to suspend themselves. storage/innobase/row/row0ins.c: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1124: Unify dict_table_get_and_increment_handle_count() with dict_table_get() by adding a second parameter, adjust callers. storage/innobase/row/row0sel.c: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1038: Port r983 from branches/zip: Enclose some more debug code in #ifdef UNIV_SYNC_DEBUG to allow the code to be built with UNIV_DEBUG but without UNIV_SYNC_DEBUG. Revision r1124: Unify dict_table_get_and_increment_handle_count() with dict_table_get() by adding a second parameter, adjust callers. storage/innobase/row/row0upd.c: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1124: Unify dict_table_get_and_increment_handle_count() with dict_table_get() by adding a second parameter, adjust callers. storage/innobase/srv/srv0start.c: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1038: Port r983 from branches/zip: Enclose some more debug code in #ifdef UNIV_SYNC_DEBUG to allow the code to be built with UNIV_DEBUG but without UNIV_SYNC_DEBUG. Revision r1078: Merge r1067:1077 from branches/5.0: innobase_start_or_create_for_mysql(): Remove unnecessary delay now that we moved the setting sync_order_checks_on=TRUE to log0recv.c, to the start of the rollback phase in crash recovery. Fix assertion failure sync0sync.c line 1239 (the latter ut_error in sync_thread_reset_level()) in crash recovery when UNIV_SYNC_DEBUG is enabled. Revision r1070: Remove another accidentally committed change to srv0start.c. The change was accidentally committed with the merge in r1068. This revision corresponds to r1051 with a properly merged r1067 of branches/5.0. Revision r1068: Merge r1067 from branches/5.0: trx_rollback_for_mysql(), trx_commit_for_mysql(): Protect the creation of trx_dummy_sess with kernel_mutex. This error was introduced in r1046 and r1050. Revision r1069: Remove an accidentally committed change to srv0start.c. The change was accidentally committed with the merge in r1068. storage/innobase/sync/sync0rw.c: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1039: Port r1034 from branches/zip: Remove some instrumentation and reduce the output of SHOW MUTEX STATUS in non-debug builds. (Bug #24386) storage/innobase/sync/sync0sync.c: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1038: Port r983 from branches/zip: Enclose some more debug code in #ifdef UNIV_SYNC_DEBUG to allow the code to be built with UNIV_DEBUG but without UNIV_SYNC_DEBUG. Revision r1037: Port r972 from branches/zip: Enclose some debug code in #ifdef UNIV_SYNC_DEBUG. The code was previously unused in non-debug builds. Revision r1039: Port r1034 from branches/zip: Remove some instrumentation and reduce the output of SHOW MUTEX STATUS in non-debug builds. (Bug #24386) storage/innobase/trx/trx0roll.c: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1049: Merge r1048 from branches/5.0: trx_rollback_for_mysql(): Do not set trx->sess back to NULL. This bug was introduced in r1046. Revision r1047: Merge r1046 from branches/5.0: branches/5.0: trx_rollback_for_mysql(): Ensure that trx->sess is non-NULL when calling trx_general_rollback_for_mysql(). This removes a segmentation fault when rolling back a prepared transaction in XA recovery. (Bug #21468) Revision r1068: Merge r1067 from branches/5.0: trx_rollback_for_mysql(), trx_commit_for_mysql(): Protect the creation of trx_dummy_sess with kernel_mutex. This error was introduced in r1046 and r1050. Revision r1051: Merge r1050 from branches/5.0: trx_rollback_for_mysql(): Fix the comment introduced in r1046. trx_commit_for_mysql(): Use the dummy trx->sess also for committing a prepared transaction in XA recovery, just in case our code would need the session object also in that case (does not seem to need it right now). storage/innobase/trx/trx0trx.c: Applied innodb-5.1-ss1039 and innodb-5.1-ss1134 snapshots. Revision r1009: Remove duplicate printing of row lock counts in SHOW INNODB STATUS, and in the remaining print, add a comma so it doesn't get combined with the heap size. Both problems were introduced in r383. Revision r1068: Merge r1067 from branches/5.0: trx_rollback_for_mysql(), trx_commit_for_mysql(): Protect the creation of trx_dummy_sess with kernel_mutex. This error was introduced in r1046 and r1050. Revision r1051: Merge r1050 from branches/5.0: trx_rollback_for_mysql(): Fix the comment introduced in r1046. trx_commit_for_mysql(): Use the dummy trx->sess also for committing a prepared transaction in XA recovery, just in case our code would need the session object also in that case (does not seem to need it right now).
241 lines
8.0 KiB
C
241 lines
8.0 KiB
C
/************************************************************************
|
|
The index tree adaptive search
|
|
|
|
(c) 1996 Innobase Oy
|
|
|
|
Created 2/17/1996 Heikki Tuuri
|
|
*************************************************************************/
|
|
|
|
#ifndef btr0sea_h
|
|
#define btr0sea_h
|
|
|
|
#include "univ.i"
|
|
|
|
#include "rem0rec.h"
|
|
#include "dict0dict.h"
|
|
#include "btr0types.h"
|
|
#include "mtr0mtr.h"
|
|
#include "ha0ha.h"
|
|
|
|
/*********************************************************************
|
|
Creates and initializes the adaptive search system at a database start. */
|
|
|
|
void
|
|
btr_search_sys_create(
|
|
/*==================*/
|
|
ulint hash_size); /* in: hash index hash table size */
|
|
/************************************************************************
|
|
Returns search info for an index. */
|
|
UNIV_INLINE
|
|
btr_search_t*
|
|
btr_search_get_info(
|
|
/*================*/
|
|
/* out: search info; search mutex reserved */
|
|
dict_index_t* index); /* in: index */
|
|
/*********************************************************************
|
|
Creates and initializes a search info struct. */
|
|
|
|
btr_search_t*
|
|
btr_search_info_create(
|
|
/*===================*/
|
|
/* out, own: search info struct */
|
|
mem_heap_t* heap); /* in: heap where created */
|
|
/*************************************************************************
|
|
Updates the search info. */
|
|
UNIV_INLINE
|
|
void
|
|
btr_search_info_update(
|
|
/*===================*/
|
|
dict_index_t* index, /* in: index of the cursor */
|
|
btr_cur_t* cursor);/* in: cursor which was just positioned */
|
|
/**********************************************************************
|
|
Tries to guess the right search position based on the hash search info
|
|
of the index. Note that if mode is PAGE_CUR_LE, which is used in inserts,
|
|
and the function returns TRUE, then cursor->up_match and cursor->low_match
|
|
both have sensible values. */
|
|
|
|
ibool
|
|
btr_search_guess_on_hash(
|
|
/*=====================*/
|
|
/* out: TRUE if succeeded */
|
|
dict_index_t* index, /* in: index */
|
|
btr_search_t* info, /* in: index search info */
|
|
dtuple_t* tuple, /* in: logical record */
|
|
ulint mode, /* in: PAGE_CUR_L, ... */
|
|
ulint latch_mode, /* in: BTR_SEARCH_LEAF, ... */
|
|
btr_cur_t* cursor, /* out: tree cursor */
|
|
ulint has_search_latch,/* in: latch mode the caller
|
|
currently has on btr_search_latch:
|
|
RW_S_LATCH, RW_X_LATCH, or 0 */
|
|
mtr_t* mtr); /* in: mtr */
|
|
/************************************************************************
|
|
Moves or deletes hash entries for moved records. If new_page is already hashed,
|
|
then the hash index for page, if any, is dropped. If new_page is not hashed,
|
|
and page is hashed, then a new hash index is built to new_page with the same
|
|
parameters as page (this often happens when a page is split). */
|
|
|
|
void
|
|
btr_search_move_or_delete_hash_entries(
|
|
/*===================================*/
|
|
page_t* new_page, /* in: records are copied
|
|
to this page */
|
|
page_t* page, /* in: index page */
|
|
dict_index_t* index); /* in: record descriptor */
|
|
/************************************************************************
|
|
Drops a page hash index. */
|
|
|
|
void
|
|
btr_search_drop_page_hash_index(
|
|
/*============================*/
|
|
page_t* page); /* in: index page, s- or x-latched */
|
|
/************************************************************************
|
|
Drops a page hash index when a page is freed from a fseg to the file system.
|
|
Drops possible hash index if the page happens to be in the buffer pool. */
|
|
|
|
void
|
|
btr_search_drop_page_hash_when_freed(
|
|
/*=================================*/
|
|
ulint space, /* in: space id */
|
|
ulint page_no); /* in: page number */
|
|
/************************************************************************
|
|
Updates the page hash index when a single record is inserted on a page. */
|
|
|
|
void
|
|
btr_search_update_hash_node_on_insert(
|
|
/*==================================*/
|
|
btr_cur_t* cursor);/* in: cursor which was positioned to the
|
|
place to insert using btr_cur_search_...,
|
|
and the new record has been inserted next
|
|
to the cursor */
|
|
/************************************************************************
|
|
Updates the page hash index when a single record is inserted on a page. */
|
|
|
|
void
|
|
btr_search_update_hash_on_insert(
|
|
/*=============================*/
|
|
btr_cur_t* cursor);/* in: cursor which was positioned to the
|
|
place to insert using btr_cur_search_...,
|
|
and the new record has been inserted next
|
|
to the cursor */
|
|
/************************************************************************
|
|
Updates the page hash index when a single record is deleted from a page. */
|
|
|
|
void
|
|
btr_search_update_hash_on_delete(
|
|
/*=============================*/
|
|
btr_cur_t* cursor);/* in: cursor which was positioned on the
|
|
record to delete using btr_cur_search_...,
|
|
the record is not yet deleted */
|
|
/************************************************************************
|
|
Validates the search system. */
|
|
|
|
ibool
|
|
btr_search_validate(void);
|
|
/*======================*/
|
|
/* out: TRUE if ok */
|
|
|
|
/* The search info struct in an index */
|
|
|
|
struct btr_search_struct{
|
|
/* The following fields are not protected by any latch.
|
|
Unfortunately, this means that they must be aligned to
|
|
the machine word, i.e., they cannot be turned into bit-fields. */
|
|
page_t* root_guess; /* the root page frame when it was last time
|
|
fetched, or NULL */
|
|
ulint hash_analysis; /* when this exceeds BTR_SEARCH_HASH_ANALYSIS,
|
|
the hash analysis starts; this is reset if no
|
|
success noticed */
|
|
ibool last_hash_succ; /* TRUE if the last search would have
|
|
succeeded, or did succeed, using the hash
|
|
index; NOTE that the value here is not exact:
|
|
it is not calculated for every search, and the
|
|
calculation itself is not always accurate! */
|
|
ulint n_hash_potential;
|
|
/* number of consecutive searches
|
|
which would have succeeded, or did succeed,
|
|
using the hash index;
|
|
the range is 0 .. BTR_SEARCH_BUILD_LIMIT + 5 */
|
|
/*----------------------*/
|
|
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;
|
|
see also BTR_PAGE_MAX_REC_SIZE */
|
|
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 */
|
|
/*----------------------*/
|
|
#ifdef UNIV_SEARCH_PERF_STAT
|
|
ulint n_hash_succ; /* number of successful hash searches thus
|
|
far */
|
|
ulint n_hash_fail; /* number of failed hash searches */
|
|
ulint n_patt_succ; /* number of successful pattern searches thus
|
|
far */
|
|
ulint n_searches; /* number of searches */
|
|
#endif /* UNIV_SEARCH_PERF_STAT */
|
|
#ifdef UNIV_DEBUG
|
|
ulint magic_n; /* magic number */
|
|
# define BTR_SEARCH_MAGIC_N 1112765
|
|
#endif /* UNIV_DEBUG */
|
|
};
|
|
|
|
/* The hash index system */
|
|
|
|
typedef struct btr_search_sys_struct btr_search_sys_t;
|
|
|
|
struct btr_search_sys_struct{
|
|
hash_table_t* hash_index;
|
|
};
|
|
|
|
extern btr_search_sys_t* btr_search_sys;
|
|
|
|
/* The latch protecting the adaptive search system: this latch protects the
|
|
(1) hash index;
|
|
(2) columns of a record to which we have a pointer in the hash index;
|
|
|
|
but does NOT protect:
|
|
|
|
(3) next record offset field in a record;
|
|
(4) next or previous records on the same page.
|
|
|
|
Bear in mind (3) and (4) when using the hash index.
|
|
*/
|
|
|
|
extern rw_lock_t* btr_search_latch_temp;
|
|
|
|
#define btr_search_latch (*btr_search_latch_temp)
|
|
|
|
#ifdef UNIV_SEARCH_PERF_STAT
|
|
extern ulint btr_search_n_succ;
|
|
extern ulint btr_search_n_hash_fail;
|
|
#endif /* UNIV_SEARCH_PERF_STAT */
|
|
|
|
/* After change in n_fields or n_bytes in info, this many rounds are waited
|
|
before starting the hash analysis again: this is to save CPU time when there
|
|
is no hope in building a hash index. */
|
|
|
|
#define BTR_SEARCH_HASH_ANALYSIS 17
|
|
|
|
/* Limit of consecutive searches for trying a search shortcut on the search
|
|
pattern */
|
|
|
|
#define BTR_SEARCH_ON_PATTERN_LIMIT 3
|
|
|
|
/* Limit of consecutive searches for trying a search shortcut using the hash
|
|
index */
|
|
|
|
#define BTR_SEARCH_ON_HASH_LIMIT 3
|
|
|
|
/* We do this many searches before trying to keep the search latch over calls
|
|
from MySQL. If we notice someone waiting for the latch, we again set this
|
|
much timeout. This is to reduce contention. */
|
|
|
|
#define BTR_SEA_TIMEOUT 10000
|
|
|
|
#ifndef UNIV_NONINL
|
|
#include "btr0sea.ic"
|
|
#endif
|
|
|
|
#endif
|