Below is the list of changes that have just been committed into a local
5.1 repository of tomash. When tomash does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-08-10 15:07:27+04:00, kroki@stripped +3 -0
Merge moonlight.intranet:/home/tomash/src/mysql_ab/tmp_merge
into moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.1-merge
MERGE: 1.1810.1696.104
sql/ha_innodb.cc@stripped, 2006-08-10 15:06:49+04:00, kroki@stripped +17 -9
Null-merge.
MERGE: 1.202.1.95
storage/innobase/fil/fil0fil.c@stripped, 2006-08-10 15:07:06+04:00, kroki@stripped +6 -9
Null-merge.
MERGE: 1.54.10.2
storage/innobase/fil/fil0fil.c@stripped, 2006-08-10 15:06:10+04:00, kroki@stripped +0 -0
Merge rename: innobase/fil/fil0fil.c -> storage/innobase/fil/fil0fil.c
storage/innobase/ibuf/ibuf0ibuf.c@stripped, 2006-08-10 15:07:17+04:00, kroki@stripped +13 -2
Null-merge.
MERGE: 1.36.5.2
storage/innobase/ibuf/ibuf0ibuf.c@stripped, 2006-08-10 15:06:10+04:00, kroki@stripped +0 -0
Merge rename: innobase/ibuf/ibuf0ibuf.c -> storage/innobase/ibuf/ibuf0ibuf.c
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: kroki
# Host: moonlight.intranet
# Root: /home/tomash/src/mysql_ab/mysql-5.1-merge/RESYNC
--- 1.54.10.1/innobase/fil/fil0fil.c 2006-08-10 15:07:34 +04:00
+++ 1.65/storage/innobase/fil/fil0fil.c 2006-08-10 15:07:34 +04:00
@@ -27,7 +27,7 @@ Created 10/25/1995 Heikki Tuuri
#include "mtr0log.h"
#include "dict0dict.h"
-
+
/*
IMPLEMENTATION OF THE TABLESPACE MEMORY CACHE
=============================================
@@ -69,7 +69,7 @@ books on database tuning to achieve more
certainly prevents the OS from fragmenting disk space, but it is not clear
if it really adds speed. We measured on the Pentium 100 MHz + NT + NTFS file
system + EIDE Conner disk only a negligible difference in speed when reading
-from a file, versus reading from a raw disk.
+from a file, versus reading from a raw disk.
To have fast access to a tablespace or a log file, we put the data structures
to a hash table. Each tablespace and log file is given an unique 32-bit
@@ -90,7 +90,7 @@ directory, and we must set the base file
const char* fil_path_to_mysql_datadir = ".";
/* The number of fsyncs done to the log */
-ulint fil_n_log_flushes = 0;
+ulint fil_n_log_flushes = 0;
ulint fil_n_pending_log_flushes = 0;
ulint fil_n_pending_tablespace_flushes = 0;
@@ -117,7 +117,7 @@ struct fil_node_struct {
ulint n_pending_flushes;
/* count of pending flushes on this file;
closing of the file is not allowed if
- this is > 0 */
+ this is > 0 */
ib_longlong modification_counter;/* when we write to the file we
increment this by one */
ib_longlong flush_counter;/* up to what modification_counter value
@@ -165,7 +165,7 @@ struct fil_space_struct {
ulint size; /* space size in pages; 0 if a single-table
tablespace whose size we do not know yet;
last incomplete megabytes in data files may be
- ignored if space == 0 */
+ ignored if space == 0 */
ulint n_reserved_extents;
/* number of reserved free extents for
ongoing operations like B-tree page split */
@@ -177,7 +177,7 @@ struct fil_space_struct {
may need to access the ibuf bitmap page in the
tablespade: dropping of the tablespace is
forbidden if this is > 0 */
- hash_node_t hash; /* hash chain node */
+ hash_node_t hash; /* hash chain node */
hash_node_t name_hash;/* hash chain the name_hash table */
rw_lock_t latch; /* latch protecting the file space storage
allocation */
@@ -251,6 +251,9 @@ struct fil_system_struct {
initialized. */
fil_system_t* fil_system = NULL;
+/* The tablespace memory cache hash table size */
+#define FIL_SYSTEM_HASH_SIZE 50 /* TODO: make bigger! */
+
/************************************************************************
NOTE: you must call fil_mutex_enter_and_prepare_for_io() first!
@@ -464,7 +467,7 @@ fil_node_create(
node->modification_counter = 0;
node->flush_counter = 0;
-
+
HASH_SEARCH(hash, system->spaces, id, space, space->id == id);
if (!space) {
@@ -488,7 +491,7 @@ fil_node_create(
node->space = space;
UT_LIST_ADD_LAST(chain, space->chain, node);
-
+
mutex_exit(&(system->mutex));
}
@@ -507,10 +510,12 @@ fil_node_open_file(
ulint size_low;
ulint size_high;
ibool ret;
+ ibool success;
+#ifndef UNIV_HOTBACKUP
byte* buf2;
byte* page;
- ibool success;
ulint space_id;
+#endif /* !UNIV_HOTBACKUP */
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(system->mutex)));
@@ -543,24 +548,24 @@ fil_node_open_file(
ut_a(0);
}
- ut_a(space->purpose != FIL_LOG);
- ut_a(space->id != 0);
-
os_file_get_size(node->handle, &size_low, &size_high);
size_bytes = (((ib_longlong)size_high) << 32)
- + (ib_longlong)size_low;
+ + (ib_longlong)size_low;
#ifdef UNIV_HOTBACKUP
node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
#else
+ ut_a(space->purpose != FIL_LOG);
+ ut_a(space->id != 0);
+
if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
- fprintf(stderr,
+ fprintf(stderr,
"InnoDB: Error: the size of single-table tablespace file %s\n"
"InnoDB: is only %lu %lu, should be at least %lu!\n", node->name,
(ulong) size_high,
(ulong) size_low, (ulong) (4 * UNIV_PAGE_SIZE));
-
+
ut_a(0);
}
@@ -576,22 +581,22 @@ fil_node_open_file(
space_id = fsp_header_get_space_id(page);
ut_free(buf2);
-
+
/* Close the file now that we have read the space id from it */
os_file_close(node->handle);
if (space_id == ULINT_UNDEFINED || space_id == 0) {
- fprintf(stderr,
+ fprintf(stderr,
"InnoDB: Error: tablespace id %lu in file %s is not sensible\n",
(ulong) space_id,
node->name);
-
- ut_a(0);
+
+ ut_a(0);
}
if (space_id != space->id) {
- fprintf(stderr,
+ fprintf(stderr,
"InnoDB: Error: tablespace id is %lu in the data dictionary\n"
"InnoDB: but in file %s it is %lu!\n", space->id, node->name, space_id);
@@ -614,20 +619,20 @@ fil_node_open_file(
unbuffered async I/O mode, though global variables may make
os_file_create() to fall back to the normal file I/O mode. */
- if (space->purpose == FIL_LOG) {
+ if (space->purpose == FIL_LOG) {
node->handle = os_file_create(node->name, OS_FILE_OPEN,
OS_FILE_AIO, OS_LOG_FILE, &ret);
} else if (node->is_raw_disk) {
node->handle = os_file_create(node->name,
- OS_FILE_OPEN_RAW,
+ OS_FILE_OPEN_RAW,
OS_FILE_AIO, OS_DATA_FILE, &ret);
} else {
node->handle = os_file_create(node->name, OS_FILE_OPEN,
OS_FILE_AIO, OS_DATA_FILE, &ret);
}
-
+
ut_a(ret);
-
+
node->open = TRUE;
system->n_open++;
@@ -683,7 +688,7 @@ ibool
fil_try_to_close_file_in_LRU(
/*=========================*/
/* out: TRUE if success, FALSE if should retry
- later; since i/o's generally complete in <
+ later; since i/o's generally complete in <
100 ms, and as InnoDB writes at most 128 pages
from the buffer pool in a batch, and then
immediately flushes the files, there is a good
@@ -707,22 +712,22 @@ fil_try_to_close_file_in_LRU(
while (node != NULL) {
if (node->modification_counter == node->flush_counter
- && node->n_pending_flushes == 0) {
+ && node->n_pending_flushes == 0) {
fil_node_close_file(node, system);
-
+
return(TRUE);
}
-
+
if (print_info && node->n_pending_flushes > 0) {
fputs("InnoDB: cannot close file ", stderr);
ut_print_filename(stderr, node->name);
fprintf(stderr, ", because n_pending_flushes %lu\n",
- (ulong) node->n_pending_flushes);
+ (ulong) node->n_pending_flushes);
}
if (print_info
- && node->modification_counter != node->flush_counter) {
+ && node->modification_counter != node->flush_counter) {
fputs("InnoDB: cannot close file ", stderr);
ut_print_filename(stderr, node->name);
fprintf(stderr,
@@ -849,7 +854,7 @@ close_more:
/* Flush tablespaces so that we can close modified files in the LRU
list */
- fil_flush_file_spaces(FIL_TABLESPACE);
+ fil_flush_file_spaces(FIL_TABLESPACE);
count++;
@@ -880,7 +885,7 @@ fil_node_free(
node->modification_counter = node->flush_counter;
if (space->is_in_unflushed_spaces
- && fil_space_is_flushed(space)) {
+ && fil_space_is_flushed(space)) {
space->is_in_unflushed_spaces = FALSE;
@@ -893,7 +898,7 @@ fil_node_free(
}
space->size -= node->size;
-
+
UT_LIST_REMOVE(chain, space->chain, node);
mem_free(node->name);
@@ -921,7 +926,7 @@ fil_space_truncate_start(
HASH_SEARCH(hash, system->spaces, id, space, space->id == id);
ut_a(space);
-
+
while (trunc_len > 0) {
node = UT_LIST_GET_FIRST(space->chain);
@@ -930,8 +935,8 @@ fil_space_truncate_start(
trunc_len -= node->size * UNIV_PAGE_SIZE;
fil_node_free(node, system, space);
- }
-
+ }
+
mutex_exit(&(system->mutex));
}
@@ -948,7 +953,7 @@ fil_space_create(
ulint purpose)/* in: FIL_TABLESPACE, or FIL_LOG if log */
{
fil_system_t* system = fil_system;
- fil_space_t* space;
+ fil_space_t* space;
ulint namesake_id;
try_again:
/*printf(
@@ -1036,7 +1041,7 @@ try_again:
space->size = 0;
space->n_reserved_extents = 0;
-
+
space->n_pending_flushes = 0;
space->n_pending_ibuf_merges = 0;
@@ -1044,10 +1049,9 @@ try_again:
space->magic_n = FIL_SPACE_MAGIC_N;
space->ibuf_data = NULL;
-
- rw_lock_create(&(space->latch));
- rw_lock_set_level(&(space->latch), SYNC_FSP);
-
+
+ rw_lock_create(&space->latch, SYNC_FSP);
+
HASH_INSERT(fil_space_t, hash, system->spaces, id, space);
HASH_INSERT(fil_space_t, name_hash, system->name_hash,
@@ -1055,7 +1059,7 @@ try_again:
space->is_in_unflushed_spaces = FALSE;
UT_LIST_ADD_LAST(space_list, system->space_list, space);
-
+
mutex_exit(&(system->mutex));
return(TRUE);
@@ -1082,8 +1086,8 @@ fil_assign_new_space_id(void)
id = system->max_assigned_id;
if (id > (SRV_LOG_SPACE_FIRST_ID / 2) && (id % 1000000UL == 0)) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
"InnoDB: Warning: you are running out of new single-table tablespace id's.\n"
"InnoDB: Current counter is %lu and it must not exceed %lu!\n"
"InnoDB: To reset the counter to zero you have to dump all your tables and\n"
@@ -1092,8 +1096,8 @@ fil_assign_new_space_id(void)
}
if (id >= SRV_LOG_SPACE_FIRST_ID) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
"InnoDB: You have run out of single-table tablespace id's!\n"
"InnoDB: Current counter is %lu.\n"
"InnoDB: To reset the counter to zero you have to dump all your tables and\n"
@@ -1135,14 +1139,14 @@ fil_space_free(
"InnoDB: it is not there.\n", (ulong) id);
mutex_exit(&(system->mutex));
-
+
return(FALSE);
}
HASH_DELETE(fil_space_t, hash, system->spaces, id, space);
HASH_SEARCH(name_hash, system->name_hash, ut_fold_string(space->name),
- namespace, 0 == strcmp(space->name, namespace->name));
+ namespace, 0 == strcmp(space->name, namespace->name));
ut_a(namespace);
ut_a(space == namespace);
@@ -1167,8 +1171,8 @@ fil_space_free(
fil_node_free(fil_node, system, space);
fil_node = UT_LIST_GET_FIRST(space->chain);
- }
-
+ }
+
ut_a(0 == UT_LIST_GET_LEN(space->chain));
mutex_exit(&(system->mutex));
@@ -1214,7 +1218,7 @@ fil_space_get_size(
/* out: space size, 0 if space not found */
ulint id) /* in: space id */
{
- fil_system_t* system = fil_system;
+ fil_system_t* system = fil_system;
fil_node_t* node;
fil_space_t* space;
ulint size;
@@ -1247,7 +1251,7 @@ fil_space_get_size(
}
size = space->size;
-
+
mutex_exit(&(system->mutex));
return(size);
@@ -1270,7 +1274,7 @@ fil_check_adress_in_tablespace(
}
return(FALSE);
-}
+}
/********************************************************************
Creates a the tablespace memory cache. */
@@ -1290,9 +1294,7 @@ fil_system_create(
system = mem_alloc(sizeof(fil_system_t));
- mutex_create(&(system->mutex));
-
- mutex_set_level(&(system->mutex), SYNC_ANY_LATCH);
+ mutex_create(&system->mutex, SYNC_ANY_LATCH);
system->spaces = hash_create(hash_size);
system->name_hash = hash_create(hash_size);
@@ -1321,17 +1323,11 @@ fil_init(
/*=====*/
ulint max_n_open) /* in: max number of open files */
{
- ulint hash_size;
-
ut_a(fil_system == NULL);
- if (srv_file_per_table) {
- hash_size = 50000;
- } else {
- hash_size = 5000;
- }
-
- fil_system = fil_system_create(hash_size, max_n_open);
+ /*printf("Initializing the tablespace cache with max %lu open files\n",
+ max_n_open); */
+ fil_system = fil_system_create(FIL_SYSTEM_HASH_SIZE, max_n_open);
}
/***********************************************************************
@@ -1369,8 +1365,8 @@ fil_open_log_and_system_tablespace_files
"InnoDB: tablespace files open for the whole time mysqld is running, and\n"
"InnoDB: needs to open also some .ibd files if the file-per-table storage\n"
"InnoDB: model is used. Current open files %lu, max allowed open files %lu.\n",
- (ulong) system->n_open,
- (ulong) system->max_n_open);
+ (ulong) system->n_open,
+ (ulong) system->max_n_open);
}
node = UT_LIST_GET_NEXT(chain, node);
}
@@ -1453,7 +1449,7 @@ fil_ibuf_init_at_db_start(void)
space = UT_LIST_GET_FIRST(fil_system->space_list);
ut_a(space);
- ut_a(space->purpose == FIL_TABLESPACE);
+ ut_a(space->purpose == FIL_TABLESPACE);
space->ibuf_data = ibuf_data_init_for_space(space->id);
}
@@ -1484,7 +1480,7 @@ fil_write_lsn_and_arch_no_to_file(
fil_write(TRUE, space_id, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
- return(DB_SUCCESS);
+ return(DB_SUCCESS);
}
/********************************************************************
@@ -1504,9 +1500,9 @@ fil_write_flushed_lsn_to_data_files(
ulint err;
mutex_enter(&(fil_system->mutex));
-
+
space = UT_LIST_GET_FIRST(fil_system->space_list);
-
+
while (space) {
/* We only write the lsn to all existing data files which have
been open during the lifetime of the mysqld process; they are
@@ -1515,7 +1511,7 @@ fil_write_flushed_lsn_to_data_files(
always open. */
if (space->purpose == FIL_TABLESPACE
- && space->id == 0) {
+ && space->id == 0) {
sum_of_sizes = 0;
node = UT_LIST_GET_FIRST(space->chain);
@@ -1568,7 +1564,7 @@ fil_read_flushed_lsn_and_arch_log_no(
buf2 = ut_malloc(2 * UNIV_PAGE_SIZE);
/* Align the memory for a possible read from a raw device */
buf = ut_align(buf2, UNIV_PAGE_SIZE);
-
+
os_file_read(data_file, buf, 0, 0, UNIV_PAGE_SIZE);
flushed_lsn = mach_read_from_8(buf + FIL_PAGE_FILE_FLUSH_LSN);
@@ -1616,7 +1612,7 @@ fil_inc_pending_ibuf_merges(
{
fil_system_t* system = fil_system;
fil_space_t* space;
-
+
mutex_enter(&(system->mutex));
HASH_SEARCH(hash, system->spaces, id, space, space->id == id);
@@ -1645,12 +1641,12 @@ Decrements the count of pending insert b
void
fil_decr_pending_ibuf_merges(
-/*========================*/
+/*=========================*/
ulint id) /* in: space id */
{
fil_system_t* system = fil_system;
fil_space_t* space;
-
+
mutex_enter(&(system->mutex));
HASH_SEARCH(hash, system->spaces, id, space, space->id == id);
@@ -1711,7 +1707,7 @@ fil_op_write_log(
const char* name, /* in: table name in the familiar
'databasename/tablename' format, or
the file path in the case of
- MLOG_FILE_DELETE */
+ MLOG_FILE_DELETE */
const char* new_name, /* in: if type is MLOG_FILE_RENAME,
the new table name in the
'databasename/tablename' format */
@@ -1770,13 +1766,13 @@ datadir that we should use in replaying
byte*
fil_op_log_parse_or_replay(
/*=======================*/
- /* out: end of log record, or NULL if the
+ /* out: end of log record, or NULL if the
record was not completely contained between
ptr and end_ptr */
- byte* ptr, /* in: buffer containing the log record body,
+ byte* ptr, /* in: buffer containing the log record body,
or an initial segment of it, if the record does
not fir completely between ptr and end_ptr */
- byte* end_ptr, /* in: buffer end */
+ byte* end_ptr, /* in: buffer end */
ulint type, /* in: the type of this log record */
ibool do_replay, /* in: TRUE if we want to replay the
operation, and not just parse the log record */
@@ -1799,7 +1795,7 @@ fil_op_log_parse_or_replay(
ptr += 2;
if (end_ptr < ptr + name_len) {
-
+
return(NULL);
}
@@ -1814,11 +1810,11 @@ fil_op_log_parse_or_replay(
}
new_name_len = mach_read_from_2(ptr);
-
+
ptr += 2;
if (end_ptr < ptr + new_name_len) {
-
+
return(NULL);
}
@@ -1844,7 +1840,7 @@ fil_op_log_parse_or_replay(
/* Let us try to perform the file operation, if sensible. Note that
ibbackup has at this stage already read in all space id info to the
fil0fil.c data structures.
-
+
NOTE that our algorithm is not guaranteed to work correctly if there
were renames of tables during the backup. See ibbackup code for more
on the problem. */
@@ -1863,12 +1859,12 @@ fil_op_log_parse_or_replay(
/* Create the database directory for the new name, if
it does not exist yet */
fil_create_directory_for_tablename(new_name);
-
+
/* Rename the table if there is not yet a tablespace
with the same name */
if (fil_get_space_id_for_table(new_name)
- == ULINT_UNDEFINED) {
+ == ULINT_UNDEFINED) {
/* We do not care of the old name, that is
why we pass NULL as the first argument */
ut_a(fil_rename_tablespace(NULL, space_id,
@@ -1890,7 +1886,7 @@ fil_op_log_parse_or_replay(
ut_a(space_id != 0);
- ut_a(DB_SUCCESS ==
+ ut_a(DB_SUCCESS ==
fil_create_new_single_table_tablespace(
&space_id, name, FALSE,
FIL_IBD_FILE_INITIAL_SIZE));
@@ -1969,9 +1965,9 @@ try_again:
(ulong) id);
mutex_exit(&(system->mutex));
-
+
return(FALSE);
- }
+ }
ut_a(space);
ut_a(space->n_pending_ibuf_merges == 0);
@@ -2074,7 +2070,7 @@ fil_discard_tablespace(
fprintf(stderr,
"InnoDB: Warning: cannot delete tablespace %lu in DISCARD TABLESPACE.\n"
"InnoDB: But let us remove the insert buffer entries for this tablespace.\n",
- (ulong) id);
+ (ulong) id);
}
/* Remove all insert buffer entries for the tablespace */
@@ -2098,9 +2094,9 @@ fil_rename_tablespace_in_mem(
fil_system_t* system = fil_system;
fil_space_t* space2;
const char* old_name = space->name;
-
+
HASH_SEARCH(name_hash, system->name_hash, ut_fold_string(old_name),
- space2, 0 == strcmp(old_name, space2->name));
+ space2, 0 == strcmp(old_name, space2->name));
if (space != space2) {
fputs("InnoDB: Error: cannot find ", stderr);
ut_print_filename(stderr, old_name);
@@ -2110,12 +2106,12 @@ fil_rename_tablespace_in_mem(
}
HASH_SEARCH(name_hash, system->name_hash, ut_fold_string(path),
- space2, 0 == strcmp(path, space2->name));
+ space2, 0 == strcmp(path, space2->name));
if (space2 != NULL) {
fputs("InnoDB: Error: ", stderr);
ut_print_filename(stderr, path);
fputs(" is already in tablespace memory cache\n", stderr);
-
+
return(FALSE);
}
@@ -2187,11 +2183,11 @@ fil_rename_tablespace(
fil_node_t* node;
ulint count = 0;
char* path;
- ibool old_name_was_specified = TRUE;
+ ibool old_name_was_specified = TRUE;
char* old_path;
ut_a(id != 0);
-
+
if (old_name == NULL) {
old_name = "(name not specified)";
old_name_was_specified = FALSE;
@@ -2300,7 +2296,7 @@ retry:
mutex_exit(&(system->mutex));
-#ifndef UNIV_HOTBACKUP
+#ifndef UNIV_HOTBACKUP
if (success) {
mtr_t mtr;
@@ -2338,7 +2334,7 @@ fil_create_new_single_table_tablespace(
tablespace file in pages,
must be >= FIL_IBD_FILE_INITIAL_SIZE */
{
- os_file_t file;
+ os_file_t file;
ibool ret;
ulint err;
byte* buf2;
@@ -2349,9 +2345,9 @@ fil_create_new_single_table_tablespace(
ut_a(size >= FIL_IBD_FILE_INITIAL_SIZE);
path = fil_make_ibd_name(tablename, is_temp);
-
+
file = os_file_create(path, OS_FILE_CREATE, OS_FILE_NORMAL,
- OS_DATA_FILE, &ret);
+ OS_DATA_FILE, &ret);
if (ret == FALSE) {
ut_print_timestamp(stderr);
fputs(" InnoDB: Error creating file ", stderr);
@@ -2359,11 +2355,11 @@ fil_create_new_single_table_tablespace(
fputs(".\n", stderr);
/* The following call will print an error message */
-
+
err = os_file_get_last_error(TRUE);
-
+
if (err == OS_FILE_ALREADY_EXISTS) {
- fputs(
+ fputs(
"InnoDB: The file already exists though the corresponding table did not\n"
"InnoDB: exist in the InnoDB data dictionary. Have you moved InnoDB\n"
"InnoDB: .ibd files around without using the SQL commands\n"
@@ -2393,7 +2389,7 @@ fil_create_new_single_table_tablespace(
page = ut_align(buf2, UNIV_PAGE_SIZE);
ret = os_file_set_size(path, file, size * UNIV_PAGE_SIZE, 0);
-
+
if (!ret) {
ut_free(buf2);
os_file_close(file);
@@ -2431,7 +2427,7 @@ fil_create_new_single_table_tablespace(
memset(page, '\0', UNIV_PAGE_SIZE);
- fsp_header_write_space_id(page, *space_id);
+ fsp_header_write_space_id(page, *space_id);
buf_flush_init_for_writing(page, ut_dulint_zero, *space_id, 0);
@@ -2464,14 +2460,14 @@ fil_create_new_single_table_tablespace(
}
success = fil_space_create(path, *space_id, FIL_TABLESPACE);
-
+
if (!success) {
goto error_exit2;
- }
+ }
fil_node_create(path, size, *space_id, FALSE);
-#ifndef UNIV_HOTBACKUP
+#ifndef UNIV_HOTBACKUP
{
mtr_t mtr;
@@ -2527,7 +2523,7 @@ fil_reset_too_high_lsns(
ut_print_timestamp(stderr);
- fputs(
+ fputs(
" InnoDB: Error: trying to open a table, but could not\n"
"InnoDB: open the tablespace file ", stderr);
ut_print_filename(stderr, filepath);
@@ -2561,17 +2557,17 @@ fil_reset_too_high_lsns(
}
space_id = fsp_header_get_space_id(page);
-
+
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Flush lsn in the tablespace file %lu to be imported\n"
"InnoDB: is %lu %lu, which exceeds current system lsn %lu %lu.\n"
"InnoDB: We reset the lsn's in the file ",
- (ulong) space_id,
- (ulong) ut_dulint_get_high(flush_lsn),
- (ulong) ut_dulint_get_low(flush_lsn),
- (ulong) ut_dulint_get_high(current_lsn),
- (ulong) ut_dulint_get_low(current_lsn));
+ (ulong) space_id,
+ (ulong) ut_dulint_get_high(flush_lsn),
+ (ulong) ut_dulint_get_low(flush_lsn),
+ (ulong) ut_dulint_get_high(current_lsn),
+ (ulong) ut_dulint_get_low(current_lsn));
ut_print_filename(stderr, filepath);
fputs(".\n", stderr);
@@ -2594,9 +2590,9 @@ fil_reset_too_high_lsns(
space_id = mach_read_from_4(page
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
page_no = mach_read_from_4(page + FIL_PAGE_OFFSET);
-
+
buf_flush_init_for_writing(page, current_lsn, space_id,
- page_no);
+ page_no);
success = os_file_write(filepath, file, page,
(ulint)(offset & 0xFFFFFFFFUL),
(ulint)(offset >> 32), UNIV_PAGE_SIZE);
@@ -2679,7 +2675,7 @@ fil_open_single_table_tablespace(
ut_print_timestamp(stderr);
- fputs(
+ fputs(
" InnoDB: Error: trying to open a table, but could not\n"
"InnoDB: open the tablespace file ", stderr);
ut_print_filename(stderr, filepath);
@@ -2721,7 +2717,7 @@ fil_open_single_table_tablespace(
if (space_id != id) {
ut_print_timestamp(stderr);
- fputs(
+ fputs(
" InnoDB: Error: tablespace id in file ", stderr);
ut_print_filename(stderr, filepath);
fprintf(stderr, " is %lu, but in the InnoDB\n"
@@ -2801,13 +2797,14 @@ fil_load_single_table_tablespace(
#ifdef UNIV_HOTBACKUP
fil_space_t* space;
#endif
- filepath = mem_alloc(strlen(dbname) + strlen(filename)
+ filepath = mem_alloc(strlen(dbname) + strlen(filename)
+ strlen(fil_path_to_mysql_datadir) + 3);
sprintf(filepath, "%s/%s/%s", fil_path_to_mysql_datadir, dbname,
filename);
srv_normalize_path_for_win(filepath);
#ifdef __WIN__
+# ifndef UNIV_HOTBACKUP
/* If lower_case_table_names is 0 or 2, then MySQL allows database
directory names with upper case letters. On Windows, all table and
database names in InnoDB are internally always in lower case. Put the
@@ -2815,6 +2812,7 @@ fil_load_single_table_tablespace(
internal data dictionary. */
dict_casedn_str(filepath);
+# endif /* !UNIV_HOTBACKUP */
#endif
file = os_file_create_simple_no_error_handling(filepath, OS_FILE_OPEN,
OS_FILE_READ_ONLY, &success);
@@ -2822,7 +2820,7 @@ fil_load_single_table_tablespace(
/* The following call prints an error message */
os_file_get_last_error(TRUE);
- fprintf(stderr,
+ fprintf(stderr,
"InnoDB: Error: could not open single-table tablespace file\n"
"InnoDB: %s!\n"
"InnoDB: We do not continue the crash recovery, because the table may become\n"
@@ -2856,7 +2854,7 @@ fil_load_single_table_tablespace(
/* The following call prints an error message */
os_file_get_last_error(TRUE);
- fprintf(stderr,
+ fprintf(stderr,
"InnoDB: Error: could not measure the size of single-table tablespace file\n"
"InnoDB: %s!\n"
"InnoDB: We do not continue crash recovery, because the table will become\n"
@@ -2894,7 +2892,7 @@ fil_load_single_table_tablespace(
size = (((ib_longlong)size_high) << 32) + (ib_longlong)size_low;
#ifndef UNIV_HOTBACKUP
if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
- fprintf(stderr,
+ fprintf(stderr,
"InnoDB: Error: the size of single-table tablespace file %s\n"
"InnoDB: is only %lu %lu, should be at least %lu!", filepath,
(ulong) size_high,
@@ -2923,7 +2921,7 @@ fil_load_single_table_tablespace(
#ifndef UNIV_HOTBACKUP
if (space_id == ULINT_UNDEFINED || space_id == 0) {
- fprintf(stderr,
+ fprintf(stderr,
"InnoDB: Error: tablespace id %lu in file %s is not sensible\n",
(ulong) space_id,
filepath);
@@ -3033,7 +3031,7 @@ fil_file_readdir_next_file(
return(ret);
}
-
+
fprintf(stderr,
"InnoDB: Error: os_file_readdir_next_file() returned -1 in\n"
"InnoDB: directory %s\n"
@@ -3065,7 +3063,7 @@ fil_load_single_table_tablespaces(void)
os_file_dir_t dbdir;
os_file_stat_t dbinfo;
os_file_stat_t fileinfo;
- ulint err = DB_SUCCESS;
+ ulint err = DB_SUCCESS;
/* The datadir of MySQL is always the default directory of mysqld */
@@ -3088,9 +3086,9 @@ fil_load_single_table_tablespaces(void)
/* printf("Looking at %s in datadir\n", dbinfo.name); */
if (dbinfo.type == OS_FILE_TYPE_FILE
- || dbinfo.type == OS_FILE_TYPE_UNKNOWN) {
+ || dbinfo.type == OS_FILE_TYPE_UNKNOWN) {
- goto next_datadir_item;
+ goto next_datadir_item;
}
/* We found a symlink or a directory; try opening it to see
@@ -3123,19 +3121,19 @@ fil_load_single_table_tablespaces(void)
&fileinfo);
while (ret == 0) {
/* printf(
-" Looking at file %s\n", fileinfo.name); */
+ " Looking at file %s\n", fileinfo.name); */
- if (fileinfo.type == OS_FILE_TYPE_DIR) {
+ if (fileinfo.type == OS_FILE_TYPE_DIR) {
- goto next_file_item;
+ goto next_file_item;
}
/* We found a symlink or a file */
if (strlen(fileinfo.name) > 4
- && 0 == strcmp(fileinfo.name +
+ && 0 == strcmp(fileinfo.name +
strlen(fileinfo.name) - 4,
".ibd")) {
- /* The name ends in .ibd; try opening
+ /* The name ends in .ibd; try opening
the file */
fil_load_single_table_tablespace(
dbinfo.name, fileinfo.name);
@@ -3155,7 +3153,7 @@ next_file_item:
err = DB_ERROR;
}
}
-
+
next_datadir_item:
ret = fil_file_readdir_next_file(&err,
fil_path_to_mysql_datadir,
@@ -3185,7 +3183,7 @@ void
fil_print_orphaned_tablespaces(void)
/*================================*/
{
- fil_system_t* system = fil_system;
+ fil_system_t* system = fil_system;
fil_space_t* space;
mutex_enter(&(system->mutex));
@@ -3193,7 +3191,7 @@ fil_print_orphaned_tablespaces(void)
space = UT_LIST_GET_FIRST(system->space_list);
while (space) {
- if (space->purpose == FIL_TABLESPACE && space->id != 0
+ if (space->purpose == FIL_TABLESPACE && space->id != 0
&& !space->mark) {
fputs("InnoDB: Warning: tablespace ", stderr);
ut_print_filename(stderr, space->name);
@@ -3204,7 +3202,7 @@ fil_print_orphaned_tablespaces(void)
space = UT_LIST_GET_NEXT(space_list, space);
}
- mutex_exit(&(system->mutex));
+ mutex_exit(&(system->mutex));
}
/***********************************************************************
@@ -3328,7 +3326,7 @@ fil_space_for_table_exists_in_mem(
0 == strcmp(namespace->name, path));
if (space && space == namespace) {
/* Found */
-
+
if (mark_space) {
space->mark = TRUE;
}
@@ -3340,16 +3338,16 @@ fil_space_for_table_exists_in_mem(
}
if (!print_error_if_does_not_exist) {
-
+
mem_free(path);
mutex_exit(&(system->mutex));
-
+
return(FALSE);
}
if (space == NULL) {
if (namespace == NULL) {
- ut_print_timestamp(stderr);
+ ut_print_timestamp(stderr);
fputs(" InnoDB: Error: table ", stderr);
ut_print_filename(stderr, name);
fprintf(stderr, "\n"
@@ -3361,7 +3359,7 @@ fil_space_for_table_exists_in_mem(
"InnoDB: table still exists in the InnoDB internal data dictionary.\n",
(ulong) id);
} else {
- ut_print_timestamp(stderr);
+ ut_print_timestamp(stderr);
fputs(" InnoDB: Error: table ", stderr);
ut_print_filename(stderr, name);
fprintf(stderr, "\n"
@@ -3443,7 +3441,7 @@ fil_get_space_id_for_table(
0 == strcmp(namespace->name, path));
if (namespace) {
id = namespace->id;
- }
+ }
mem_free(path);
@@ -3492,11 +3490,11 @@ fil_extend_space_to_desired_size(
*actual_size = space->size;
- mutex_exit(&(system->mutex));
+ mutex_exit(&(system->mutex));
return(TRUE);
}
-
+
node = UT_LIST_GET_LAST(space->chain);
fil_node_prepare_for_io(node, system, space);
@@ -3520,7 +3518,7 @@ fil_extend_space_to_desired_size(
/ (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE));
offset_low = ((start_page_no - file_start_page_no)
% (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE)))
- * UNIV_PAGE_SIZE;
+ * UNIV_PAGE_SIZE;
#ifdef UNIV_HOTBACKUP
success = os_file_write(node->name, node->handle, buf,
offset_low, offset_high,
@@ -3540,7 +3538,7 @@ fil_extend_space_to_desired_size(
} else {
/* Let us measure the size of the file to determine
how much we were able to extend it */
-
+
n_pages = ((ulint)
(os_file_get_size_as_iblonglong(node->handle)
/ UNIV_PAGE_SIZE)) - node->size;
@@ -3573,9 +3571,9 @@ fil_extend_space_to_desired_size(
#endif /* !UNIV_HOTBACKUP */
/*
- printf("Extended %s to %lu, actual size %lu pages\n", space->name,
- size_after_extend, *actual_size); */
- mutex_exit(&(system->mutex));
+ printf("Extended %s to %lu, actual size %lu pages\n", space->name,
+ size_after_extend, *actual_size); */
+ mutex_exit(&(system->mutex));
fil_flush(space_id);
@@ -3593,7 +3591,7 @@ void
fil_extend_tablespaces_to_stored_len(void)
/*======================================*/
{
- fil_system_t* system = fil_system;
+ fil_system_t* system = fil_system;
fil_space_t* space;
byte* buf;
ulint actual_size;
@@ -3608,11 +3606,11 @@ fil_extend_tablespaces_to_stored_len(voi
space = UT_LIST_GET_FIRST(system->space_list);
while (space) {
- ut_a(space->purpose == FIL_TABLESPACE);
+ ut_a(space->purpose == FIL_TABLESPACE);
mutex_exit(&(system->mutex)); /* no need to protect with a
- mutex, because this is a single-
- threaded operation */
+ mutex, because this is a
+ single-threaded operation */
error = fil_read(TRUE, space->id, 0, 0, UNIV_PAGE_SIZE, buf,
NULL);
ut_a(error == DB_SUCCESS);
@@ -3628,7 +3626,7 @@ fil_extend_tablespaces_to_stored_len(voi
"InnoDB: size after extension %lu pages\n"
"InnoDB: Check that you have free disk space and retry!\n", space->name,
size_in_header, actual_size);
- exit(1);
+ exit(1);
}
mutex_enter(&(system->mutex));
@@ -3673,7 +3671,7 @@ fil_space_reserve_free_extents(
space->n_reserved_extents += n_to_reserve;
success = TRUE;
}
-
+
mutex_exit(&(system->mutex));
return(success);
@@ -3699,9 +3697,9 @@ fil_space_release_free_extents(
ut_a(space);
ut_a(space->n_reserved_extents >= n_reserved);
-
+
space->n_reserved_extents -= n_reserved;
-
+
mutex_exit(&(system->mutex));
}
@@ -3723,11 +3721,11 @@ fil_space_get_n_reserved_extents(
mutex_enter(&(system->mutex));
HASH_SEARCH(hash, system->spaces, id, space, space->id == id);
-
+
ut_a(space);
n = space->n_reserved_extents;
-
+
mutex_exit(&(system->mutex));
return(n);
@@ -3754,7 +3752,7 @@ fil_node_prepare_for_io(
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(system->mutex)));
#endif /* UNIV_SYNC_DEBUG */
-
+
if (system->n_open > system->max_n_open + 5) {
ut_print_timestamp(stderr);
fprintf(stderr,
@@ -3771,7 +3769,7 @@ fil_node_prepare_for_io(
}
if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE
- && space->id != 0) {
+ && space->id != 0) {
/* The node is in the LRU list, remove it */
ut_a(UT_LIST_GET_LEN(system->LRU) > 0);
@@ -3802,7 +3800,7 @@ fil_node_complete_io(
#endif /* UNIV_SYNC_DEBUG */
ut_a(node->n_pending > 0);
-
+
node->n_pending--;
if (type == OS_FILE_WRITE) {
@@ -3817,7 +3815,7 @@ fil_node_complete_io(
node->space);
}
}
-
+
if (node->n_pending == 0 && node->space->purpose == FIL_TABLESPACE
&& node->space->id != 0) {
/* The node must be put back to the LRU list */
@@ -3892,13 +3890,13 @@ fil_io(
ibool ret;
ulint is_log;
ulint wake_later;
-
+
is_log = type & OS_FILE_LOG;
type = type & ~OS_FILE_LOG;
wake_later = type & OS_AIO_SIMULATED_WAKE_LATER;
type = type & ~OS_AIO_SIMULATED_WAKE_LATER;
-
+
ut_ad(byte_offset < UNIV_PAGE_SIZE);
ut_ad(buf);
ut_ad(len > 0);
@@ -3924,17 +3922,17 @@ fil_io(
mode = OS_AIO_NORMAL;
}
- if (type == OS_FILE_READ) {
- srv_data_read+= len;
- } else if (type == OS_FILE_WRITE) {
- srv_data_written+= len;
- }
+ if (type == OS_FILE_READ) {
+ srv_data_read+= len;
+ } else if (type == OS_FILE_WRITE) {
+ srv_data_written+= len;
+ }
/* Reserve the fil_system mutex and make sure that we can open at
least one file while holding it, if the file is not already open */
fil_mutex_enter_and_prepare_for_io(space_id);
-
+
HASH_SEARCH(hash, system->spaces, space_id, space,
space->id == space_id);
if (!space) {
@@ -3958,7 +3956,7 @@ fil_io(
if (node == NULL) {
fil_report_invalid_page_access(block_offset, space_id,
space->name, byte_offset, len, type);
-
+
ut_error;
}
@@ -3976,15 +3974,15 @@ fil_io(
block_offset -= node->size;
node = UT_LIST_GET_NEXT(chain, node);
}
- }
-
+ }
+
/* Open file if closed */
fil_node_prepare_for_io(node, system, space);
/* Check that at least the start offset is within the bounds of a
single-table tablespace */
if (space->purpose == FIL_TABLESPACE && space->id != 0
- && node->size <= block_offset) {
+ && node->size <= block_offset) {
fil_report_invalid_page_access(block_offset, space_id,
space->name, byte_offset, len, type);
@@ -4002,7 +4000,7 @@ fil_io(
+ byte_offset;
ut_a(node->size - block_offset >=
- (byte_offset + len + (UNIV_PAGE_SIZE - 1)) / UNIV_PAGE_SIZE);
+ (byte_offset + len + (UNIV_PAGE_SIZE - 1)) / UNIV_PAGE_SIZE);
/* Do aio */
@@ -4028,7 +4026,7 @@ fil_io(
if (mode == OS_AIO_SYNC) {
/* The i/o operation is already completed when we return from
os_aio: */
-
+
mutex_enter(&(system->mutex));
fil_node_complete_io(node, system, type);
@@ -4107,21 +4105,21 @@ void
fil_aio_wait(
/*=========*/
ulint segment) /* in: the number of the segment in the aio
- array to wait for */
+ array to wait for */
{
fil_system_t* system = fil_system;
- ibool ret;
+ ibool ret;
fil_node_t* fil_node;
void* message;
ulint type;
-
+
ut_ad(fil_validate());
if (os_aio_use_native_aio) {
srv_set_io_thread_op_info(segment, "native aio handle");
#ifdef WIN_ASYNC_IO
ret = os_aio_windows_handle(segment, 0, &fil_node,
- &message, &type);
+ &message, &type);
#elif defined(POSIX_ASYNC_IO)
ret = os_aio_posix_handle(segment, &fil_node, &message);
#else
@@ -4132,9 +4130,9 @@ fil_aio_wait(
srv_set_io_thread_op_info(segment, "simulated aio handle");
ret = os_aio_simulated_handle(segment, &fil_node,
- &message, &type);
+ &message, &type);
}
-
+
ut_a(ret);
srv_set_io_thread_op_info(segment, "complete io for fil node");
@@ -4179,7 +4177,7 @@ fil_flush(
ib_longlong old_mod_counter;
mutex_enter(&(system->mutex));
-
+
HASH_SEARCH(hash, system->spaces, space_id, space,
space->id == space_id);
if (!space || space->is_being_deleted) {
@@ -4212,7 +4210,7 @@ fil_flush(
goto skip_flush;
}
#endif
-retry:
+retry:
if (node->n_pending_flushes > 0) {
/* We want to avoid calling os_file_flush() on
the file twice at the same time, because we do
@@ -4242,7 +4240,7 @@ retry:
/* fprintf(stderr, "Flushing to file %s\n",
node->name); */
- os_file_flush(file);
+ os_file_flush(file);
mutex_enter(&(system->mutex));
@@ -4252,7 +4250,7 @@ skip_flush:
node->flush_counter = old_mod_counter;
if (space->is_in_unflushed_spaces
- && fil_space_is_flushed(space)) {
+ && fil_space_is_flushed(space)) {
space->is_in_unflushed_spaces = FALSE;
@@ -4270,7 +4268,7 @@ skip_flush:
}
node = UT_LIST_GET_NEXT(chain, node);
- }
+ }
space->n_pending_flushes--;
@@ -4296,8 +4294,8 @@ fil_flush_file_spaces(
while (space) {
if (space->purpose == purpose && !space->is_being_deleted) {
- space->n_pending_flushes++; /* prevent dropping of the
- space while we are
+ space->n_pending_flushes++; /* prevent dropping of
+ the space while we are
flushing */
mutex_exit(&(system->mutex));
@@ -4309,7 +4307,7 @@ fil_flush_file_spaces(
}
space = UT_LIST_GET_NEXT(unflushed_spaces, space);
}
-
+
mutex_exit(&(system->mutex));
}
@@ -4320,13 +4318,13 @@ ibool
fil_validate(void)
/*==============*/
/* out: TRUE if ok */
-{
+{
fil_system_t* system = fil_system;
fil_space_t* space;
fil_node_t* fil_node;
ulint n_open = 0;
ulint i;
-
+
mutex_enter(&(system->mutex));
/* Look for spaces in the hash table */
@@ -4334,9 +4332,9 @@ fil_validate(void)
for (i = 0; i < hash_get_n_cells(system->spaces); i++) {
space = HASH_GET_FIRST(system->spaces, i);
-
+
while (space != NULL) {
- UT_LIST_VALIDATE(chain, fil_node_t, space->chain);
+ UT_LIST_VALIDATE(chain, fil_node_t, space->chain);
fil_node = UT_LIST_GET_FIRST(space->chain);
@@ -4368,7 +4366,7 @@ fil_validate(void)
fil_node = UT_LIST_GET_NEXT(LRU, fil_node);
}
-
+
mutex_exit(&(system->mutex));
return(TRUE);
@@ -4411,13 +4409,13 @@ Sets the file page type. */
void
fil_page_set_type(
/*==============*/
- byte* page, /* in: file page */
+ byte* page, /* in: file page */
ulint type) /* in: type */
{
ut_ad(page);
mach_write_to_2(page + FIL_PAGE_TYPE, type);
-}
+}
/*************************************************************************
Gets the file page type. */
@@ -4427,7 +4425,7 @@ fil_page_get_type(
/*==============*/
/* out: type; NOTE that if the type has not been
written to page, the return value not defined */
- byte* page) /* in: file page */
+ byte* page) /* in: file page */
{
ut_ad(page);
--- 1.36.5.1/innobase/ibuf/ibuf0ibuf.c 2006-08-10 15:07:34 +04:00
+++ 1.46/storage/innobase/ibuf/ibuf0ibuf.c 2006-08-10 15:07:34 +04:00
@@ -29,7 +29,7 @@ Created 7/19/1997 Heikki Tuuri
#include "log0recv.h"
#include "que0que.h"
-/* STRUCTURE OF AN INSERT BUFFER RECORD
+/* STRUCTURE OF AN INSERT BUFFER RECORD
In versions < 4.1.x:
@@ -140,11 +140,11 @@ access order rules. */
/* The insert buffer control structure */
ibuf_t* ibuf = NULL;
-static
-ulint ibuf_rnd = 986058871;
+static ulint ibuf_rnd = 986058871;
ulint ibuf_flush_count = 0;
+#ifdef UNIV_IBUF_DEBUG
/* Dimensions for the ibuf_count array */
#define IBUF_COUNT_N_SPACES 500
#define IBUF_COUNT_N_PAGES 2000
@@ -153,6 +153,7 @@ ulint ibuf_flush_count = 0;
static ulint* ibuf_counts[IBUF_COUNT_N_SPACES];
static ibool ibuf_counts_inited = FALSE;
+#endif
/* The start address for an insert buffer bitmap page bitmap */
#define IBUF_BITMAP PAGE_DATA
@@ -315,6 +316,7 @@ ibuf_tree_root_get(
return(page);
}
+#ifdef UNIV_IBUF_DEBUG
/**********************************************************************
Gets the ibuf count for a given page. */
@@ -339,7 +341,6 @@ ibuf_count_get(
/**********************************************************************
Sets the ibuf count for a given page. */
-#ifdef UNIV_IBUF_DEBUG
static
void
ibuf_count_set(
@@ -369,14 +370,14 @@ ibuf_init_at_db_start(void)
/* Note that also a pessimistic delete can sometimes make a B-tree
grow in size, as the references on the upper levels of the tree can
change */
-
+
ibuf->max_size = buf_pool_get_curr_size() / UNIV_PAGE_SIZE
/ IBUF_POOL_SIZE_PER_MAX_SIZE;
ibuf->meter = IBUF_THRESHOLD + 1;
UT_LIST_INIT(ibuf->data_list);
- ibuf->size = 0;
+ ibuf->size = 0;
#ifdef UNIV_IBUF_DEBUG
{
@@ -390,23 +391,18 @@ ibuf_init_at_db_start(void)
ibuf_count_set(i, j, 0);
}
}
- }
-#endif
- mutex_create(&ibuf_pessimistic_insert_mutex);
- mutex_set_level(&ibuf_pessimistic_insert_mutex,
- SYNC_IBUF_PESS_INSERT_MUTEX);
- mutex_create(&ibuf_mutex);
-
- mutex_set_level(&ibuf_mutex, SYNC_IBUF_MUTEX);
+ ibuf_counts_inited = TRUE;
+ }
+#endif
+ mutex_create(&ibuf_pessimistic_insert_mutex,
+ SYNC_IBUF_PESS_INSERT_MUTEX);
- mutex_create(&ibuf_bitmap_mutex);
+ mutex_create(&ibuf_mutex, SYNC_IBUF_MUTEX);
- mutex_set_level(&ibuf_bitmap_mutex, SYNC_IBUF_BITMAP_MUTEX);
+ mutex_create(&ibuf_bitmap_mutex, SYNC_IBUF_BITMAP_MUTEX);
fil_ibuf_init_at_db_start();
-
- ibuf_counts_inited = TRUE;
}
/**********************************************************************
@@ -427,7 +423,7 @@ ibuf_data_sizes_update(
#endif /* UNIV_SYNC_DEBUG */
old_size = data->size;
-
+
data->free_list_len = flst_get_len(root + PAGE_HEADER
+ PAGE_BTR_IBUF_FREE_LIST, mtr);
@@ -473,7 +469,7 @@ ibuf_data_init_for_space(
dict_table_t* table;
dict_index_t* index;
ulint n_used;
-
+
ut_a(space == 0);
#ifdef UNIV_LOG_DEBUG
@@ -499,11 +495,11 @@ ibuf_data_init_for_space(
fseg_n_reserved_pages(header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER,
&n_used, &mtr);
ibuf_enter();
-
+
ut_ad(n_used >= 2);
data->seg_size = n_used;
-
+
root = buf_page_get(space, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH,
&mtr);
#ifdef UNIV_SYNC_DEBUG
@@ -514,7 +510,7 @@ ibuf_data_init_for_space(
data->n_inserts = 0;
data->n_merges = 0;
data->n_merged_recs = 0;
-
+
ibuf_data_sizes_update(data, root, &mtr);
/*
if (!data->empty) {
@@ -533,7 +529,7 @@ ibuf_data_init_for_space(
sprintf(buf, "SYS_IBUF_TABLE_%lu", (ulong) space);
/* use old-style record format for the insert buffer */
- table = dict_mem_table_create(buf, space, 2, FALSE);
+ table = dict_mem_table_create(buf, space, 2, 0);
dict_mem_table_add_col(table, "PAGE_NO", DATA_BINARY, 0, 0, 0);
dict_mem_table_add_col(table, "TYPES", DATA_BINARY, 0, 0, 0);
@@ -545,8 +541,8 @@ ibuf_data_init_for_space(
index = dict_mem_index_create(buf, "CLUST_IND", space,
DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF,2);
- dict_mem_index_add_field(index, "PAGE_NO", 0, 0);
- dict_mem_index_add_field(index, "TYPES", 0, 0);
+ dict_mem_index_add_field(index, "PAGE_NO", 0);
+ dict_mem_index_add_field(index, "TYPES", 0);
index->id = ut_dulint_add(DICT_IBUF_ID_MIN, space);
@@ -574,18 +570,18 @@ ibuf_bitmap_page_init(
{
ulint bit_offset;
ulint byte_offset;
- ulint i;
/* Write all zeros to the bitmap */
bit_offset = XDES_DESCRIBED_PER_PAGE * IBUF_BITS_PER_PAGE;
- byte_offset = bit_offset / 8 + 1;
+ byte_offset = bit_offset / 8 + 1; /* better: (bit_offset + 7) / 8 */
- for (i = IBUF_BITMAP; i < IBUF_BITMAP + byte_offset; i++) {
+ fil_page_set_type(page, FIL_PAGE_IBUF_BITMAP);
- *(page + i) = (byte)0;
- }
+ memset(page + IBUF_BITMAP, 0, byte_offset);
+
+ /* The remaining area (up to the page trailer) is uninitialized. */
mlog_write_initial_log_record(page, MLOG_IBUF_BITMAP_INIT, mtr);
}
@@ -621,8 +617,9 @@ ibuf_bitmap_page_get_bits(
page_t* page, /* in: bitmap page */
ulint page_no,/* in: page whose bits to get */
ulint bit, /* in: IBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ... */
- mtr_t* mtr __attribute__((unused))) /* in: mtr containing an x-latch
- to the bitmap page */
+ mtr_t* mtr __attribute__((unused))) /* in: mtr containing an
+ x-latch to the bitmap
+ page */
{
ulint byte_offset;
ulint bit_offset;
@@ -630,12 +627,14 @@ ibuf_bitmap_page_get_bits(
ulint value;
ut_ad(bit < IBUF_BITS_PER_PAGE);
- ut_ad(IBUF_BITS_PER_PAGE % 2 == 0);
+#if IBUF_BITS_PER_PAGE % 2
+# error "IBUF_BITS_PER_PAGE % 2 != 0"
+#endif
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX));
bit_offset = (page_no % XDES_DESCRIBED_PER_PAGE) * IBUF_BITS_PER_PAGE
- + bit;
+ + bit;
byte_offset = bit_offset / 8;
bit_offset = bit_offset % 8;
@@ -648,7 +647,7 @@ ibuf_bitmap_page_get_bits(
if (bit == IBUF_BITMAP_FREE) {
ut_ad(bit_offset + 1 < 8);
-
+
value = value * 2 + ut_bit_get_nth(map_byte, bit_offset + 1);
}
@@ -672,15 +671,18 @@ ibuf_bitmap_page_set_bits(
ulint map_byte;
ut_ad(bit < IBUF_BITS_PER_PAGE);
- ut_ad(IBUF_BITS_PER_PAGE % 2 == 0);
+#if IBUF_BITS_PER_PAGE % 2
+# error "IBUF_BITS_PER_PAGE % 2 != 0"
+#endif
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX));
#ifdef UNIV_IBUF_DEBUG
ut_a((bit != IBUF_BITMAP_BUFFERED) || (val != FALSE)
- || (0 == ibuf_count_get(buf_frame_get_space_id(page), page_no)));
+ || (0 == ibuf_count_get(buf_frame_get_space_id(page),
+ page_no)));
#endif
bit_offset = (page_no % XDES_DESCRIBED_PER_PAGE) * IBUF_BITS_PER_PAGE
- + bit;
+ + bit;
byte_offset = bit_offset / 8;
bit_offset = bit_offset % 8;
@@ -692,14 +694,14 @@ ibuf_bitmap_page_set_bits(
if (bit == IBUF_BITMAP_FREE) {
ut_ad(bit_offset + 1 < 8);
ut_ad(val <= 3);
-
+
map_byte = ut_bit_set_nth(map_byte, bit_offset, val / 2);
map_byte = ut_bit_set_nth(map_byte, bit_offset + 1, val % 2);
} else {
ut_ad(val <= 1);
map_byte = ut_bit_set_nth(map_byte, bit_offset, val);
}
-
+
mlog_write_ulint(page + IBUF_BITMAP + byte_offset, map_byte,
MLOG_1BYTE, mtr);
}
@@ -715,8 +717,8 @@ ibuf_bitmap_page_no_calc(
ulint page_no) /* in: tablespace page number */
{
return(FSP_IBUF_BITMAP_OFFSET
- + XDES_DESCRIBED_PER_PAGE
- * (page_no / XDES_DESCRIBED_PER_PAGE));
+ + XDES_DESCRIBED_PER_PAGE
+ * (page_no / XDES_DESCRIBED_PER_PAGE));
}
/************************************************************************
@@ -779,7 +781,7 @@ ibuf_set_free_bits_low(
"Setting page no %lu free bits to %lu should be %lu\n",
buf_frame_get_page_no(page), val,
ibuf_index_page_calc_free(page)); */
-
+
ut_a(val <= ibuf_index_page_calc_free(page));
#endif
ibuf_bitmap_page_set_bits(bitmap_page, buf_frame_get_page_no(page),
@@ -818,7 +820,7 @@ ibuf_set_free_bits(
}
mtr_start(&mtr);
-
+
bitmap_page = ibuf_bitmap_get_map_page(buf_frame_get_space_id(page),
buf_frame_get_page_no(page), &mtr);
@@ -844,7 +846,7 @@ ibuf_set_free_bits(
ibuf_index_page_calc_free(page)); */
ut_a(val <= ibuf_index_page_calc_free(page));
-#endif
+#endif
ibuf_bitmap_page_set_bits(bitmap_page, buf_frame_get_page_no(page),
IBUF_BITMAP_FREE, val, &mtr);
mtr_commit(&mtr);
@@ -931,7 +933,7 @@ ibuf_update_free_bits_for_two_pages_low(
performed by another OS thread. */
mutex_enter(&ibuf_bitmap_mutex);
-
+
state = ibuf_index_page_calc_free(page1);
ibuf_set_free_bits_low(index->type, page1, state, mtr);
@@ -1025,7 +1027,7 @@ ibuf_page_low(
return(FALSE);
}
-#endif
+#endif
if (ibuf_fixed_addr_page(space, page_no)) {
return(TRUE);
@@ -1119,13 +1121,18 @@ ibuf_dummy_index_create(
{
dict_table_t* table;
dict_index_t* index;
+
table = dict_mem_table_create("IBUF_DUMMY",
- DICT_HDR_SPACE, n, comp);
+ DICT_HDR_SPACE, n, comp ? DICT_TF_COMPACT : 0);
+
index = dict_mem_index_create("IBUF_DUMMY", "IBUF_DUMMY",
- DICT_HDR_SPACE, 0, n);
+ DICT_HDR_SPACE, 0, n);
+
index->table = table;
+
/* avoid ut_ad(index->cached) in dict_index_get_n_unique_in_tree */
index->cached = TRUE;
+
return(index);
}
/************************************************************************
@@ -1133,7 +1140,7 @@ Add a column to the dummy index */
static
void
ibuf_dummy_index_add_col(
-/*====================*/
+/*=====================*/
dict_index_t* index, /* in: dummy index */
dtype_t* type, /* in: the data type of the column */
ulint len) /* in: length of the column */
@@ -1145,7 +1152,7 @@ ibuf_dummy_index_add_col(
dtype_get_len(type),
dtype_get_prec(type));
dict_index_add_col(index,
- dict_table_get_nth_col(index->table, i), 0, len);
+ dict_table_get_nth_col(index->table, i), len);
}
/************************************************************************
Deallocates a dummy index for inserting a record to a non-clustered index.
@@ -1153,7 +1160,7 @@ Deallocates a dummy index for inserting
static
void
ibuf_dummy_index_free(
-/*====================*/
+/*==================*/
dict_index_t* index) /* in: dummy index */
{
dict_table_t* table = index->table;
@@ -1375,7 +1382,7 @@ ibuf_entry_build(
byte* buf;
byte* buf2;
ulint i;
-
+
/* Starting from 4.1.x, we have to build a tuple whose
(1) first field is the space id,
(2) the second field a single marker byte (0) to tell that this
@@ -1464,7 +1471,7 @@ ibuf_entry_build(
dtuple_set_types_binary(tuple, n_fields + 4);
return(tuple);
-}
+}
/*************************************************************************
Builds a search tuple used to search buffered inserts for an index page.
@@ -1481,7 +1488,7 @@ ibuf_search_tuple_build(
dtuple_t* tuple;
dfield_t* field;
byte* buf;
-
+
ut_a(space == 0);
ut_a(trx_doublewrite_must_reset_space_ids);
ut_a(!trx_sys_multiple_tablespace_format);
@@ -1518,7 +1525,7 @@ ibuf_new_search_tuple_build(
dtuple_t* tuple;
dfield_t* field;
byte* buf;
-
+
ut_a(trx_sys_multiple_tablespace_format);
tuple = dtuple_create(heap, 3);
@@ -1634,7 +1641,7 @@ ibuf_add_free_page(
/* Acquire the fsp latch before the ibuf header, obeying the latching
order */
mtr_x_lock(fil_space_get_latch(space), &mtr);
-
+
header_page = ibuf_header_page_get(space, &mtr);
/* Allocate a new page: NOTE that if the page has been a part of a
@@ -1671,9 +1678,10 @@ ibuf_add_free_page(
/* Add the page to the free list and update the ibuf size data */
flst_add_last(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
- page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr);
+ page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr);
- fil_page_set_type(page, FIL_PAGE_IBUF_FREE_LIST);
+ mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_IBUF_FREE_LIST,
+ MLOG_2BYTES, &mtr);
ibuf_data->seg_size++;
ibuf_data->free_list_len++;
@@ -1718,7 +1726,7 @@ ibuf_remove_free_page(
/* Acquire the fsp latch before the ibuf header, obeying the latching
order */
mtr_x_lock(fil_space_get_latch(space), &mtr);
-
+
header_page = ibuf_header_page_get(space, &mtr);
/* Prevent pessimistic inserts to insert buffer trees for a while */
@@ -1733,16 +1741,16 @@ ibuf_remove_free_page(
mutex_exit(&ibuf_mutex);
ibuf_exit();
-
+
mutex_exit(&ibuf_pessimistic_insert_mutex);
mtr_commit(&mtr);
return;
}
-
+
mtr_start(&mtr2);
-
+
root = ibuf_tree_root_get(ibuf_data, space, &mtr2);
page_no = flst_get_last(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
@@ -1752,32 +1760,32 @@ ibuf_remove_free_page(
/* NOTE that we must release the latch on the ibuf tree root
because in fseg_free_page we access level 1 pages, and the root
is a level 2 page. */
-
+
mtr_commit(&mtr2);
mutex_exit(&ibuf_mutex);
ibuf_exit();
-
+
/* Since pessimistic inserts were prevented, we know that the
page is still in the free list. NOTE that also deletes may take
pages from the free list, but they take them from the start, and
the free list was so long that they cannot have taken the last
page from it. */
-
+
fseg_free_page(header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER,
space, page_no, &mtr);
#ifdef UNIV_DEBUG_FILE_ACCESSES
buf_page_reset_file_page_was_freed(space, page_no);
#endif
ibuf_enter();
-
+
mutex_enter(&ibuf_mutex);
root = ibuf_tree_root_get(ibuf_data, space, &mtr);
ut_ad(page_no == flst_get_last(root + PAGE_HEADER
+ PAGE_BTR_IBUF_FREE_LIST, &mtr)
- .page);
+ .page);
page = buf_page_get(space, page_no, RW_X_LATCH, &mtr);
@@ -1786,13 +1794,13 @@ ibuf_remove_free_page(
#endif /* UNIV_SYNC_DEBUG */
/* Remove the page from the free list and update the ibuf size data */
-
+
flst_remove(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
- page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr);
+ page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr);
ibuf_data->seg_size--;
ibuf_data->free_list_len--;
-
+
mutex_exit(&ibuf_pessimistic_insert_mutex);
/* Set the bit indicating that this page is no more an ibuf tree page
@@ -1815,7 +1823,7 @@ ibuf_remove_free_page(
/***************************************************************************
Frees excess pages from the ibuf free list. This function is called when an OS
thread calls fsp services to allocate a new file segment, or a new page to a
-file segment, and the thread did not own the fsp latch before this call. */
+file segment, and the thread did not own the fsp latch before this call. */
void
ibuf_free_excess_pages(
@@ -1826,7 +1834,7 @@ ibuf_free_excess_pages(
ulint i;
if (space != 0) {
- fprintf(stderr,
+ fprintf(stderr,
"InnoDB: Error: calling ibuf_free_excess_pages for space %lu\n", (ulong) space);
return;
}
@@ -1836,7 +1844,7 @@ ibuf_free_excess_pages(
#endif /* UNIV_SYNC_DEBUG */
ut_ad(rw_lock_get_x_lock_count(fil_space_get_latch(space)) == 1);
ut_ad(!ibuf_inside());
-
+
/* NOTE: We require that the thread did not own the latch before,
because then we know that we can obey the correct latching order
for ibuf latches */
@@ -1934,7 +1942,7 @@ ibuf_get_merge_page_nos(
n_pages = 0;
prev_page_no = 0;
prev_space_id = 0;
-
+
/* Go backwards from the first rec until we reach the border of the
'merge area', or the page start or the limit of storeable pages is
reached */
@@ -1945,14 +1953,14 @@ ibuf_get_merge_page_nos(
rec_space_id = ibuf_rec_get_space(rec);
if (rec_space_id != first_space_id
- || rec_page_no / IBUF_MERGE_AREA
- != first_page_no / IBUF_MERGE_AREA) {
+ || rec_page_no / IBUF_MERGE_AREA
+ != first_page_no / IBUF_MERGE_AREA) {
- break;
+ break;
}
-
+
if (rec_page_no != prev_page_no
- || rec_space_id != prev_space_id) {
+ || rec_space_id != prev_space_id) {
n_pages++;
}
@@ -1972,7 +1980,7 @@ ibuf_get_merge_page_nos(
prev_space_id = 0;
sum_volumes = 0;
volume_for_page = 0;
-
+
while (*n_stored < limit) {
if (page_rec_is_supremum(rec)) {
/* When no more records available, mark this with
@@ -1989,19 +1997,19 @@ ibuf_get_merge_page_nos(
ut_a(*n_stored < IBUF_MAX_N_PAGES_MERGED);
#endif
if ((rec_space_id != prev_space_id
- || rec_page_no != prev_page_no)
- && (prev_space_id != 0 || prev_page_no != 0)) {
+ || rec_page_no != prev_page_no)
+ && (prev_space_id != 0 || prev_page_no != 0)) {
if ((prev_page_no == first_page_no
- && prev_space_id == first_space_id)
- || contract
- || (volume_for_page >
- ((IBUF_MERGE_THRESHOLD - 1)
- * 4 * UNIV_PAGE_SIZE
- / IBUF_PAGE_SIZE_PER_FREE_SPACE)
- / IBUF_MERGE_THRESHOLD)) {
+ && prev_space_id == first_space_id)
+ || contract
+ || (volume_for_page >
+ ((IBUF_MERGE_THRESHOLD - 1)
+ * 4 * UNIV_PAGE_SIZE
+ / IBUF_PAGE_SIZE_PER_FREE_SPACE)
+ / IBUF_MERGE_THRESHOLD)) {
- space_ids[*n_stored] = prev_space_id;
+ space_ids[*n_stored] = prev_space_id;
space_versions[*n_stored]
= fil_space_get_version(
prev_space_id);
@@ -2013,10 +2021,10 @@ ibuf_get_merge_page_nos(
}
if (rec_space_id != first_space_id
- || rec_page_no / IBUF_MERGE_AREA
- != first_page_no / IBUF_MERGE_AREA) {
+ || rec_page_no / IBUF_MERGE_AREA
+ != first_page_no / IBUF_MERGE_AREA) {
- break;
+ break;
}
volume_for_page = 0;
@@ -2031,7 +2039,7 @@ ibuf_get_merge_page_nos(
rec_volume = ibuf_rec_get_volume(rec);
volume_for_page += rec_volume;
-
+
prev_page_no = rec_page_no;
prev_space_id = rec_space_id;
@@ -2078,7 +2086,7 @@ loop:
mutex_enter(&ibuf_mutex);
- ut_ad(ibuf_validate_low());
+ ut_ad(ibuf_validate_low());
/* Choose an ibuf tree at random (though there really is only one tree
in the current implementation) */
@@ -2093,15 +2101,15 @@ loop:
for (;;) {
if (!data->empty) {
all_trees_empty = FALSE;
-
+
if (rnd_pos < data->size) {
break;
}
-
+
rnd_pos -= data->size;
}
-
+
data = UT_LIST_GET_NEXT(data_list, data);
if (data == NULL) {
@@ -2110,7 +2118,7 @@ loop:
return(0);
}
-
+
data = UT_LIST_GET_FIRST(ibuf->data_list);
}
}
@@ -2124,7 +2132,7 @@ loop:
mtr_start(&mtr);
ibuf_enter();
-
+
/* Open a cursor to a randomly chosen leaf of the tree, at a random
position within the leaf */
@@ -2133,19 +2141,19 @@ loop:
if (0 == page_get_n_recs(btr_pcur_get_page(&pcur))) {
/* This tree is empty */
-
- data->empty = TRUE;
- ibuf_exit();
+ data->empty = TRUE;
- mtr_commit(&mtr);
- btr_pcur_close(&pcur);
+ ibuf_exit();
- mutex_exit(&ibuf_mutex);
+ mtr_commit(&mtr);
+ btr_pcur_close(&pcur);
+
+ mutex_exit(&ibuf_mutex);
- goto loop;
+ goto loop;
}
-
+
mutex_exit(&ibuf_mutex);
sum_sizes = ibuf_get_merge_page_nos(TRUE, btr_pcur_get_rec(&pcur),
@@ -2162,7 +2170,7 @@ loop:
buf_read_ibuf_merge_pages(sync, space_ids, space_versions, page_nos,
n_stored);
*n_pages = n_stored;
-
+
return(sum_sizes + 1);
}
@@ -2201,13 +2209,13 @@ ibuf_contract_for_n_pages(
them */
{
ulint sum_bytes = 0;
- ulint sum_pages = 0;
+ ulint sum_pages = 0;
ulint n_bytes;
ulint n_pag2;
-
+
while (sum_pages < n_pages) {
n_bytes = ibuf_contract_ext(&n_pag2, sync);
-
+
if (n_bytes == 0) {
return(sum_bytes);
}
@@ -2241,7 +2249,7 @@ ibuf_contract_after_insert(
}
sync = FALSE;
-
+
if (ibuf->size >= ibuf->max_size + IBUF_CONTRACT_ON_INSERT_SYNC) {
sync = TRUE;
@@ -2288,7 +2296,7 @@ ibuf_get_volume_buffered(
page_t* prev_page;
ulint next_page_no;
page_t* next_page;
-
+
ut_a(trx_sys_multiple_tablespace_format);
ut_ad((pcur->latch_mode == BTR_MODIFY_PREV)
@@ -2298,7 +2306,7 @@ ibuf_get_volume_buffered(
pcur */
volume = 0;
-
+
rec = btr_pcur_get_rec(pcur);
page = buf_frame_align(rec);
@@ -2312,9 +2320,9 @@ ibuf_get_volume_buffered(
break;
}
-
+
if (page_no != ibuf_rec_get_page_no(rec)
- || space != ibuf_rec_get_space(rec)) {
+ || space != ibuf_rec_get_space(rec)) {
goto count_later;
}
@@ -2325,7 +2333,7 @@ ibuf_get_volume_buffered(
}
/* Look at the previous page */
-
+
prev_page_no = btr_page_get_prev(page, mtr);
if (prev_page_no == FIL_NULL) {
@@ -2334,6 +2342,10 @@ ibuf_get_volume_buffered(
}
prev_page = buf_page_get(0, prev_page_no, RW_X_LATCH, mtr);
+#ifdef UNIV_BTR_DEBUG
+ ut_a(btr_page_get_next(prev_page, mtr)
+ == buf_frame_get_page_no(page));
+#endif /* UNIV_BTR_DEBUG */
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(prev_page, SYNC_TREE_NODE);
@@ -2341,19 +2353,19 @@ ibuf_get_volume_buffered(
rec = page_get_supremum_rec(prev_page);
rec = page_rec_get_prev(rec);
-
+
for (;;) {
if (page_rec_is_infimum(rec)) {
/* We cannot go to yet a previous page, because we
do not have the x-latch on it, and cannot acquire one
because of the latching order: we have to give up */
-
+
return(UNIV_PAGE_SIZE);
}
-
+
if (page_no != ibuf_rec_get_page_no(rec)
- || space != ibuf_rec_get_space(rec)) {
+ || space != ibuf_rec_get_space(rec)) {
goto count_later;
}
@@ -2362,7 +2374,7 @@ ibuf_get_volume_buffered(
rec = page_rec_get_prev(rec);
}
-
+
count_later:
rec = btr_pcur_get_rec(pcur);
@@ -2375,9 +2387,9 @@ count_later:
break;
}
-
+
if (page_no != ibuf_rec_get_page_no(rec)
- || space != ibuf_rec_get_space(rec)) {
+ || space != ibuf_rec_get_space(rec)) {
return(volume);
}
@@ -2388,7 +2400,7 @@ count_later:
}
/* Look at the next page */
-
+
next_page_no = btr_page_get_next(page, mtr);
if (next_page_no == FIL_NULL) {
@@ -2397,6 +2409,10 @@ count_later:
}
next_page = buf_page_get(0, next_page_no, RW_X_LATCH, mtr);
+#ifdef UNIV_BTR_DEBUG
+ ut_a(btr_page_get_prev(next_page, mtr)
+ == buf_frame_get_page_no(page));
+#endif /* UNIV_BTR_DEBUG */
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(next_page, SYNC_TREE_NODE);
@@ -2409,12 +2425,12 @@ count_later:
if (page_rec_is_supremum(rec)) {
/* We give up */
-
+
return(UNIV_PAGE_SIZE);
}
-
+
if (page_no != ibuf_rec_get_page_no(rec)
- || space != ibuf_rec_get_space(rec)) {
+ || space != ibuf_rec_get_space(rec)) {
return(volume);
}
@@ -2445,7 +2461,7 @@ ibuf_update_max_tablespace_id(void)
ibuf_data = fil_space_get_ibuf_data(0);
ibuf_index = ibuf_data->index;
- ut_a(!ibuf_index->table->comp);
+ ut_a(!dict_table_is_comp(ibuf_index->table));
ibuf_enter();
@@ -2465,7 +2481,7 @@ ibuf_update_max_tablespace_id(void)
field = rec_get_nth_field_old(rec, 0, &len);
ut_a(len == 4);
-
+
max_space_id = mach_read_from_4(field);
}
@@ -2515,7 +2531,7 @@ ibuf_insert_low(
ulint bits;
mtr_t mtr;
mtr_t bitmap_mtr;
-
+
ut_a(!(index->type & DICT_CLUSTERED));
ut_ad(dtuple_check_typed(entry));
@@ -2540,7 +2556,7 @@ ibuf_insert_low(
#ifdef UNIV_IBUF_DEBUG
fputs("Ibuf too big\n", stderr);
-#endif
+#endif
/* Use synchronous contract (== TRUE) */
ibuf_contract(TRUE);
@@ -2561,7 +2577,7 @@ ibuf_insert_low(
mutex_exit(&ibuf_mutex);
ibuf_exit();
-
+
mutex_exit(&ibuf_pessimistic_insert_mutex);
err = ibuf_add_free_page(0, ibuf_data);
@@ -2574,7 +2590,7 @@ ibuf_insert_low(
mutex_enter(&ibuf_pessimistic_insert_mutex);
ibuf_enter();
-
+
mutex_enter(&ibuf_mutex);
}
} else {
@@ -2585,12 +2601,12 @@ ibuf_insert_low(
heap = mem_heap_create(512);
- /* Build the entry which contains the space id and the page number as
+ /* Build the entry which contains the space id and the page number as
the first fields and the type information for other fields, and which
will be inserted to the insert buffer. */
- ibuf_entry = ibuf_entry_build(entry, index->table->comp,
- space, page_no, heap);
+ ibuf_entry = ibuf_entry_build(entry, dict_table_is_comp(index->table),
+ space, page_no, heap);
/* Open a cursor to the insert buffer tree to calculate if we can add
the new entry to it without exceeding the free space limit for the
@@ -2607,7 +2623,7 @@ ibuf_insert_low(
#ifdef UNIV_IBUF_DEBUG
ut_a((buffered == 0) || ibuf_count_get(space, page_no));
#endif
- mtr_start(&bitmap_mtr);
+ mtr_start(&bitmap_mtr);
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, &bitmap_mtr);
@@ -2629,16 +2645,16 @@ ibuf_insert_low(
> ibuf_index_page_calc_free_from_bits(bits)) {
mtr_commit(&bitmap_mtr);
- /* It may not fit */
+ /* It may not fit */
err = DB_STRONG_FAIL;
- do_merge = TRUE;
+ do_merge = TRUE;
ibuf_get_merge_page_nos(FALSE, btr_pcur_get_rec(&pcur),
space_ids, space_versions,
page_nos, &n_stored);
goto function_exit;
- }
+ }
/* Set the bitmap bit denoting that the insert buffer contains
buffered entries for this index page, if the bit is not set yet */
@@ -2651,9 +2667,9 @@ ibuf_insert_low(
}
mtr_commit(&bitmap_mtr);
-
+
cursor = btr_pcur_get_btr_cur(&pcur);
-
+
if (mode == BTR_MODIFY_PREV) {
err = btr_cur_optimistic_insert(BTR_NO_LOCKING_FLAG, cursor,
ibuf_entry, &ins_rec,
@@ -2671,7 +2687,7 @@ ibuf_insert_low(
because a pessimistic insert releases the tree x-latch,
which would cause the x-latching of the root after that to
break the latching order. */
-
+
root = ibuf_tree_root_get(ibuf_data, 0, &mtr);
err = btr_cur_pessimistic_insert(BTR_NO_LOCKING_FLAG
@@ -2700,18 +2716,18 @@ function_exit:
ibuf_count_get(space, page_no) + 1);
}
#endif
- if (mode == BTR_MODIFY_TREE) {
+ if (mode == BTR_MODIFY_TREE) {
ut_ad(ibuf_validate_low());
mutex_exit(&ibuf_mutex);
mutex_exit(&ibuf_pessimistic_insert_mutex);
}
-
+
mtr_commit(&mtr);
- btr_pcur_close(&pcur);
+ btr_pcur_close(&pcur);
ibuf_exit();
- mem_heap_free(heap);
+ mem_heap_free(heap);
mutex_enter(&ibuf_mutex);
@@ -2719,13 +2735,13 @@ function_exit:
ibuf_data->empty = FALSE;
ibuf_data->n_inserts++;
}
-
+
mutex_exit(&ibuf_mutex);
- if ((mode == BTR_MODIFY_TREE) && (err == DB_SUCCESS)) {
+ if ((mode == BTR_MODIFY_TREE) && (err == DB_SUCCESS)) {
ibuf_contract_after_insert(entry_size);
}
-
+
if (do_merge) {
#ifdef UNIV_IBUF_DEBUG
ut_a(n_stored <= IBUF_MAX_N_PAGES_MERGED);
@@ -2733,7 +2749,7 @@ function_exit:
buf_read_ibuf_merge_pages(FALSE, space_ids, space_versions,
page_nos, n_stored);
}
-
+
return(err);
}
@@ -2758,19 +2774,20 @@ ibuf_insert(
ut_ad(dtuple_check_typed(entry));
ut_a(!(index->type & DICT_CLUSTERED));
-
+
if (rec_get_converted_size(index, entry)
- >= page_get_free_space_of_empty(index->table->comp) / 2) {
+ >= page_get_free_space_of_empty(
+ dict_table_is_comp(index->table)) / 2) {
return(FALSE);
}
-
+
err = ibuf_insert_low(BTR_MODIFY_PREV, entry, index, space, page_no,
thr);
if (err == DB_FAIL) {
err = ibuf_insert_low(BTR_MODIFY_TREE, entry, index, space,
page_no, thr);
}
-
+
if (err == DB_SUCCESS) {
#ifdef UNIV_IBUF_DEBUG
/* fprintf(stderr, "Ibuf insert for page no %lu of index %s\n",
@@ -2784,7 +2801,7 @@ ibuf_insert(
return(FALSE);
}
}
-
+
/************************************************************************
During merge, inserts to an index page a secondary index entry extracted
from the insert buffer. */
@@ -2807,7 +2824,8 @@ ibuf_insert_to_index_page(
ut_ad(ibuf_inside());
ut_ad(dtuple_check_typed(entry));
- if (UNIV_UNLIKELY(index->table->comp != (ibool)!!page_is_comp(page))) {
+ if (UNIV_UNLIKELY(dict_table_is_comp(index->table)
+ != (ibool)!!page_is_comp(page))) {
fputs(
"InnoDB: Trying to insert a record from the insert buffer to an index page\n"
"InnoDB: but the 'compact' flag does not match!\n", stderr);
@@ -2824,7 +2842,7 @@ ibuf_insert_to_index_page(
dump:
buf_page_print(page);
- dtuple_print(stderr, entry);
+ dtuple_print(stderr, entry);
fputs(
"InnoDB: The table where where this index record belongs\n"
@@ -2837,14 +2855,14 @@ ibuf_insert_to_index_page(
low_match = page_cur_search(page, index, entry,
PAGE_CUR_LE, &page_cur);
-
+
if (low_match == dtuple_get_n_fields(entry)) {
rec = page_cur_get_rec(&page_cur);
-
+
btr_cur_del_unmark_for_ibuf(rec, mtr);
} else {
rec = page_cur_tuple_insert(&page_cur, entry, index, mtr);
-
+
if (rec == NULL) {
/* If the record did not fit, reorganize */
@@ -2870,7 +2888,7 @@ ibuf_insert_to_index_page(
"\nInnoDB: The table where where this index record belongs\n"
"InnoDB: is now probably corrupt. Please run CHECK TABLE on\n"
"InnoDB: that table.\n", stderr);
-
+
bitmap_page = ibuf_bitmap_get_map_page(
buf_frame_get_space_id(page),
buf_frame_get_page_no(page),
@@ -2884,7 +2902,7 @@ ibuf_insert_to_index_page(
fputs(
"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr);
- }
+ }
}
}
}
@@ -2912,7 +2930,7 @@ ibuf_delete_rec(
ibuf_data_t* ibuf_data;
page_t* root;
ulint err;
-
+
ut_ad(ibuf_inside());
success = btr_cur_optimistic_delete(btr_pcur_get_btr_cur(pcur), mtr);
@@ -2927,7 +2945,7 @@ ibuf_delete_rec(
#endif
return(FALSE);
}
-
+
/* We have to resort to a pessimistic delete from ibuf */
btr_pcur_store_position(pcur, mtr);
@@ -2941,7 +2959,7 @@ ibuf_delete_rec(
mutex_enter(&ibuf_mutex);
mtr_start(mtr);
-
+
success = btr_pcur_restore_position(BTR_MODIFY_TREE, pcur, mtr);
if (!success) {
@@ -3048,7 +3066,7 @@ ibuf_merge_or_delete_for_page(
return;
}
-#endif
+#endif
if (ibuf_fixed_addr_page(space, page_no) || fsp_descr_page(page_no)
|| trx_sys_hdr_page(space, page_no)) {
return;
@@ -3100,12 +3118,12 @@ ibuf_merge_or_delete_for_page(
if (!trx_sys_multiple_tablespace_format) {
ut_a(trx_doublewrite_must_reset_space_ids);
- search_tuple = ibuf_search_tuple_build(space, page_no, heap);
+ search_tuple = ibuf_search_tuple_build(space, page_no, heap);
} else {
- search_tuple = ibuf_new_search_tuple_build(space, page_no,
+ search_tuple = ibuf_new_search_tuple_build(space, page_no,
heap);
}
-
+
if (page) {
/* Move the ownership of the x-latch on the page to this OS
thread, so that we can acquire a second x-latch on it. This
@@ -3114,22 +3132,22 @@ ibuf_merge_or_delete_for_page(
block = buf_block_align(page);
rw_lock_x_lock_move_ownership(&(block->lock));
-
+
if (fil_page_get_type(page) != FIL_PAGE_INDEX) {
corruption_noticed = TRUE;
-
+
ut_print_timestamp(stderr);
mtr_start(&mtr);
fputs(" InnoDB: Dump of the ibuf bitmap page:\n",
stderr);
-
+
bitmap_page = ibuf_bitmap_get_map_page(space, page_no,
&mtr);
buf_page_print(bitmap_page);
-
+
mtr_commit(&mtr);
fputs("\nInnoDB: Dump of the page:\n", stderr);
@@ -3166,7 +3184,7 @@ loop:
buf_page_dbg_add_level(page, SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */
}
-
+
/* Position pcur in the insert buffer at the first entry for this
index page */
btr_pcur_open_on_user_rec(ibuf_data->index, search_tuple, PAGE_CUR_GE,
@@ -3184,7 +3202,7 @@ loop:
/* Check if the entry is for this index page */
if (ibuf_rec_get_page_no(ibuf_rec) != page_no
- || ibuf_rec_get_space(ibuf_rec) != space) {
+ || ibuf_rec_get_space(ibuf_rec) != space) {
if (page) {
page_header_reset_last_insert(page, &mtr);
}
@@ -3195,7 +3213,7 @@ loop:
fputs("InnoDB: Discarding record\n ", stderr);
rec_print_old(stderr, ibuf_rec);
fputs("\n from the insert buffer!\n\n", stderr);
- } else if (page) {
+ } else if (page) {
/* Now we have at pcur a record which should be
inserted to the index page; NOTE that the call below
copies pointers to fields in ibuf_rec, and we must
@@ -3205,12 +3223,12 @@ loop:
dulint max_trx_id = page_get_max_trx_id(
buf_frame_align(ibuf_rec));
page_update_max_trx_id(page, max_trx_id);
-
+
entry = ibuf_build_entry_from_ibuf_rec(ibuf_rec,
heap, &dummy_index);
#ifdef UNIV_IBUF_DEBUG
volume += rec_get_converted_size(dummy_index, entry)
- + page_dir_calc_reserved_space(1);
+ + page_dir_calc_reserved_space(1);
ut_a(volume <= 4 * UNIV_PAGE_SIZE
/ IBUF_PAGE_SIZE_PER_FREE_SPACE);
#endif
@@ -3220,7 +3238,7 @@ loop:
}
n_inserts++;
-
+
/* Delete the record from ibuf */
if (ibuf_delete_rec(space, page_no, &pcur, search_tuple,
&mtr)) {
@@ -3232,7 +3250,7 @@ loop:
if (btr_pcur_is_after_last_on_page(&pcur, &mtr)) {
mtr_commit(&mtr);
- btr_pcur_close(&pcur);
+ btr_pcur_close(&pcur);
goto loop;
}
@@ -3271,13 +3289,13 @@ reset_bit:
n_inserts, volume, page_no); */
#endif
mtr_commit(&mtr);
- btr_pcur_close(&pcur);
+ btr_pcur_close(&pcur);
mem_heap_free(heap);
/* Protect our statistics keeping from race conditions */
mutex_enter(&ibuf_mutex);
- ibuf_data->n_merges++;
+ ibuf_data->n_merges++;
ibuf_data->n_merged_recs += n_inserts;
mutex_exit(&ibuf_mutex);
@@ -3325,7 +3343,7 @@ ibuf_delete_for_discarded_space(
cursor positioned at the first entry for this space id */
search_tuple = ibuf_new_search_tuple_build(space, 0, heap);
-
+
n_inserts = 0;
loop:
ibuf_enter();
@@ -3356,7 +3374,7 @@ loop:
page_no = ibuf_rec_get_page_no(ibuf_rec);
n_inserts++;
-
+
/* Delete the record from ibuf */
closed = ibuf_delete_rec(space, page_no, &pcur, search_tuple,
&mtr);
@@ -3371,7 +3389,7 @@ loop:
if (btr_pcur_is_after_last_on_page(&pcur, &mtr)) {
mtr_commit(&mtr);
- btr_pcur_close(&pcur);
+ btr_pcur_close(&pcur);
ibuf_exit();
@@ -3381,12 +3399,12 @@ loop:
leave_loop:
mtr_commit(&mtr);
- btr_pcur_close(&pcur);
+ btr_pcur_close(&pcur);
/* Protect our statistics keeping from race conditions */
mutex_enter(&ibuf_mutex);
- ibuf_data->n_merges++;
+ ibuf_data->n_merges++;
ibuf_data->n_merged_recs += n_inserts;
mutex_exit(&ibuf_mutex);
@@ -3417,12 +3435,12 @@ ibuf_validate_low(void)
#endif /* UNIV_SYNC_DEBUG */
sum_sizes = 0;
-
+
data = UT_LIST_GET_FIRST(ibuf->data_list);
while (data) {
sum_sizes += data->size;
-
+
data = UT_LIST_GET_NEXT(data_list, data);
}
@@ -3465,7 +3483,7 @@ ibuf_is_empty(void)
"InnoDB: run to completion.\n");
}
} else {
- ut_a(data->empty == FALSE);
+ ut_a(data->empty == FALSE);
is_empty = FALSE;
}
@@ -3499,23 +3517,35 @@ ibuf_print(
data = UT_LIST_GET_FIRST(ibuf->data_list);
while (data) {
+ fprintf(file,
+ "Ibuf for space %lu: size %lu, free list len %lu, seg size %lu,",
+ (ulong) data->space, (ulong) data->size,
+ (ulong) data->free_list_len,
+ (ulong) data->seg_size);
+
+ if (data->empty) {
+ fputs(" is empty\n", file);
+ } else {
+ fputs(" is not empty\n", file);
+ }
fprintf(file,
- "Ibuf: size %lu, free list len %lu, seg size %lu,\n"
- "%lu inserts, %lu merged recs, %lu merges\n",
- (ulong) data->size,
- (ulong) data->free_list_len,
- (ulong) data->seg_size,
- (ulong) data->n_inserts,
- (ulong) data->n_merged_recs,
- (ulong) data->n_merges);
+ "Ibuf for space %lu: size %lu, free list len %lu, seg size %lu,\n"
+ "%lu inserts, %lu merged recs, %lu merges\n",
+ (ulong) data->space,
+ (ulong) data->size,
+ (ulong) data->free_list_len,
+ (ulong) data->seg_size,
+ (ulong) data->n_inserts,
+ (ulong) data->n_merged_recs,
+ (ulong) data->n_merges);
#ifdef UNIV_IBUF_DEBUG
for (i = 0; i < IBUF_COUNT_N_PAGES; i++) {
if (ibuf_count_get(data->space, i) > 0) {
fprintf(stderr,
"Ibuf count for page %lu is %lu\n",
- (ulong) i,
- (ulong) ibuf_count_get(data->space, i));
+ (ulong) i,
+ (ulong) ibuf_count_get(data->space, i));
}
}
#endif
| Thread |
|---|
| • bk commit into 5.1 tree (kroki:1.2270) | kroki | 10 Aug |