Commit b0ab8786 authored by marko's avatar marko

branches/zip: Introduce UNIV_AHI_DEBUG for debugging the adaptive hash

index without enabling UNIV_DEBUG.
parent fc249aa5
2008-12-17 The InnoDB Team
* include/univ.i, include/buf0buf.h, include/hash0hash.h,
include/ha0ha.h, include/ha0ha.ic, ha/ha0ha.c, ha/hash0hash.c,
btr/btr0sea.c, buf/buf0lru.c, buf/buf0buf.c:
Introduce the preprocessor symbol UNIV_AHI_DEBUG for enabling
adaptive hash index debugging independently of UNIV_DEBUG.
2008-12-02 The InnoDB Team 2008-12-02 The InnoDB Team
* row/row0merge.c: * row/row0merge.c:
......
...@@ -1102,7 +1102,7 @@ next_rec: ...@@ -1102,7 +1102,7 @@ next_rec:
block->index = NULL; block->index = NULL;
cleanup: cleanup:
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (UNIV_UNLIKELY(block->n_pointers)) { if (UNIV_UNLIKELY(block->n_pointers)) {
/* Corruption */ /* Corruption */
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
...@@ -1118,9 +1118,9 @@ cleanup: ...@@ -1118,9 +1118,9 @@ cleanup:
} else { } else {
rw_lock_x_unlock(&btr_search_latch); rw_lock_x_unlock(&btr_search_latch);
} }
#else /* UNIV_DEBUG */ #else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
rw_lock_x_unlock(&btr_search_latch); rw_lock_x_unlock(&btr_search_latch);
#endif /* UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
mem_free(folds); mem_free(folds);
} }
......
...@@ -658,8 +658,10 @@ buf_block_init( ...@@ -658,8 +658,10 @@ buf_block_init(
block->page.in_free_list = FALSE; block->page.in_free_list = FALSE;
block->page.in_LRU_list = FALSE; block->page.in_LRU_list = FALSE;
block->in_unzip_LRU_list = FALSE; block->in_unzip_LRU_list = FALSE;
block->n_pointers = 0;
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
block->n_pointers = 0;
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
page_zip_des_init(&block->page.zip); page_zip_des_init(&block->page.zip);
mutex_create(&block->mutex, SYNC_BUF_BLOCK); mutex_create(&block->mutex, SYNC_BUF_BLOCK);
......
...@@ -1569,7 +1569,9 @@ buf_LRU_block_free_non_file_page( ...@@ -1569,7 +1569,9 @@ buf_LRU_block_free_non_file_page(
ut_error; ut_error;
} }
ut_ad(block->n_pointers == 0); #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
ut_a(block->n_pointers == 0);
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
ut_ad(!block->page.in_free_list); ut_ad(!block->page.in_free_list);
ut_ad(!block->page.in_flush_list); ut_ad(!block->page.in_flush_list);
ut_ad(!block->page.in_LRU_list); ut_ad(!block->page.in_LRU_list);
......
...@@ -40,9 +40,9 @@ ha_create_func( ...@@ -40,9 +40,9 @@ ha_create_func(
table = hash_create(n); table = hash_create(n);
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
table->adaptive = TRUE; table->adaptive = TRUE;
#endif /* UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/* Creating MEM_HEAP_BTR_SEARCH type heaps can potentially fail, /* Creating MEM_HEAP_BTR_SEARCH type heaps can potentially fail,
but in practise it never should in this case, hence the asserts. */ but in practise it never should in this case, hence the asserts. */
...@@ -111,9 +111,9 @@ ha_insert_for_fold_func( ...@@ -111,9 +111,9 @@ ha_insert_for_fold_func(
the same fold value already exists, it is the same fold value already exists, it is
updated to point to the same data, and no new updated to point to the same data, and no new
node is created! */ node is created! */
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* block, /* in: buffer block containing the data */ buf_block_t* block, /* in: buffer block containing the data */
#endif /* UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* data) /* in: data, must not be NULL */ void* data) /* in: data, must not be NULL */
{ {
hash_cell_t* cell; hash_cell_t* cell;
...@@ -122,7 +122,9 @@ ha_insert_for_fold_func( ...@@ -122,7 +122,9 @@ ha_insert_for_fold_func(
ulint hash; ulint hash;
ut_ad(table && data); ut_ad(table && data);
ut_ad(block->frame == page_align(data)); #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
ut_a(block->frame == page_align(data));
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold))); ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold)));
hash = hash_calc_hash(fold, table); hash = hash_calc_hash(fold, table);
...@@ -133,7 +135,7 @@ ha_insert_for_fold_func( ...@@ -133,7 +135,7 @@ ha_insert_for_fold_func(
while (prev_node != NULL) { while (prev_node != NULL) {
if (prev_node->fold == fold) { if (prev_node->fold == fold) {
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (table->adaptive) { if (table->adaptive) {
buf_block_t* prev_block = prev_node->block; buf_block_t* prev_block = prev_node->block;
ut_a(prev_block->frame ut_a(prev_block->frame
...@@ -144,7 +146,7 @@ ha_insert_for_fold_func( ...@@ -144,7 +146,7 @@ ha_insert_for_fold_func(
} }
prev_node->block = block; prev_node->block = block;
#endif /* UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
prev_node->data = data; prev_node->data = data;
return(TRUE); return(TRUE);
...@@ -168,11 +170,11 @@ ha_insert_for_fold_func( ...@@ -168,11 +170,11 @@ ha_insert_for_fold_func(
ha_node_set_data(node, block, data); ha_node_set_data(node, block, data);
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (table->adaptive) { if (table->adaptive) {
block->n_pointers++; block->n_pointers++;
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
node->fold = fold; node->fold = fold;
node->next = NULL; node->next = NULL;
...@@ -205,13 +207,13 @@ ha_delete_hash_node( ...@@ -205,13 +207,13 @@ ha_delete_hash_node(
hash_table_t* table, /* in: hash table */ hash_table_t* table, /* in: hash table */
ha_node_t* del_node) /* in: node to be deleted */ ha_node_t* del_node) /* in: node to be deleted */
{ {
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (table->adaptive) { if (table->adaptive) {
ut_a(del_node->block->frame = page_align(del_node->data)); ut_a(del_node->block->frame = page_align(del_node->data));
ut_a(del_node->block->n_pointers > 0); ut_a(del_node->block->n_pointers > 0);
del_node->block->n_pointers--; del_node->block->n_pointers--;
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
HASH_DELETE_AND_COMPACT(ha_node_t, next, table, del_node); HASH_DELETE_AND_COMPACT(ha_node_t, next, table, del_node);
} }
...@@ -247,20 +249,22 @@ ha_search_and_update_if_found_func( ...@@ -247,20 +249,22 @@ ha_search_and_update_if_found_func(
hash_table_t* table, /* in: hash table */ hash_table_t* table, /* in: hash table */
ulint fold, /* in: folded value of the searched data */ ulint fold, /* in: folded value of the searched data */
void* data, /* in: pointer to the data */ void* data, /* in: pointer to the data */
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* new_block,/* in: block containing new_data */ buf_block_t* new_block,/* in: block containing new_data */
#endif #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* new_data)/* in: new pointer to the data */ void* new_data)/* in: new pointer to the data */
{ {
ha_node_t* node; ha_node_t* node;
ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold))); ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold)));
ut_ad(new_block->frame == page_align(new_data)); #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
ut_a(new_block->frame == page_align(new_data));
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
node = ha_search_with_data(table, fold, data); node = ha_search_with_data(table, fold, data);
if (node) { if (node) {
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (table->adaptive) { if (table->adaptive) {
ut_a(node->block->n_pointers > 0); ut_a(node->block->n_pointers > 0);
node->block->n_pointers--; node->block->n_pointers--;
...@@ -268,7 +272,7 @@ ha_search_and_update_if_found_func( ...@@ -268,7 +272,7 @@ ha_search_and_update_if_found_func(
} }
node->block = new_block; node->block = new_block;
#endif /* UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
node->data = new_data; node->data = new_data;
} }
} }
......
...@@ -89,9 +89,9 @@ hash_create( ...@@ -89,9 +89,9 @@ hash_create(
array = ut_malloc(sizeof(hash_cell_t) * prime); array = ut_malloc(sizeof(hash_cell_t) * prime);
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
table->adaptive = FALSE; table->adaptive = FALSE;
#endif /* UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
table->array = array; table->array = array;
table->n_cells = prime; table->n_cells = prime;
table->n_mutexes = 0; table->n_mutexes = 0;
......
...@@ -1162,11 +1162,11 @@ struct buf_block_struct{ ...@@ -1162,11 +1162,11 @@ struct buf_block_struct{
An exception to this is when we init or create a page An exception to this is when we init or create a page
in the buffer pool in buf0buf.c. */ in the buffer pool in buf0buf.c. */
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
ulint n_pointers; /* used in debugging: the number of ulint n_pointers; /* used in debugging: the number of
pointers in the adaptive hash index pointers in the adaptive hash index
pointing to this frame */ pointing to this frame */
#endif /* UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
unsigned is_hashed:1; /* TRUE if hash index has already been unsigned is_hashed:1; /* TRUE if hash index has already been
built on this page; note that it does built on this page; note that it does
not guarantee that the index is not guarantee that the index is
......
...@@ -36,18 +36,18 @@ ha_search_and_update_if_found_func( ...@@ -36,18 +36,18 @@ ha_search_and_update_if_found_func(
hash_table_t* table, /* in: hash table */ hash_table_t* table, /* in: hash table */
ulint fold, /* in: folded value of the searched data */ ulint fold, /* in: folded value of the searched data */
void* data, /* in: pointer to the data */ void* data, /* in: pointer to the data */
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* new_block,/* in: block containing new_data */ buf_block_t* new_block,/* in: block containing new_data */
#endif #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* new_data);/* in: new pointer to the data */ void* new_data);/* in: new pointer to the data */
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
# define ha_search_and_update_if_found(table,fold,data,new_block,new_data) \ # define ha_search_and_update_if_found(table,fold,data,new_block,new_data) \
ha_search_and_update_if_found_func(table,fold,data,new_block,new_data) ha_search_and_update_if_found_func(table,fold,data,new_block,new_data)
#else #else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
# define ha_search_and_update_if_found(table,fold,data,new_block,new_data) \ # define ha_search_and_update_if_found(table,fold,data,new_block,new_data) \
ha_search_and_update_if_found_func(table,fold,data,new_data) ha_search_and_update_if_found_func(table,fold,data,new_data)
#endif #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/***************************************************************** /*****************************************************************
Creates a hash table with >= n array cells. The actual number of cells is Creates a hash table with >= n array cells. The actual number of cells is
chosen to be a prime number slightly bigger than n. */ chosen to be a prime number slightly bigger than n. */
...@@ -92,16 +92,16 @@ ha_insert_for_fold_func( ...@@ -92,16 +92,16 @@ ha_insert_for_fold_func(
the same fold value already exists, it is the same fold value already exists, it is
updated to point to the same data, and no new updated to point to the same data, and no new
node is created! */ node is created! */
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* block, /* in: buffer block containing the data */ buf_block_t* block, /* in: buffer block containing the data */
#endif /* UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* data); /* in: data, must not be NULL */ void* data); /* in: data, must not be NULL */
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
# define ha_insert_for_fold(t,f,b,d) ha_insert_for_fold_func(t,f,b,d) # define ha_insert_for_fold(t,f,b,d) ha_insert_for_fold_func(t,f,b,d)
#else #else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
# define ha_insert_for_fold(t,f,b,d) ha_insert_for_fold_func(t,f,d) # define ha_insert_for_fold(t,f,b,d) ha_insert_for_fold_func(t,f,d)
#endif #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/***************************************************************** /*****************************************************************
Deletes an entry from a hash table. */ Deletes an entry from a hash table. */
...@@ -158,9 +158,9 @@ ha_print_info( ...@@ -158,9 +158,9 @@ ha_print_info(
typedef struct ha_node_struct ha_node_t; typedef struct ha_node_struct ha_node_t;
struct ha_node_struct { struct ha_node_struct {
ha_node_t* next; /* next chain node or NULL if none */ ha_node_t* next; /* next chain node or NULL if none */
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* block; /* buffer block containing the data, or NULL */ buf_block_t* block; /* buffer block containing the data, or NULL */
#endif /* UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* data; /* pointer to the data */ void* data; /* pointer to the data */
ulint fold; /* fold value for the data */ ulint fold; /* fold value for the data */
}; };
......
...@@ -37,22 +37,22 @@ void ...@@ -37,22 +37,22 @@ void
ha_node_set_data_func( ha_node_set_data_func(
/*==================*/ /*==================*/
ha_node_t* node, /* in: hash chain node */ ha_node_t* node, /* in: hash chain node */
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* block, /* in: buffer block containing the data */ buf_block_t* block, /* in: buffer block containing the data */
#endif /* UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* data) /* in: pointer to the data */ void* data) /* in: pointer to the data */
{ {
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
node->block = block; node->block = block;
#endif /* UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
node->data = data; node->data = data;
} }
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
# define ha_node_set_data(n,b,d) ha_node_set_data_func(n,b,d) # define ha_node_set_data(n,b,d) ha_node_set_data_func(n,b,d)
#else /* UNIV_DEBUG */ #else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
# define ha_node_set_data(n,b,d) ha_node_set_data_func(n,d) # define ha_node_set_data(n,b,d) ha_node_set_data_func(n,d)
#endif /* UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/********************************************************************** /**********************************************************************
Gets the next node in a hash chain. */ Gets the next node in a hash chain. */
......
...@@ -363,10 +363,10 @@ struct hash_cell_struct{ ...@@ -363,10 +363,10 @@ struct hash_cell_struct{
/* The hash table structure */ /* The hash table structure */
struct hash_table_struct { struct hash_table_struct {
#ifdef UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
ibool adaptive;/* TRUE if this is the hash table of the ibool adaptive;/* TRUE if this is the hash table of the
adaptive hash index */ adaptive hash index */
#endif /* UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
ulint n_cells;/* number of cells in the hash table */ ulint n_cells;/* number of cells in the hash table */
hash_cell_t* array; /* pointer to cell array */ hash_cell_t* array; /* pointer to cell array */
ulint n_mutexes;/* if mutexes != NULL, then the number of ulint n_mutexes;/* if mutexes != NULL, then the number of
......
...@@ -130,6 +130,8 @@ command. Not tested on Windows. */ ...@@ -130,6 +130,8 @@ command. Not tested on Windows. */
Valgrind instrumentation */ Valgrind instrumentation */
#define UNIV_DEBUG_PRINT /* Enable the compilation of #define UNIV_DEBUG_PRINT /* Enable the compilation of
some debug print functions */ some debug print functions */
#define UNIV_AHI_DEBUG /* Enable adaptive hash index
debugging without UNIV_DEBUG */
#define UNIV_BUF_DEBUG /* Enable buffer pool #define UNIV_BUF_DEBUG /* Enable buffer pool
debugging without UNIV_DEBUG */ debugging without UNIV_DEBUG */
#define UNIV_DEBUG /* Enable ut_ad() assertions #define UNIV_DEBUG /* Enable ut_ad() assertions
......
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