Commit 03bdaaf5 authored by marko's avatar marko

branches/zip: Introduce a new preprocessor symbol, UNIV_BUF_DEBUG, and

enclose buf_validate() and friends in it.
parent 97b49ef9
......@@ -206,10 +206,12 @@ static const int WAIT_FOR_READ = 20000;
buf_pool_t* buf_pool = NULL; /* The buffer buf_pool of the database */
#ifdef UNIV_DEBUG
ulint buf_dbg_counter = 0; /* This is used to insert validation
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
static ulint buf_dbg_counter = 0; /* This is used to insert validation
operations in excution in the
debug version */
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
#ifdef UNIV_DEBUG
ibool buf_debug_prints = FALSE; /* If this is set TRUE,
the program prints info whenever
read-ahead or flush occurs */
......@@ -1349,13 +1351,9 @@ buf_page_get_gen(
buf_read_page(space, fil_space_get_zip_size(space), offset);
#ifdef UNIV_DEBUG
buf_dbg_counter++;
if (buf_dbg_counter % 37 == 0) {
ut_ad(buf_validate());
}
#endif
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
ut_a(++buf_dbg_counter % 37 || buf_validate());
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
goto loop;
}
......@@ -1399,15 +1397,11 @@ buf_page_get_gen(
ut_a(block->file_page_was_freed == FALSE);
#endif
#ifdef UNIV_DEBUG
buf_dbg_counter++;
if (buf_dbg_counter % 5771 == 0) {
ut_ad(buf_validate());
}
#endif
ut_ad(block->buf_fix_count > 0);
ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
ut_a(++buf_dbg_counter % 5771 || buf_validate());
ut_a(block->buf_fix_count > 0);
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
if (mode == BUF_GET_NOWAIT) {
if (rw_latch == RW_S_LATCH) {
......@@ -1581,15 +1575,11 @@ buf_page_optimistic_get_func(
mtr_memo_push(mtr, block, fix_type);
#ifdef UNIV_DEBUG
buf_dbg_counter++;
if (buf_dbg_counter % 5771 == 0) {
ut_ad(buf_validate());
}
#endif
ut_ad(block->buf_fix_count > 0);
ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
ut_a(++buf_dbg_counter % 5771 || buf_validate());
ut_a(block->buf_fix_count > 0);
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
#ifdef UNIV_DEBUG_FILE_ACCESSES
ut_a(block->file_page_was_freed == FALSE);
......@@ -1689,15 +1679,11 @@ buf_page_get_known_nowait(
mtr_memo_push(mtr, block, fix_type);
#ifdef UNIV_DEBUG
buf_dbg_counter++;
if (buf_dbg_counter % 5771 == 0) {
ut_ad(buf_validate());
}
#endif
ut_ad(block->buf_fix_count > 0);
ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
ut_a(++buf_dbg_counter % 5771 || buf_validate());
ut_a(block->buf_fix_count > 0);
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
#ifdef UNIV_DEBUG_FILE_ACCESSES
ut_a(block->file_page_was_freed == FALSE);
#endif
......@@ -1797,12 +1783,12 @@ buf_page_init(
" in the hash table\n",
(ulong) space,
(ulong) offset);
#ifdef UNIV_DEBUG
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
buf_print();
buf_LRU_print();
buf_validate();
buf_LRU_validate();
#endif /* UNIV_DEBUG */
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
ut_error;
}
......@@ -2043,13 +2029,9 @@ buf_page_create(
memset(frame + FIL_PAGE_FILE_FLUSH_LSN, 0, 8);
#ifdef UNIV_DEBUG
buf_dbg_counter++;
if (buf_dbg_counter % 357 == 0) {
ut_ad(buf_validate());
}
#endif
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
ut_a(++buf_dbg_counter % 357 || buf_validate());
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
#ifdef UNIV_IBUF_DEBUG
ut_a(ibuf_count_get(block->space, block->offset) == 0);
#endif
......@@ -2301,7 +2283,7 @@ buf_pool_invalidate(void)
mutex_exit(&(buf_pool->mutex));
}
#ifdef UNIV_DEBUG
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/*************************************************************************
Validates the buffer buf_pool data structure. */
......@@ -2412,9 +2394,9 @@ buf_validate(void)
return(TRUE);
}
#endif /* UNIV_DEBUG */
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
#if defined UNIV_DEBUG || defined UNIV_DEBUG_PRINT
#if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/*************************************************************************
Prints info of the buffer buf_pool data structure. */
......@@ -2521,9 +2503,9 @@ buf_print(void)
mem_free(index_ids);
mem_free(counts);
ut_ad(buf_validate());
ut_a(buf_validate());
}
#endif /* UNIV_DEBUG || UNIV_DEBUG_PRINT */
#endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
/*************************************************************************
Returns the number of latched pages in the buffer pool. */
......
......@@ -33,6 +33,7 @@ flushed along with the original page. */
#define BUF_FLUSH_AREA ut_min(BUF_READ_AHEAD_AREA,\
buf_pool->curr_size / 16)
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/**********************************************************************
Validates the flush list. */
static
......@@ -40,6 +41,7 @@ ibool
buf_flush_validate_low(void);
/*========================*/
/* out: TRUE if ok */
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
/************************************************************************
Inserts a modified block into the flush list. */
......@@ -62,7 +64,9 @@ buf_flush_insert_into_flush_list(
UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, block);
ut_ad(buf_flush_validate_low());
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
ut_a(buf_flush_validate_low());
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
}
/************************************************************************
......@@ -98,7 +102,9 @@ buf_flush_insert_sorted_into_flush_list(
block);
}
ut_ad(buf_flush_validate_low());
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
ut_a(buf_flush_validate_low());
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
}
/************************************************************************
......@@ -1112,6 +1118,7 @@ buf_flush_free_margin(void)
}
}
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/**********************************************************************
Validates the flush list. */
static
......@@ -1161,3 +1168,4 @@ buf_flush_validate(void)
return(ret);
}
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
......@@ -933,12 +933,12 @@ buf_LRU_block_remove_hashed_page(
(void*) block);
}
#ifdef UNIV_DEBUG
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
buf_print();
buf_LRU_print();
buf_validate();
buf_LRU_validate();
#endif
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
ut_error;
}
......@@ -971,7 +971,7 @@ buf_LRU_block_free_hashed_page(
buf_LRU_block_free_non_file_page(block);
}
#ifdef UNIV_DEBUG
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/**************************************************************************
Validates the LRU list. */
......@@ -1043,9 +1043,9 @@ buf_LRU_validate(void)
mutex_exit(&(buf_pool->mutex));
return(TRUE);
}
#endif /* UNIV_DEBUG */
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
#if defined UNIV_DEBUG || defined UNIV_DEBUG_PRINT
#if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/**************************************************************************
Prints the LRU list. */
......@@ -1098,4 +1098,4 @@ buf_LRU_print(void)
mutex_exit(&(buf_pool->mutex));
}
#endif /* UNIV_DEBUG || UNIV_DEBUG_PRINT */
#endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
......@@ -3566,7 +3566,7 @@ dict_index_get_if_in_cache_low(
return(dict_index_find_on_id_low(index_id));
}
#ifdef UNIV_DEBUG
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/**************************************************************************
Returns an index object if it is found in the dictionary cache. */
......@@ -3590,7 +3590,9 @@ dict_index_get_if_in_cache(
return(index);
}
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
#ifdef UNIV_DEBUG
/**************************************************************************
Checks that a tuple has n_fields_cmp value in a sensible range, so that
no comparison can occur with the page number field in a node pointer. */
......
......@@ -425,20 +425,22 @@ buf_block_get_lock_hash_val(
/* out: lock hash value */
const buf_block_t* block) /* in: block */
__attribute__((const));
#ifdef UNIV_DEBUG
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/*************************************************************************
Validates the buffer pool data structure. */
ibool
buf_validate(void);
/*==============*/
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
#if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/*************************************************************************
Prints info of the buffer pool data structure. */
void
buf_print(void);
/*============*/
#endif /* UNIV_DEBUG */
#endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
/************************************************************************
Prints a page to stderr. */
......
......@@ -97,6 +97,7 @@ buf_flush_ready_for_replace(
buf_block_t* block); /* in: buffer control block, must
be in state BUF_BLOCK_FILE_PAGE
and in the LRU list */
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/**********************************************************************
Validates the flush list. */
......@@ -104,6 +105,7 @@ ibool
buf_flush_validate(void);
/*====================*/
/* out: TRUE if ok */
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
/* When buf_flush_free_margin is called, it tries to make this many blocks
available to replacement in the free list and at the end of the LRU list (to
......
......@@ -131,20 +131,22 @@ void
buf_LRU_make_block_old(
/*===================*/
buf_block_t* block); /* in: control block */
#ifdef UNIV_DEBUG
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/**************************************************************************
Validates the LRU list. */
ibool
buf_LRU_validate(void);
/*==================*/
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
#if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/**************************************************************************
Prints the LRU list. */
void
buf_LRU_print(void);
/*===============*/
#endif /* UNIV_DEBUG */
#endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
#ifndef UNIV_NONINL
#include "buf0lru.ic"
......
......@@ -836,7 +836,7 @@ dict_index_get_if_in_cache_low(
/*===========================*/
/* out: index, NULL if not found */
dulint index_id); /* in: index id */
#ifdef UNIV_DEBUG
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/**************************************************************************
Returns an index object if it is found in the dictionary cache. */
......@@ -845,6 +845,8 @@ dict_index_get_if_in_cache(
/*=======================*/
/* out: index, NULL if not found */
dulint index_id); /* in: index id */
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
#ifdef UNIV_DEBUG
/**************************************************************************
Checks that a tuple has n_fields_cmp value in a sensible range, so that
no comparison can occur with the page number field in a node pointer. */
......
......@@ -79,6 +79,7 @@ memory is read outside the allocated blocks. */
#if 0
#define UNIV_DEBUG_VALGRIND
#define UNIV_DEBUG_PRINT
#define UNIV_BUF_DEBUG
#define UNIV_DEBUG
#define UNIV_DEBUG_FILE_ACCESSES
#define UNIV_LIST_DEBUG
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment