summaryrefslogtreecommitdiff
path: root/innobase/buf
diff options
context:
space:
mode:
authorunknown <heikki@hundin.mysql.fi>2003-10-13 11:20:19 +0300
committerunknown <heikki@hundin.mysql.fi>2003-10-13 11:20:19 +0300
commitd212ba604b22f8fad80489319a7ddc09d126ba67 (patch)
tree5d5b7191e57ae4eafdff3f6a259ba37729217404 /innobase/buf
parent1862f671606e086c68228903abb64d9727f95b72 (diff)
downloadmariadb-git-d212ba604b22f8fad80489319a7ddc09d126ba67.tar.gz
Many files:
ALTER TABLE ... DISCARD/IMPORT TABLESPACE Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x sql/ha_innodb.cc: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/sql_class.cc: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/sql_parse.cc: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/sql_table.cc: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/ha_innodb.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/handler.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/lex.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/mysql_priv.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/sql_class.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/sql_lex.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/sql_yacc.yy: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/ha/ha0ha.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/ha/hash0hash.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/buf/buf0buf.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/buf/buf0flu.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/buf/buf0lru.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/buf/buf0rea.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/btr/btr0btr.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/btr/btr0sea.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/fil/fil0fil.c: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/include/buf0buf.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/include/ha0ha.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/include/hash0hash.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/include/row0mysql.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/include/buf0buf.ic: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/include/ha0ha.ic: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/include/ibuf0ibuf.ic: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/page/page0page.c: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/row/row0mysql.c: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/row/row0purge.c: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/row/row0uins.c: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/row/row0umod.c: ALTER TABLE ... DISCARD/IMPORT TABLESPACE
Diffstat (limited to 'innobase/buf')
-rw-r--r--innobase/buf/buf0buf.c32
-rw-r--r--innobase/buf/buf0flu.c26
-rw-r--r--innobase/buf/buf0lru.c83
-rw-r--r--innobase/buf/buf0rea.c3
4 files changed, 108 insertions, 36 deletions
diff --git a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c
index 1e1c6b25c1d..b403cc4df0d 100644
--- a/innobase/buf/buf0buf.c
+++ b/innobase/buf/buf0buf.c
@@ -468,6 +468,11 @@ buf_block_init(
block->check_index_page_at_flush = FALSE;
+ block->in_free_list = FALSE;
+ block->in_LRU_list = FALSE;
+
+ block->n_pointers = 0;
+
rw_lock_create(&(block->lock));
ut_ad(rw_lock_validate(&(block->lock)));
@@ -687,6 +692,7 @@ buf_pool_init(
}
UT_LIST_ADD_LAST(free, buf_pool->free, block);
+ block->in_free_list = TRUE;
}
mutex_exit(&(buf_pool->mutex));
@@ -830,7 +836,7 @@ buf_page_make_young(
block = buf_block_align(frame);
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
buf_LRU_make_block_young(block);
@@ -845,7 +851,7 @@ buf_block_free(
/*===========*/
buf_block_t* block) /* in, own: block to be freed */
{
- ut_ad(block->state != BUF_BLOCK_FILE_PAGE);
+ ut_a(block->state != BUF_BLOCK_FILE_PAGE);
mutex_enter(&(buf_pool->mutex));
@@ -1109,6 +1115,8 @@ loop:
goto loop;
}
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
+
must_read = FALSE;
if (block->io_fix == BUF_IO_READ) {
@@ -1407,6 +1415,8 @@ buf_page_get_known_nowait(
return(FALSE);
}
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
+
#ifdef UNIV_SYNC_DEBUG
buf_block_buf_fix_inc_debug(block, file, line);
#else
@@ -1517,7 +1527,7 @@ buf_page_init(
buf_block_t* block) /* in: block to init */
{
ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(block->state == BUF_BLOCK_READY_FOR_USE);
+ ut_a(block->state != BUF_BLOCK_FILE_PAGE);
/* Set the state of the block */
block->magic_n = BUF_BLOCK_MAGIC_N;
@@ -1533,6 +1543,18 @@ buf_page_init(
/* Insert into the hash table of file pages */
+ if (buf_page_hash_get(space, offset)) {
+ fprintf(stderr,
+"InnoDB: Error: page %lu %lu already found from the hash table\n", space,
+ offset);
+ buf_print();
+ buf_LRU_print();
+ buf_validate();
+ buf_LRU_validate();
+
+ ut_a(0);
+ }
+
HASH_INSERT(buf_block_t, hash, buf_pool->page_hash,
buf_page_address_fold(space, offset), block);
@@ -1605,7 +1627,7 @@ buf_page_init_for_read(
block = buf_block_alloc();
- ut_ad(block);
+ ut_a(block);
mutex_enter(&(buf_pool->mutex));
@@ -1769,6 +1791,8 @@ buf_page_io_complete(
ut_ad(block);
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
+
io_type = block->io_fix;
if (io_type == BUF_IO_READ) {
diff --git a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
index 3f8022f36bc..27a1829942d 100644
--- a/innobase/buf/buf0flu.c
+++ b/innobase/buf/buf0flu.c
@@ -50,6 +50,8 @@ buf_flush_insert_into_flush_list(
{
ut_ad(mutex_own(&(buf_pool->mutex)));
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
+
ut_ad((UT_LIST_GET_FIRST(buf_pool->flush_list) == NULL)
|| (ut_dulint_cmp(
(UT_LIST_GET_FIRST(buf_pool->flush_list))
@@ -131,7 +133,7 @@ buf_flush_ready_for_flush(
ulint flush_type)/* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */
{
ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
if ((ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0)
&& (block->io_fix == 0)) {
@@ -163,6 +165,8 @@ buf_flush_write_complete(
ut_ad(block);
ut_ad(mutex_own(&(buf_pool->mutex)));
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
+
block->oldest_modification = ut_dulint_zero;
UT_LIST_REMOVE(flush_list, buf_pool->flush_list, block);
@@ -282,6 +286,8 @@ buf_flush_buffered_writes(void)
for (i = 0; i < trx_doublewrite->first_free; i++) {
block = trx_doublewrite->buf_block_arr[i];
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
+
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
FALSE, block->space, block->offset, 0, UNIV_PAGE_SIZE,
(void*)block->frame, (void*)block);
@@ -321,6 +327,8 @@ buf_flush_post_to_doublewrite_buf(
try_again:
mutex_enter(&(trx_doublewrite->mutex));
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
+
if (trx_doublewrite->first_free
>= 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) {
mutex_exit(&(trx_doublewrite->mutex));
@@ -395,6 +403,8 @@ buf_flush_write_block_low(
/*======================*/
buf_block_t* block) /* in: buffer block to write */
{
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
+
#ifdef UNIV_IBUF_DEBUG
ut_a(ibuf_count_get(block->space, block->offset) == 0);
#endif
@@ -443,7 +453,7 @@ buf_flush_try_page(
block = buf_page_hash_get(space, offset);
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
+ ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE);
if (flush_type == BUF_FLUSH_LIST
&& block && buf_flush_ready_for_flush(block, flush_type)) {
@@ -635,6 +645,7 @@ buf_flush_try_neighbors(
for (i = low; i < high; i++) {
block = buf_page_hash_get(space, i);
+ ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE);
if (block && flush_type == BUF_FLUSH_LRU && i != offset
&& !block->old) {
@@ -703,10 +714,10 @@ buf_flush_batch(
ulint offset;
ibool found;
- ut_ad((flush_type == BUF_FLUSH_LRU) || (flush_type == BUF_FLUSH_LIST));
- ut_ad((flush_type != BUF_FLUSH_LIST) ||
- sync_thread_levels_empty_gen(TRUE));
-
+ ut_ad((flush_type == BUF_FLUSH_LRU)
+ || (flush_type == BUF_FLUSH_LIST));
+ ut_ad((flush_type != BUF_FLUSH_LIST)
+ || sync_thread_levels_empty_gen(TRUE));
mutex_enter(&(buf_pool->mutex));
if ((buf_pool->n_flush[flush_type] > 0)
@@ -737,7 +748,6 @@ buf_flush_batch(
ut_ad(flush_type == BUF_FLUSH_LIST);
block = UT_LIST_GET_LAST(buf_pool->flush_list);
-
if (!block
|| (ut_dulint_cmp(block->oldest_modification,
lsn_limit) >= 0)) {
@@ -756,6 +766,7 @@ buf_flush_batch(
function a pointer to a block in the list! */
while ((block != NULL) && !found) {
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
if (buf_flush_ready_for_flush(block, flush_type)) {
@@ -781,7 +792,6 @@ buf_flush_batch(
} else if (flush_type == BUF_FLUSH_LRU) {
block = UT_LIST_GET_PREV(LRU, block);
-
} else {
ut_ad(flush_type == BUF_FLUSH_LIST);
diff --git a/innobase/buf/buf0lru.c b/innobase/buf/buf0lru.c
index 5d48d460745..55a5ecbeba5 100644
--- a/innobase/buf/buf0lru.c
+++ b/innobase/buf/buf0lru.c
@@ -82,6 +82,8 @@ scan_again:
block = UT_LIST_GET_LAST(buf_pool->LRU);
while (block != NULL) {
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
+
if (block->space == id
&& (block->buf_fix_count > 0 || block->io_fix != 0)) {
@@ -199,19 +201,16 @@ buf_LRU_search_and_free_block(
mutex_enter(&(buf_pool->mutex));
freed = FALSE;
-
block = UT_LIST_GET_LAST(buf_pool->LRU);
while (block != NULL) {
-
+ ut_a(block->in_LRU_list);
if (buf_flush_ready_for_replace(block)) {
-
if (buf_debug_prints) {
printf(
"Putting space %lu page %lu to free list\n",
block->space, block->offset);
}
-
buf_LRU_block_remove_hashed_page(block);
mutex_exit(&(buf_pool->mutex));
@@ -223,25 +222,21 @@ buf_LRU_search_and_free_block(
if (block->frame) {
btr_search_drop_page_hash_index(block->frame);
}
-
mutex_enter(&(buf_pool->mutex));
ut_a(block->buf_fix_count == 0);
buf_LRU_block_free_hashed_page(block);
-
freed = TRUE;
break;
}
-
block = UT_LIST_GET_PREV(LRU, block);
distance++;
if (!freed && n_iterations <= 10
&& distance > 100 + (n_iterations * buf_pool->curr_size)
/ 10) {
-
buf_pool->LRU_flush_ended = 0;
mutex_exit(&(buf_pool->mutex));
@@ -249,15 +244,12 @@ buf_LRU_search_and_free_block(
return(FALSE);
}
}
-
if (buf_pool->LRU_flush_ended > 0) {
buf_pool->LRU_flush_ended--;
}
-
- if (!freed) {
+ if (!freed) {
buf_pool->LRU_flush_ended = 0;
}
-
mutex_exit(&(buf_pool->mutex));
return(freed);
@@ -355,7 +347,11 @@ loop:
if (UT_LIST_GET_LEN(buf_pool->free) > 0) {
block = UT_LIST_GET_FIRST(buf_pool->free);
+ ut_a(block->in_free_list);
UT_LIST_REMOVE(free, buf_pool->free, block);
+ block->in_free_list = FALSE;
+ ut_a(block->state != BUF_BLOCK_FILE_PAGE);
+ ut_a(!block->in_LRU_list);
if (srv_use_awe) {
if (block->frame) {
@@ -466,7 +462,7 @@ buf_LRU_old_adjust_len(void)
ulint old_len;
ulint new_len;
- ut_ad(buf_pool->LRU_old);
+ ut_a(buf_pool->LRU_old);
ut_ad(mutex_own(&(buf_pool->mutex)));
ut_ad(3 * (BUF_LRU_OLD_MIN_LEN / 8) > BUF_LRU_OLD_TOLERANCE + 5);
@@ -474,6 +470,8 @@ buf_LRU_old_adjust_len(void)
old_len = buf_pool->LRU_old_len;
new_len = 3 * (UT_LIST_GET_LEN(buf_pool->LRU) / 8);
+ ut_a(buf_pool->LRU_old->in_LRU_list);
+
/* Update the LRU_old pointer if necessary */
if (old_len < new_len - BUF_LRU_OLD_TOLERANCE) {
@@ -490,7 +488,7 @@ buf_LRU_old_adjust_len(void)
buf_pool->LRU_old);
buf_pool->LRU_old_len--;
} else {
- ut_ad(buf_pool->LRU_old); /* Check that we did not
+ ut_a(buf_pool->LRU_old); /* Check that we did not
fall out of the LRU list */
return;
}
@@ -498,9 +496,8 @@ buf_LRU_old_adjust_len(void)
}
/***********************************************************************
-Initializes the old blocks pointer in the LRU list.
-This function should be called when the LRU list grows to
-BUF_LRU_OLD_MIN_LEN length. */
+Initializes the old blocks pointer in the LRU list. This function should be
+called when the LRU list grows to BUF_LRU_OLD_MIN_LEN length. */
static
void
buf_LRU_old_init(void)
@@ -508,7 +505,7 @@ buf_LRU_old_init(void)
{
buf_block_t* block;
- ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == BUF_LRU_OLD_MIN_LEN);
+ ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == BUF_LRU_OLD_MIN_LEN);
/* We first initialize all blocks in the LRU list as old and then use
the adjust function to move the LRU_old pointer to the right
@@ -517,6 +514,8 @@ buf_LRU_old_init(void)
block = UT_LIST_GET_FIRST(buf_pool->LRU);
while (block != NULL) {
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
+ ut_a(block->in_LRU_list);
block->old = TRUE;
block = UT_LIST_GET_NEXT(LRU, block);
}
@@ -539,6 +538,9 @@ buf_LRU_remove_block(
ut_ad(block);
ut_ad(mutex_own(&(buf_pool->mutex)));
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
+ ut_a(block->in_LRU_list);
+
/* If the LRU_old pointer is defined and points to just this block,
move it backward one step */
@@ -552,11 +554,12 @@ buf_LRU_remove_block(
(buf_pool->LRU_old)->old = TRUE;
buf_pool->LRU_old_len++;
- ut_ad(buf_pool->LRU_old);
+ ut_a(buf_pool->LRU_old);
}
/* Remove the block from the LRU list */
UT_LIST_REMOVE(LRU, buf_pool->LRU, block);
+ block->in_LRU_list = FALSE;
if (srv_use_awe && block->frame) {
/* Remove from the list of mapped pages */
@@ -599,6 +602,8 @@ buf_LRU_add_block_to_end_low(
ut_ad(block);
ut_ad(mutex_own(&(buf_pool->mutex)));
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
+
block->old = TRUE;
last_block = UT_LIST_GET_LAST(buf_pool->LRU);
@@ -609,7 +614,9 @@ buf_LRU_add_block_to_end_low(
block->LRU_position = buf_pool_clock_tic();
}
+ ut_a(!block->in_LRU_list);
UT_LIST_ADD_LAST(LRU, buf_pool->LRU, block);
+ block->in_LRU_list = TRUE;
if (srv_use_awe && block->frame) {
/* Add to the list of mapped pages */
@@ -658,6 +665,9 @@ buf_LRU_add_block_low(
ut_ad(block);
ut_ad(mutex_own(&(buf_pool->mutex)));
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
+ ut_a(!block->in_LRU_list);
+
block->old = old;
cl = buf_pool_clock_tic();
@@ -687,6 +697,8 @@ buf_LRU_add_block_low(
block->LRU_position = (buf_pool->LRU_old)->LRU_position;
}
+ block->in_LRU_list = TRUE;
+
if (UT_LIST_GET_LEN(buf_pool->LRU) > BUF_LRU_OLD_MIN_LEN) {
ut_ad(buf_pool->LRU_old);
@@ -755,9 +767,12 @@ buf_LRU_block_free_non_file_page(
ut_ad(mutex_own(&(buf_pool->mutex)));
ut_ad(block);
- ut_ad((block->state == BUF_BLOCK_MEMORY)
+ ut_a((block->state == BUF_BLOCK_MEMORY)
|| (block->state == BUF_BLOCK_READY_FOR_USE));
+ ut_a(block->n_pointers == 0);
+ ut_a(!block->in_free_list);
+
block->state = BUF_BLOCK_NOT_USED;
#ifdef UNIV_DEBUG
@@ -765,6 +780,7 @@ buf_LRU_block_free_non_file_page(
memset(block->frame, '\0', UNIV_PAGE_SIZE);
#endif
UT_LIST_ADD_FIRST(free, buf_pool->free, block);
+ block->in_free_list = TRUE;
if (srv_use_awe && block->frame) {
/* Add to the list of mapped pages */
@@ -788,8 +804,7 @@ buf_LRU_block_remove_hashed_page(
ut_ad(mutex_own(&(buf_pool->mutex)));
ut_ad(block);
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
-
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(block->io_fix == 0);
ut_a(block->buf_fix_count == 0);
ut_a(ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) == 0);
@@ -802,6 +817,28 @@ buf_LRU_block_remove_hashed_page(
buf_block_modify_clock_inc(block);
+ if (block != buf_page_hash_get(block->space, block->offset)) {
+ fprintf(stderr,
+"InnoDB: Error: page %lu %lu not found from the hash table\n",
+ block->space,
+ block->offset);
+ if (buf_page_hash_get(block->space, block->offset)) {
+ fprintf(stderr,
+"InnoDB: From hash table we find block %lx of %lu %lu which is not %lx\n",
+ (ulint)buf_page_hash_get(block->space, block->offset),
+ buf_page_hash_get(block->space, block->offset)->space,
+ buf_page_hash_get(block->space, block->offset)->offset,
+ (ulint)block);
+ }
+
+ buf_print();
+ buf_LRU_print();
+ buf_validate();
+ buf_LRU_validate();
+
+ ut_a(0);
+ }
+
HASH_DELETE(buf_block_t, hash, buf_pool->page_hash,
buf_page_address_fold(block->space, block->offset),
block);
@@ -819,7 +856,7 @@ buf_LRU_block_free_hashed_page(
be in a state where it can be freed */
{
ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(block->state == BUF_BLOCK_REMOVE_HASH);
+ ut_a(block->state == BUF_BLOCK_REMOVE_HASH);
block->state = BUF_BLOCK_MEMORY;
diff --git a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
index 8cc379e75d8..0fa6912ba1d 100644
--- a/innobase/buf/buf0rea.c
+++ b/innobase/buf/buf0rea.c
@@ -129,6 +129,8 @@ buf_read_page_low(
offset, sync);
}
+ ut_a(block->state == BUF_BLOCK_FILE_PAGE);
+
*err = fil_io(OS_FILE_READ | wake_later,
sync, space,
offset, 0, UNIV_PAGE_SIZE,
@@ -604,7 +606,6 @@ buf_read_ibuf_merge_pages(
}
for (i = 0; i < n_stored; i++) {
-
if ((i + 1 == n_stored) && sync) {
buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE,
space_ids[i], space_versions[i], page_nos[i]);