From 03bdaaf5094baafa7c6c429426cee5f3fdddfd01 Mon Sep 17 00:00:00 2001 From: marko Date: Thu, 16 Nov 2006 09:00:30 +0000 Subject: [PATCH] branches/zip: Introduce a new preprocessor symbol, UNIV_BUF_DEBUG, and enclose buf_validate() and friends in it. --- buf/buf0buf.c | 82 ++++++++++++++++++--------------------------- buf/buf0flu.c | 12 +++++-- buf/buf0lru.c | 12 +++---- dict/dict0dict.c | 4 ++- include/buf0buf.h | 6 ++-- include/buf0flu.h | 2 ++ include/buf0lru.h | 6 ++-- include/dict0dict.h | 4 ++- include/univ.i | 1 + 9 files changed, 65 insertions(+), 64 deletions(-) diff --git a/buf/buf0buf.c b/buf/buf0buf.c index 0936372b582..a3ed819cee6 100644 --- a/buf/buf0buf.c +++ b/buf/buf0buf.c @@ -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 @@ loop: 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 @@ loop: 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. */ diff --git a/buf/buf0flu.c b/buf/buf0flu.c index 27f57e6c4bd..157cf7f4791 100644 --- a/buf/buf0flu.c +++ b/buf/buf0flu.c @@ -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 */ diff --git a/buf/buf0lru.c b/buf/buf0lru.c index a5db248f585..a7b58b6bff3 100644 --- a/buf/buf0lru.c +++ b/buf/buf0lru.c @@ -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 */ diff --git a/dict/dict0dict.c b/dict/dict0dict.c index 172948e13b0..f7fb3a451cd 100644 --- a/dict/dict0dict.c +++ b/dict/dict0dict.c @@ -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. */ diff --git a/include/buf0buf.h b/include/buf0buf.h index 6ef56957947..deb98c8ecd5 100644 --- a/include/buf0buf.h +++ b/include/buf0buf.h @@ -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. */ diff --git a/include/buf0flu.h b/include/buf0flu.h index 2c9a7cf3dea..b7612beda58 100644 --- a/include/buf0flu.h +++ b/include/buf0flu.h @@ -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 diff --git a/include/buf0lru.h b/include/buf0lru.h index dd098e9ccb4..cced9b4ab94 100644 --- a/include/buf0lru.h +++ b/include/buf0lru.h @@ -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" diff --git a/include/dict0dict.h b/include/dict0dict.h index 8fd2c44357d..5c5280a69bb 100644 --- a/include/dict0dict.h +++ b/include/dict0dict.h @@ -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. */ diff --git a/include/univ.i b/include/univ.i index b9f33cb9a40..6ac091fee66 100644 --- a/include/univ.i +++ b/include/univ.i @@ -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