diff options
author | unknown <marko@hundin.mysql.fi> | 2004-03-12 17:14:51 +0200 |
---|---|---|
committer | unknown <marko@hundin.mysql.fi> | 2004-03-12 17:14:51 +0200 |
commit | e1cb1ca6fe25380edae06ded5e22e106761dcb46 (patch) | |
tree | 6a59a674bf740a7b4046a20e847ad2578a573d69 /innobase/include | |
parent | 9a817bea5a369306dbb2113fbc599e63d5bb7d17 (diff) | |
download | mariadb-git-e1cb1ca6fe25380edae06ded5e22e106761dcb46.tar.gz |
Allow UNIV_SYNC_DEBUG to be disabled while UNIV_DEBUG is enabled
Diffstat (limited to 'innobase/include')
-rw-r--r-- | innobase/include/btr0sea.ic | 6 | ||||
-rw-r--r-- | innobase/include/buf0buf.h | 10 | ||||
-rw-r--r-- | innobase/include/buf0buf.ic | 12 | ||||
-rw-r--r-- | innobase/include/buf0flu.ic | 4 | ||||
-rw-r--r-- | innobase/include/dict0dict.ic | 10 | ||||
-rw-r--r-- | innobase/include/fut0fut.ic | 2 | ||||
-rw-r--r-- | innobase/include/ha0ha.ic | 12 | ||||
-rw-r--r-- | innobase/include/hash0hash.h | 55 | ||||
-rw-r--r-- | innobase/include/lock0lock.ic | 2 | ||||
-rw-r--r-- | innobase/include/log0log.ic | 8 | ||||
-rw-r--r-- | innobase/include/row0upd.ic | 2 | ||||
-rw-r--r-- | innobase/include/sync0rw.h | 14 | ||||
-rw-r--r-- | innobase/include/sync0rw.ic | 9 | ||||
-rw-r--r-- | innobase/include/sync0sync.h | 14 | ||||
-rw-r--r-- | innobase/include/sync0sync.ic | 9 | ||||
-rw-r--r-- | innobase/include/trx0rseg.ic | 4 | ||||
-rw-r--r-- | innobase/include/trx0sys.ic | 22 | ||||
-rw-r--r-- | innobase/include/trx0undo.ic | 4 |
18 files changed, 138 insertions, 61 deletions
diff --git a/innobase/include/btr0sea.ic b/innobase/include/btr0sea.ic index 63a3a658cf4..8a41042f713 100644 --- a/innobase/include/btr0sea.ic +++ b/innobase/include/btr0sea.ic @@ -44,8 +44,10 @@ btr_search_info_update( { btr_search_t* info; - ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED) - && !rw_lock_own(&btr_search_latch, RW_LOCK_EX)); +#ifdef UNIV_SYNC_DEBUG + ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); + ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); +#endif /* UNIV_SYNC_DEBUG */ info = btr_search_get_info(index); diff --git a/innobase/include/buf0buf.h b/innobase/include/buf0buf.h index 2963efd6396..72cedafa7e1 100644 --- a/innobase/include/buf0buf.h +++ b/innobase/include/buf0buf.h @@ -525,11 +525,11 @@ buf_pool_invalidate(void); --------------------------- LOWER LEVEL ROUTINES ------------------------- =========================================================================*/ +#ifdef UNIV_SYNC_DEBUG /************************************************************************* Adds latch level info for the rw-lock protecting the buffer frame. This should be called in the debug version after a successful latching of a -page if we know the latching order level of the acquired latch. If -UNIV_SYNC_DEBUG is not defined, compiles to an empty function. */ +page if we know the latching order level of the acquired latch. */ UNIV_INLINE void buf_page_dbg_add_level( @@ -537,6 +537,7 @@ buf_page_dbg_add_level( buf_frame_t* frame, /* in: buffer page where we have acquired a latch */ ulint level); /* in: latching order level */ +#endif /* UNIV_SYNC_DEBUG */ /************************************************************************* Gets a pointer to the memory frame of a block. */ UNIV_INLINE @@ -778,11 +779,12 @@ struct buf_block_struct{ BTR_SEARCH_RIGHT_SIDE in hash indexing */ /* 6. Debug fields */ - +#ifdef UNIV_SYNC_DEBUG rw_lock_t debug_latch; /* in the debug version, each thread which bufferfixes the block acquires an s-latch here; so we can use the debug utilities in sync0rw */ +#endif ibool file_page_was_freed; /* this is set to TRUE when fsp frees a page in buffer pool */ @@ -822,7 +824,7 @@ struct buf_pool_struct{ ulint n_pages_created;/* number of pages created in the pool with no read */ ulint n_page_gets; /* number of page gets performed; - also successful seraches through + also successful searches through the adaptive hash index are counted as page gets; this field is NOT protected by the buffer diff --git a/innobase/include/buf0buf.ic b/innobase/include/buf0buf.ic index d8e5857a570..0957dcf4402 100644 --- a/innobase/include/buf0buf.ic +++ b/innobase/include/buf0buf.ic @@ -129,7 +129,9 @@ buf_pool_clock_tic(void) /*====================*/ /* out: new clock value */ { +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(buf_pool->mutex))); +#endif /* UNIV_SYNC_DEBUG */ buf_pool->ulint_clock++; @@ -471,8 +473,10 @@ buf_frame_modify_clock_inc( block = buf_block_align_low(frame); +#ifdef UNIV_SYNC_DEBUG ut_ad((mutex_own(&(buf_pool->mutex)) && (block->buf_fix_count == 0)) || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE)); +#endif /* UNIV_SYNC_DEBUG */ UT_DULINT_INC(block->modify_clock); @@ -495,8 +499,10 @@ buf_frame_get_modify_clock( block = buf_block_align(frame); +#ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE)); +#endif /* UNIV_SYNC_DEBUG */ return(block->modify_clock); } @@ -546,7 +552,9 @@ buf_page_hash_get( ulint fold; ut_ad(buf_pool); +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(buf_pool->mutex))); +#endif /* UNIV_SYNC_DEBUG */ /* Look for the page in the hash table */ @@ -644,6 +652,7 @@ buf_page_release( } } +#ifdef UNIV_SYNC_DEBUG /************************************************************************* Adds latch level info for the rw-lock protecting the buffer frame. This should be called in the debug version after a successful latching of a @@ -658,7 +667,6 @@ buf_page_dbg_add_level( ulint level __attribute__((unused))) /* in: latching order level */ { -#ifdef UNIV_SYNC_DEBUG sync_thread_add_level(&(buf_block_align(frame)->lock), level); -#endif } +#endif /* UNIV_SYNC_DEBUG */ diff --git a/innobase/include/buf0flu.ic b/innobase/include/buf0flu.ic index e2faf773cab..d6dbdcc0865 100644 --- a/innobase/include/buf0flu.ic +++ b/innobase/include/buf0flu.ic @@ -40,8 +40,10 @@ buf_flush_note_modification( ut_ad(block); ut_ad(block->state == BUF_BLOCK_FILE_PAGE); ut_ad(block->buf_fix_count > 0); +#ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX)); ut_ad(mutex_own(&(buf_pool->mutex))); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(ut_dulint_cmp(mtr->start_lsn, ut_dulint_zero) != 0); ut_ad(mtr->modifications); @@ -76,7 +78,9 @@ buf_flush_recv_note_modification( ut_ad(block); ut_ad(block->state == BUF_BLOCK_FILE_PAGE); ut_ad(block->buf_fix_count > 0); +#ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX)); +#endif /* UNIV_SYNC_DEBUG */ mutex_enter(&(buf_pool->mutex)); diff --git a/innobase/include/dict0dict.ic b/innobase/include/dict0dict.ic index c5982c162a7..b70822e331f 100644 --- a/innobase/include/dict0dict.ic +++ b/innobase/include/dict0dict.ic @@ -543,8 +543,10 @@ dict_table_check_if_in_cache_low( ulint table_fold; ut_ad(table_name); +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(dict_sys->mutex))); - +#endif /* UNIV_SYNC_DEBUG */ + /* Look for the table name in the hash table */ table_fold = ut_fold_string(table_name); @@ -566,8 +568,10 @@ dict_table_get_low( dict_table_t* table; ut_ad(table_name); +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(dict_sys->mutex))); - +#endif /* UNIV_SYNC_DEBUG */ + table = dict_table_check_if_in_cache_low(table_name); if (table == NULL) { @@ -621,7 +625,9 @@ dict_table_get_on_id_low( dict_table_t* table; ulint fold; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(dict_sys->mutex))); +#endif /* UNIV_SYNC_DEBUG */ UT_NOT_USED(trx); /* Look for the table name in the hash table */ diff --git a/innobase/include/fut0fut.ic b/innobase/include/fut0fut.ic index 0f1aa9dd9ae..6a107786376 100644 --- a/innobase/include/fut0fut.ic +++ b/innobase/include/fut0fut.ic @@ -30,7 +30,9 @@ fut_get_ptr( ptr = buf_page_get(space, addr.page, rw_latch, mtr) + addr.boffset; +#ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(ptr, SYNC_NO_ORDER_CHECK); +#endif /* UNIV_SYNC_DEBUG */ return(ptr); } diff --git a/innobase/include/ha0ha.ic b/innobase/include/ha0ha.ic index 761bc3b20de..f6faf84b9f5 100644 --- a/innobase/include/ha0ha.ic +++ b/innobase/include/ha0ha.ic @@ -84,7 +84,9 @@ ha_search( { ha_node_t* node; +#ifdef UNIV_SYNC_DEBUG ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold))); +#endif /* UNIV_SYNC_DEBUG */ node = ha_chain_get_first(table, fold); @@ -114,7 +116,9 @@ ha_search_and_get_data( { ha_node_t* node; +#ifdef UNIV_SYNC_DEBUG ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold))); +#endif /* UNIV_SYNC_DEBUG */ node = ha_chain_get_first(table, fold); @@ -146,7 +150,9 @@ ha_next( fold = node->fold; +#ifdef UNIV_SYNC_DEBUG ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold))); +#endif /* UNIV_SYNC_DEBUG */ node = ha_chain_get_next(table, node); @@ -176,7 +182,9 @@ ha_search_with_data( { ha_node_t* node; +#ifdef UNIV_SYNC_DEBUG ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold))); +#endif /* UNIV_SYNC_DEBUG */ node = ha_chain_get_first(table, fold); @@ -206,7 +214,9 @@ ha_search_and_update_if_found( { ha_node_t* node; +#ifdef UNIV_SYNC_DEBUG ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold))); +#endif /* UNIV_SYNC_DEBUG */ node = ha_search_with_data(table, fold, data); @@ -229,7 +239,9 @@ ha_search_and_delete_if_found( { ha_node_t* node; +#ifdef UNIV_SYNC_DEBUG ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold))); +#endif /* UNIV_SYNC_DEBUG */ node = ha_search_with_data(table, fold, data); diff --git a/innobase/include/hash0hash.h b/innobase/include/hash0hash.h index 2669520b753..d325636f511 100644 --- a/innobase/include/hash0hash.h +++ b/innobase/include/hash0hash.h @@ -53,15 +53,24 @@ hash_calc_hash( /* out: hashed value */ ulint fold, /* in: folded value */ hash_table_t* table); /* in: hash table */ +/************************************************************************ +Assert that the mutex for the table in a hash operation is owned. */ +#ifdef UNIV_SYNC_DEBUG +# define HASH_ASSERT_OWNED(TABLE, FOLD) \ +ut_ad(!(TABLE)->mutexes || mutex_own(hash_get_mutex(TABLE, FOLD))); +#else +# define HASH_ASSERT_OWNED(TABLE, FOLD) +#endif + /*********************************************************************** Inserts a struct to a hash table. */ #define HASH_INSERT(TYPE, NAME, TABLE, FOLD, DATA)\ -{\ +do {\ hash_cell_t* cell3333;\ TYPE* struct3333;\ \ - ut_ad(!(TABLE)->mutexes || mutex_own(hash_get_mutex(TABLE, FOLD)));\ + HASH_ASSERT_OWNED(TABLE, FOLD)\ \ (DATA)->NAME = NULL;\ \ @@ -79,17 +88,17 @@ Inserts a struct to a hash table. */ \ struct3333->NAME = DATA;\ }\ -} +} while (0) /*********************************************************************** Deletes a struct from a hash table. */ #define HASH_DELETE(TYPE, NAME, TABLE, FOLD, DATA)\ -{\ +do {\ hash_cell_t* cell3333;\ TYPE* struct3333;\ \ - ut_ad(!(TABLE)->mutexes || mutex_own(hash_get_mutex(TABLE, FOLD)));\ + HASH_ASSERT_OWNED(TABLE, FOLD)\ \ cell3333 = hash_get_nth_cell(TABLE, hash_calc_hash(FOLD, TABLE));\ \ @@ -100,13 +109,13 @@ Deletes a struct from a hash table. */ \ while (struct3333->NAME != DATA) {\ \ - ut_ad(struct3333)\ + ut_ad(struct3333);\ struct3333 = struct3333->NAME;\ }\ \ struct3333->NAME = DATA->NAME;\ }\ -} +} while (0) /*********************************************************************** Gets the first struct in a hash chain, NULL if none. */ @@ -124,7 +133,7 @@ Looks for a struct in a hash table. */ #define HASH_SEARCH(NAME, TABLE, FOLD, DATA, TEST)\ {\ \ - ut_ad(!(TABLE)->mutexes || mutex_own(hash_get_mutex(TABLE, FOLD)));\ + HASH_ASSERT_OWNED(TABLE, FOLD)\ \ (DATA) = HASH_GET_FIRST(TABLE, hash_calc_hash(FOLD, TABLE));\ \ @@ -160,7 +169,7 @@ the heap. The fold value must be stored in the struct NODE in a field named 'fold'. */ #define HASH_DELETE_AND_COMPACT(TYPE, NAME, TABLE, NODE)\ -{\ +do {\ TYPE* node111;\ TYPE* top_node111;\ hash_cell_t* cell111;\ @@ -211,33 +220,7 @@ the heap. The fold value must be stored in the struct NODE in a field named /* Free the space occupied by the top node */\ \ mem_heap_free_top(hash_get_heap(TABLE, fold111), sizeof(TYPE));\ -} - -/*********************************************************************** -Calculates the number of stored structs in a hash table. */ - -#define HASH_GET_N_NODES(TYPE, NAME, TABLE, N)\ -{\ - hash_cell_t* cell3333;\ - TYPE* struct3333;\ - ulint i3333;\ -\ - (N) = 0;\ -\ - for (i3333 = 0; i3333 < hash_get_n_cells(TABLE); i3333++) {\ -\ - cell3333 = hash_get_nth_cell(TABLE, i3333);\ -\ - struct3333 = cell3333->node;\ -\ - while (struct3333) {\ -\ - (N) = (N) + 1;\ -\ - struct = HASH_GET_NEXT(NAME, struct3333);\ - }\ - }\ -} +} while (0) /**************************************************************** Gets the mutex index for a fold value in a hash table. */ diff --git a/innobase/include/lock0lock.ic b/innobase/include/lock0lock.ic index 64c43c88d2e..fabc9256401 100644 --- a/innobase/include/lock0lock.ic +++ b/innobase/include/lock0lock.ic @@ -64,7 +64,9 @@ lock_clust_rec_some_has_impl( { dulint trx_id; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(index->type & DICT_CLUSTERED); ut_ad(page_rec_is_user_rec(rec)); diff --git a/innobase/include/log0log.ic b/innobase/include/log0log.ic index 8de239df0bd..587291883f7 100644 --- a/innobase/include/log0log.ic +++ b/innobase/include/log0log.ic @@ -255,7 +255,9 @@ log_block_init( { ulint no; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(log_sys->mutex))); +#endif /* UNIV_SYNC_DEBUG */ no = log_block_convert_lsn_to_no(lsn); @@ -277,7 +279,9 @@ log_block_init_in_old_format( { ulint no; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(log_sys->mutex))); +#endif /* UNIV_SYNC_DEBUG */ no = log_block_convert_lsn_to_no(lsn); @@ -407,7 +411,9 @@ log_get_online_backup_lsn_low(void) /* out: online_backup_lsn, the caller must own the log_sys mutex */ { +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(log_sys->mutex))); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(log_sys->online_backup_state); return(log_sys->online_backup_lsn); @@ -422,7 +428,9 @@ log_get_online_backup_state_low(void) /* out: online backup state, the caller must own the log_sys mutex */ { +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(log_sys->mutex))); +#endif /* UNIV_SYNC_DEBUG */ return(log_sys->online_backup_state); } diff --git a/innobase/include/row0upd.ic b/innobase/include/row0upd.ic index 7015b2eda13..3e00978be2f 100644 --- a/innobase/include/row0upd.ic +++ b/innobase/include/row0upd.ic @@ -107,8 +107,10 @@ row_upd_rec_sys_fields( dulint roll_ptr)/* in: roll ptr of the undo log record */ { ut_ad(index->type & DICT_CLUSTERED); +#ifdef UNIV_SYNC_DEBUG ut_ad(!buf_block_align(rec)->is_hashed || rw_lock_own(&btr_search_latch, RW_LOCK_EX)); +#endif /* UNIV_SYNC_DEBUG */ row_set_rec_trx_id(rec, index, trx->id); row_set_rec_roll_ptr(rec, index, roll_ptr); diff --git a/innobase/include/sync0rw.h b/innobase/include/sync0rw.h index 5aa3dcdffc3..d71691b4353 100644 --- a/innobase/include/sync0rw.h +++ b/innobase/include/sync0rw.h @@ -25,13 +25,16 @@ smaller than 30 and the order of the numerical values like below! */ #define RW_NO_LATCH 3 typedef struct rw_lock_struct rw_lock_t; +#ifdef UNIV_SYNC_DEBUG typedef struct rw_lock_debug_struct rw_lock_debug_t; +#endif /* UNIV_SYNC_DEBUG */ typedef UT_LIST_BASE_NODE_T(rw_lock_t) rw_lock_list_t; extern rw_lock_list_t rw_lock_list; extern mutex_t rw_lock_list_mutex; +#ifdef UNIV_SYNC_DEBUG /* The global mutex which protects debug info lists of all rw-locks. To modify the debug info list of an rw-lock, this mutex has to be @@ -42,6 +45,7 @@ extern os_event_t rw_lock_debug_event; /* If deadlock detection does may wait for this event */ extern ibool rw_lock_debug_waiters; /* This is set to TRUE, if there may be waiters for the event */ +#endif /* UNIV_SYNC_DEBUG */ extern ulint rw_s_system_call_count; extern ulint rw_s_spin_wait_count; @@ -327,6 +331,7 @@ ulint rw_lock_get_reader_count( /*=====================*/ rw_lock_t* lock); +#ifdef UNIV_SYNC_DEBUG /********************************************************************** Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0. */ @@ -337,6 +342,7 @@ rw_lock_own( rw_lock_t* lock, /* in: rw-lock */ ulint lock_type); /* in: lock type: RW_LOCK_SHARED, RW_LOCK_EX */ +#endif /* UNIV_SYNC_DEBUG */ /********************************************************************** Checks if somebody has locked the rw-lock in the specified mode. */ @@ -346,6 +352,7 @@ rw_lock_is_locked( rw_lock_t* lock, /* in: rw-lock */ ulint lock_type); /* in: lock type: RW_LOCK_SHARED, RW_LOCK_EX */ +#ifdef UNIV_SYNC_DEBUG /******************************************************************* Prints debug info of an rw-lock. */ @@ -392,6 +399,7 @@ void rw_lock_debug_print( /*================*/ rw_lock_debug_t* info); /* in: debug struct */ +#endif /* UNIV_SYNC_DEBUG */ /* NOTE! The structure appears here only for the compiler to know its size. Do not use its fields directly! The structure used in the spin lock @@ -434,10 +442,12 @@ struct rw_lock_struct { UT_LIST_NODE_T(rw_lock_t) list; /* All allocated rw locks are put into a list */ +#ifdef UNIV_SYNC_DEBUG UT_LIST_BASE_NODE_T(rw_lock_debug_t) debug_list; /* In the debug version: pointer to the debug info list of the lock */ - ulint level; /* Debug version: level in the global latching +#endif /* UNIV_SYNC_DEBUG */ + ulint level; /* Level in the global latching order; default SYNC_LEVEL_NONE */ char* cfile_name; /* File name where lock created */ ulint cline; /* Line where created */ @@ -450,6 +460,7 @@ struct rw_lock_struct { #define RW_LOCK_MAGIC_N 22643 +#ifdef UNIV_SYNC_DEBUG /* The structure for storing debug info of an rw-lock */ struct rw_lock_debug_struct { @@ -464,6 +475,7 @@ struct rw_lock_debug_struct { /* Debug structs are linked in a two-way list */ }; +#endif /* UNIV_SYNC_DEBUG */ #ifndef UNIV_NONINL #include "sync0rw.ic" diff --git a/innobase/include/sync0rw.ic b/innobase/include/sync0rw.ic index caf6f5f1de4..8fc93f4a9da 100644 --- a/innobase/include/sync0rw.ic +++ b/innobase/include/sync0rw.ic @@ -20,6 +20,7 @@ rw_lock_s_lock_spin( be passed to another thread to unlock */ char* file_name,/* in: file name where lock requested */ ulint line); /* in: line where requested */ +#ifdef UNIV_SYNC_DEBUG /********************************************************************** Inserts the debug information for an rw-lock. */ @@ -40,7 +41,7 @@ rw_lock_remove_debug_info( rw_lock_t* lock, /* in: rw-lock */ ulint pass, /* in: pass value */ ulint lock_type); /* in: lock type */ - +#endif /* UNIV_SYNC_DEBUG */ /************************************************************************ Accessor functions for rw lock. */ @@ -132,8 +133,9 @@ rw_lock_s_lock_low( char* file_name, /* in: file name where lock requested */ ulint line) /* in: line where requested */ { +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(rw_lock_get_mutex(lock))); - +#endif /* UNIV_SYNC_DEBUG */ /* Check if the writer field is free */ if (lock->writer == RW_LOCK_NOT_LOCKED) { @@ -144,7 +146,6 @@ rw_lock_s_lock_low( rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name, line); #endif - lock->last_s_file_name = file_name; lock->last_s_line = line; @@ -236,7 +237,9 @@ rw_lock_s_lock_func( the threads which have s-locked a latch. This would use some CPU time. */ +#ifdef UNIV_SYNC_DEBUG ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED)); /* see NOTE above */ +#endif /* UNIV_SYNC_DEBUG */ mutex_enter(rw_lock_get_mutex(lock)); diff --git a/innobase/include/sync0sync.h b/innobase/include/sync0sync.h index 71263f5d136..3acf3415889 100644 --- a/innobase/include/sync0sync.h +++ b/innobase/include/sync0sync.h @@ -185,6 +185,7 @@ sync_thread_levels_empty_gen( allowed to be owned by the thread, also purge_is_running mutex is allowed */ +#ifdef UNIV_SYNC_DEBUG /********************************************************************** Checks that the current thread owns the mutex. Works only in the debug version. */ @@ -217,6 +218,7 @@ Prints debug info of currently reserved mutexes. */ void mutex_list_print_info(void); /*========================*/ +#endif /* UNIV_SYNC_DEBUG */ /********************************************************************** NOT to be used outside this module except in debugging! Gets the value of the lock word. */ @@ -225,6 +227,7 @@ ulint mutex_get_lock_word( /*================*/ mutex_t* mutex); /* in: mutex */ +#ifdef UNIV_SYNC_DEBUG /********************************************************************** NOT to be used outside this module except in debugging! Gets the waiters field in a mutex. */ @@ -234,6 +237,7 @@ mutex_get_waiters( /*==============*/ /* out: value to set */ mutex_t* mutex); /* in: mutex */ +#endif /* UNIV_SYNC_DEBUG */ /* LATCHING ORDER WITHIN THE DATABASE @@ -442,13 +446,13 @@ struct mutex_struct { Otherwise, this is 0. */ UT_LIST_NODE_T(mutex_t) list; /* All allocated mutexes are put into a list. Pointers to the next and prev. */ +#ifdef UNIV_SYNC_DEBUG + const char* file_name; /* File where the mutex was locked */ + ulint line; /* Line where the mutex was locked */ os_thread_id_t thread_id; /* Debug version: The thread id of the thread which locked the mutex. */ - char* file_name; /* Debug version: File name where the mutex - was locked */ - ulint line; /* Debug version: Line where the mutex was - locked */ - ulint level; /* Debug version: level in the global latching +#endif /* UNIV_SYNC_DEBUG */ + ulint level; /* Level in the global latching order; default SYNC_LEVEL_NONE */ char* cfile_name; /* File name where mutex created */ ulint cline; /* Line where created */ diff --git a/innobase/include/sync0sync.ic b/innobase/include/sync0sync.ic index 816b44a5bd3..758c8524f66 100644 --- a/innobase/include/sync0sync.ic +++ b/innobase/include/sync0sync.ic @@ -25,6 +25,7 @@ mutex_spin_wait( mutex_t* mutex, /* in: pointer to mutex */ char* file_name,/* in: file name where mutex requested */ ulint line); /* in: line where requested */ +#ifdef UNIV_SYNC_DEBUG /********************************************************************** Sets the debug information for a reserved mutex. */ @@ -34,6 +35,7 @@ mutex_set_debug_info( mutex_t* mutex, /* in: mutex */ char* file_name, /* in: file where requested */ ulint line); /* in: line where requested */ +#endif /* UNIV_SYNC_DEBUG */ /********************************************************************** Releases the threads waiting in the primary wait array for this mutex. */ @@ -200,9 +202,9 @@ mutex_exit( /*=======*/ mutex_t* mutex) /* in: pointer to mutex */ { +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(mutex)); -#ifdef UNIV_SYNC_DEBUG mutex->thread_id = ULINT_UNDEFINED; sync_thread_reset_level(mutex); @@ -249,14 +251,9 @@ mutex_enter_func( the atomic test_and_set; we could peek, and possibly save time. */ if (!mutex_test_and_set(mutex)) { - #ifdef UNIV_SYNC_DEBUG mutex_set_debug_info(mutex, file_name, line); #endif - - mutex->file_name = file_name; - mutex->line = line; - return; /* Succeeded! */ } diff --git a/innobase/include/trx0rseg.ic b/innobase/include/trx0rseg.ic index 423447d5566..840d61a6840 100644 --- a/innobase/include/trx0rseg.ic +++ b/innobase/include/trx0rseg.ic @@ -24,7 +24,9 @@ trx_rsegf_get( header = TRX_RSEG + buf_page_get(space, page_no, RW_X_LATCH, mtr); +#ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(header, SYNC_RSEG_HEADER); +#endif /* UNIV_SYNC_DEBUG */ return(header); } @@ -45,7 +47,9 @@ trx_rsegf_get_new( header = TRX_RSEG + buf_page_get(space, page_no, RW_X_LATCH, mtr); +#ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(header, SYNC_RSEG_HEADER_NEW); +#endif /* UNIV_SYNC_DEBUG */ return(header); } diff --git a/innobase/include/trx0sys.ic b/innobase/include/trx0sys.ic index 343e6d7c2fa..8f455e554ea 100644 --- a/innobase/include/trx0sys.ic +++ b/innobase/include/trx0sys.ic @@ -60,7 +60,9 @@ trx_sys_get_nth_rseg( trx_sys_t* sys, /* in: trx system */ ulint n) /* in: index of slot */ { +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(kernel_mutex))); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(n < TRX_SYS_N_RSEGS); return(sys->rseg_array[n]); @@ -98,7 +100,9 @@ trx_sysf_get( header = TRX_SYS + buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, RW_X_LATCH, mtr); +#ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(header, SYNC_TRX_SYS_HEADER); +#endif /* UNIV_SYNC_DEBUG */ return(header); } @@ -115,7 +119,9 @@ trx_sysf_rseg_get_space( ulint i, /* in: slot index == rseg id */ mtr_t* mtr) /* in: mtr */ { +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(kernel_mutex))); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(sys_header); ut_ad(i < TRX_SYS_N_RSEGS); @@ -138,7 +144,9 @@ trx_sysf_rseg_get_page_no( mtr_t* mtr) /* in: mtr */ { ut_ad(sys_header); +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(kernel_mutex))); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(i < TRX_SYS_N_RSEGS); return(mtr_read_ulint(sys_header + TRX_SYS_RSEGS @@ -158,7 +166,9 @@ trx_sysf_rseg_set_space( ulint space, /* in: space id */ mtr_t* mtr) /* in: mtr */ { +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(kernel_mutex))); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(sys_header); ut_ad(i < TRX_SYS_N_RSEGS); @@ -182,7 +192,9 @@ trx_sysf_rseg_set_page_no( slot is reset to unused */ mtr_t* mtr) /* in: mtr */ { +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(kernel_mutex))); +#endif /* UNIV_SYNC_DEBUG */ ut_ad(sys_header); ut_ad(i < TRX_SYS_N_RSEGS); @@ -236,7 +248,9 @@ trx_get_on_id( { trx_t* trx; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(kernel_mutex))); +#endif /* UNIV_SYNC_DEBUG */ trx = UT_LIST_GET_FIRST(trx_sys->trx_list); @@ -266,7 +280,9 @@ trx_list_get_min_trx_id(void) { trx_t* trx; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(kernel_mutex))); +#endif /* UNIV_SYNC_DEBUG */ trx = UT_LIST_GET_LAST(trx_sys->trx_list); @@ -289,7 +305,9 @@ trx_is_active( { trx_t* trx; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(kernel_mutex))); +#endif /* UNIV_SYNC_DEBUG */ if (ut_dulint_cmp(trx_id, trx_list_get_min_trx_id()) < 0) { @@ -325,7 +343,9 @@ trx_sys_get_new_trx_id(void) { dulint id; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ /* VERY important: after the database is started, max_trx_id value is divisible by TRX_SYS_TRX_ID_WRITE_MARGIN, and the following if @@ -355,7 +375,9 @@ trx_sys_get_new_trx_no(void) /*========================*/ /* out: new, allocated trx number */ { +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ return(trx_sys_get_new_trx_id()); } diff --git a/innobase/include/trx0undo.ic b/innobase/include/trx0undo.ic index bedbc02b00b..a04b234b495 100644 --- a/innobase/include/trx0undo.ic +++ b/innobase/include/trx0undo.ic @@ -126,7 +126,9 @@ trx_undo_page_get( page = buf_page_get(space, page_no, RW_X_LATCH, mtr); +#ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(page, SYNC_TRX_UNDO_PAGE); +#endif /* UNIV_SYNC_DEBUG */ return(page); } @@ -146,7 +148,9 @@ trx_undo_page_get_s_latched( page = buf_page_get(space, page_no, RW_S_LATCH, mtr); +#ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(page, SYNC_TRX_UNDO_PAGE); +#endif /* UNIV_SYNC_DEBUG */ return(page); } |