diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c
index 5f03cf43e2915117525eed5b05aeb13f9c3d72a5..e2c2043db74a023cd65a7bbeab33b704cd0c90f8 100644
--- a/innobase/dict/dict0dict.c
+++ b/innobase/dict/dict0dict.c
@@ -3392,9 +3392,9 @@ dict_tree_create(
 	tree->id = index->id;
 	
 	UT_LIST_INIT(tree->tree_indexes);
-#ifdef UNIV_DEBUG
+
 	tree->magic_n = DICT_TREE_MAGIC_N;
-#endif /* UNIV_DEBUG */
+
 	rw_lock_create(&(tree->lock));
 
 	rw_lock_set_level(&(tree->lock), SYNC_INDEX_TREE);
diff --git a/innobase/dict/dict0mem.c b/innobase/dict/dict0mem.c
index c4b393d292b430e0b1afd3002bc617c2773b276f..85bd79a72f5063565e897f1c181930951e9f89ee 100644
--- a/innobase/dict/dict0mem.c
+++ b/innobase/dict/dict0mem.c
@@ -88,9 +88,9 @@ dict_mem_table_create(
 	mutex_set_level(&(table->autoinc_mutex), SYNC_DICT_AUTOINC_MUTEX);
 
 	table->autoinc_inited = FALSE;
-#ifdef UNIV_DEBUG
+
 	table->magic_n = DICT_TABLE_MAGIC_N;
-#endif /* UNIV_DEBUG */
+	
 	return(table);
 }
 
@@ -205,9 +205,7 @@ dict_mem_index_create(
 	index->stat_n_diff_key_vals = NULL;
 
 	index->cached = FALSE;
-#ifdef UNIV_DEBUG
 	index->magic_n = DICT_INDEX_MAGIC_N;
-#endif /* UNIV_DEBUG */
 
 	return(index);
 }
diff --git a/innobase/ha/hash0hash.c b/innobase/ha/hash0hash.c
index 808aa88da3df4327aabd7eaf999d2a601a21dd9b..1f7edf9d7d29cff2ef075a3d934e6255f61675b9 100644
--- a/innobase/ha/hash0hash.c
+++ b/innobase/ha/hash0hash.c
@@ -22,7 +22,6 @@ hash_mutex_enter(
 	hash_table_t* 	table,	/* in: hash table */
 	ulint 		fold)	/* in: fold */
 {
-	ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
 	mutex_enter(hash_get_mutex(table, fold));
 }
 
@@ -35,10 +34,41 @@ hash_mutex_exit(
 	hash_table_t* 	table,	/* in: hash table */
 	ulint 		fold)	/* in: fold */
 {
-	ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
 	mutex_exit(hash_get_mutex(table, fold));
 }
 
+/****************************************************************
+Reserves all the mutexes of a hash table, in an ascending order. */
+
+void
+hash_mutex_enter_all(
+/*=================*/
+	hash_table_t* 	table)	/* in: hash table */
+{
+	ulint	i;
+
+	for (i = 0; i < table->n_mutexes; i++) {
+
+		mutex_enter(table->mutexes + i);
+	}
+}
+
+/****************************************************************
+Releases all the mutexes of a hash table. */
+
+void
+hash_mutex_exit_all(
+/*================*/
+	hash_table_t* 	table)	/* in: hash table */
+{
+	ulint	i;
+
+	for (i = 0; i < table->n_mutexes; i++) {
+
+		mutex_exit(table->mutexes + i);
+	}
+}
+
 /*****************************************************************
 Creates a hash table with >= n array cells. The actual number of cells is
 chosen to be a prime number slightly bigger than n. */
@@ -67,9 +97,7 @@ hash_create(
 	table->mutexes = NULL;
 	table->heaps = NULL;
 	table->heap = NULL;
-#ifdef UNIV_DEBUG
 	table->magic_n = HASH_TABLE_MAGIC_N;
-#endif /* UNIV_DEBUG */
 	
 	/* Initialize the cell array */
 
@@ -90,7 +118,6 @@ hash_table_free(
 /*============*/
 	hash_table_t*	table)	/* in, own: hash table */
 {
-	ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
 	ut_a(table->mutexes == NULL);
 
 	ut_free(table->array);
@@ -112,7 +139,6 @@ hash_create_mutexes(
 	ulint	i;
 
 	ut_a(n_mutexes == ut_2_power_up(n_mutexes));
-	ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
 
 	table->mutexes = mem_alloc(n_mutexes * sizeof(mutex_t));
 
diff --git a/innobase/include/data0data.h b/innobase/include/data0data.h
index 99d3c29703918d6412eadcb53a0f66594d266866..80207631dd9fef435248fbaba027056dad3c439c 100644
--- a/innobase/include/data0data.h
+++ b/innobase/include/data0data.h
@@ -395,11 +395,9 @@ struct dtuple_struct {
 	UT_LIST_NODE_T(dtuple_t) tuple_list;
 					/* data tuples can be linked into a
 					list using this field */
-#ifdef UNIV_DEBUG
-	ulint		magic_n;
-#define	DATA_TUPLE_MAGIC_N	65478679
-#endif /* UNIV_DEBUG */
+	ulint		magic_n;	
 };
+#define	DATA_TUPLE_MAGIC_N	65478679
 
 /* A slot for a field in a big rec vector */
 
diff --git a/innobase/include/dict0mem.h b/innobase/include/dict0mem.h
index 439adf6f52ed006841567b891d25fd5645fa9a26..6d6e95ab511d6e7ca701817c816a2b7e78448714 100644
--- a/innobase/include/dict0mem.h
+++ b/innobase/include/dict0mem.h
@@ -186,12 +186,11 @@ struct dict_tree_struct{
 				the list; if the tree is of the mixed
 				type, the first index in the list is the
 				index of the cluster which owns the tree */
-#ifdef UNIV_DEBUG
 	ulint		magic_n;/* magic number */
-#define	DICT_TREE_MAGIC_N	7545676
-#endif /* UNIV_DEBUG */
 };
 
+#define	DICT_TREE_MAGIC_N	7545676
+
 /* Data structure for an index */
 struct dict_index_struct{
 	dulint		id;	/* id of the index */
@@ -236,10 +235,7 @@ struct dict_index_struct{
 	ulint		stat_n_leaf_pages;
 				/* approximate number of leaf pages in the
 				index tree */
-#ifdef UNIV_DEBUG
 	ulint		magic_n;/* magic number */
-#define	DICT_INDEX_MAGIC_N	76789786
-#endif /* UNIV_DEBUG */
 };
 
 /* Data structure for a foreign key constraint; an example:
@@ -290,6 +286,9 @@ a foreign key constraint is enforced, therefore RESTRICT just means no flag */
 #define DICT_FOREIGN_ON_DELETE_NO_ACTION 16
 #define DICT_FOREIGN_ON_UPDATE_NO_ACTION 32
 
+
+#define	DICT_INDEX_MAGIC_N	76789786
+
 /* Data structure for a database table */
 struct dict_table_struct{
 	dulint		id;	/* id of the table or cluster */
@@ -401,12 +400,10 @@ struct dict_table_struct{
 				inited; MySQL gets the init value by executing
 				SELECT MAX(auto inc column) */
 	ib_longlong	autoinc;/* autoinc counter value to give to the
-				next inserted row */
-#ifdef UNIV_DEBUG
+				next inserted row */	
 	ulint		magic_n;/* magic number */
-#define	DICT_TABLE_MAGIC_N	76333786
-#endif /* UNIV_DEBUG */
 };
+#define	DICT_TABLE_MAGIC_N	76333786
 					
 #ifndef UNIV_NONINL
 #include "dict0mem.ic"
diff --git a/innobase/include/hash0hash.h b/innobase/include/hash0hash.h
index d325636f51185c27fb16509b8f9c54519f445548..101cb5d434f5063b1a44f3c35f455ea0a4322512 100644
--- a/innobase/include/hash0hash.h
+++ b/innobase/include/hash0hash.h
@@ -283,6 +283,21 @@ hash_mutex_exit(
 /*============*/
 	hash_table_t* 	table,	/* in: hash table */
 	ulint 		fold);	/* in: fold */
+/****************************************************************
+Reserves all the mutexes of a hash table, in an ascending order. */
+
+void
+hash_mutex_enter_all(
+/*=================*/
+	hash_table_t* 	table);	/* in: hash table */
+/****************************************************************
+Releases all the mutexes of a hash table. */
+
+void
+hash_mutex_exit_all(
+/*================*/
+	hash_table_t* 	table);	/* in: hash table */
+
 
 struct hash_cell_struct{
 	void*	node;	/* hash chain node, NULL if none */
@@ -301,12 +316,11 @@ struct hash_table_struct {
 				memory heaps; there are then n_mutexes many of
 				these heaps */
 	mem_heap_t*	heap;
-#ifdef UNIV_DEBUG
 	ulint		magic_n;
-#define HASH_TABLE_MAGIC_N	76561114
-#endif /* UNIV_DEBUG */
 };
 
+#define HASH_TABLE_MAGIC_N	76561114
+
 #ifndef UNIV_NONINL
 #include "hash0hash.ic"
 #endif
diff --git a/innobase/include/hash0hash.ic b/innobase/include/hash0hash.ic
index 1b9acfa2f34c71f64a5efc3b0dbcb7beb3128b28..0d713140c13c979cf2e3ab63b4261f4d37517671 100644
--- a/innobase/include/hash0hash.ic
+++ b/innobase/include/hash0hash.ic
@@ -18,7 +18,6 @@ hash_get_nth_cell(
 	hash_table_t* 	table,	/* in: hash table */
 	ulint 		n)	/* in: cell index */
 {
-	ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
 	ut_ad(n < table->n_cells);
 
 	return(table->array + n);
@@ -33,7 +32,6 @@ hash_get_n_cells(
 				/* out: number of cells */
 	hash_table_t*	table)	/* in: table */
 {
-	ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
 	return(table->n_cells);
 }
 
@@ -47,7 +45,6 @@ hash_calc_hash(
 	ulint		fold,	/* in: folded value */
 	hash_table_t*	table)	/* in: hash table */
 {
-	ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
 	return(ut_hash_ulint(fold, table->n_cells));
 }
 
@@ -61,7 +58,6 @@ hash_get_mutex_no(
 	hash_table_t* 	table,	/* in: hash table */
 	ulint 		fold)	/* in: fold */
 {
-	ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
 	return(ut_2pow_remainder(fold, table->n_mutexes));
 }
 
@@ -75,7 +71,6 @@ hash_get_nth_heap(
 	hash_table_t* 	table,	/* in: hash table */
 	ulint 		i)	/* in: index of the heap */
 {
-	ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
 	ut_ad(i < table->n_mutexes);
 
 	return(table->heaps[i]);
@@ -93,8 +88,6 @@ hash_get_heap(
 {
 	ulint	i;
 
-	ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
-
 	if (table->heap) {
 		return(table->heap);
 	}
@@ -114,7 +107,6 @@ hash_get_nth_mutex(
 	hash_table_t* 	table,	/* in: hash table */
 	ulint 		i)	/* in: index of the mutex */
 {
-	ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
 	ut_ad(i < table->n_mutexes);
 	
 	return(table->mutexes + i);
diff --git a/innobase/include/mtr0mtr.h b/innobase/include/mtr0mtr.h
index 112a1e50e15c0d84ceafde2f4854b3f457cac56a..5e22ad0c5988d0358372159996ba5ae6229555ee 100644
--- a/innobase/include/mtr0mtr.h
+++ b/innobase/include/mtr0mtr.h
@@ -279,12 +279,7 @@ struct mtr_memo_slot_struct{
 
 /* Mini-transaction handle and buffer */
 struct mtr_struct{
-#ifdef UNIV_DEBUG
 	ulint		state;	/* MTR_ACTIVE, MTR_COMMITTING, MTR_COMMITTED */
-#define MTR_ACTIVE		12231
-#define MTR_COMMITTING		56456
-#define MTR_COMMITTED		34676
-#endif /* UNIV_DEBUG */
 	dyn_array_t	memo;	/* memo stack for locks etc. */
 	dyn_array_t	log;	/* mini-transaction log */
 	ibool		modifications;
@@ -299,12 +294,15 @@ struct mtr_struct{
 				this mtr */
 	dulint		end_lsn;/* end lsn of the possible log entry for
 				this mtr */
-#ifdef UNIV_DEBUG
 	ulint		magic_n;
-#define	MTR_MAGIC_N		54551
-#endif /* UNIV_DEBUG */
 };
 
+#define	MTR_MAGIC_N		54551
+
+#define MTR_ACTIVE		12231
+#define MTR_COMMITTING		56456
+#define MTR_COMMITTED		34676
+	
 #ifndef UNIV_NONINL
 #include "mtr0mtr.ic"
 #endif
diff --git a/innobase/include/row0ins.h b/innobase/include/row0ins.h
index f3f0b7e8ecabd99ebc0fff46506fac02c14378e5..a5b4b74e7fccecf18eeb396d80c3534cfe2f99a7 100644
--- a/innobase/include/row0ins.h
+++ b/innobase/include/row0ins.h
@@ -145,12 +145,11 @@ struct ins_node_struct{
 				entry_list and sys fields are stored here;
 				if this is NULL, entry list should be created
 				and buffers for sys fields in row allocated */
-#ifdef UNIV_DEBUG
 	ulint		magic_n;
-#define	INS_NODE_MAGIC_N	15849075
-#endif /* UNIV_DEBUG */
 };
 
+#define	INS_NODE_MAGIC_N	15849075
+
 /* Insert node types */
 #define INS_SEARCHED	0	/* INSERT INTO ... SELECT ... */
 #define INS_VALUES	1	/* INSERT INTO ... VALUES ... */
diff --git a/innobase/include/row0upd.h b/innobase/include/row0upd.h
index 687e90deee52b2b872519ab310c3ed92714bce77..f5e0a88231f43b2cdc387fb0d15ececeeb7707ca 100644
--- a/innobase/include/row0upd.h
+++ b/innobase/include/row0upd.h
@@ -384,12 +384,11 @@ struct upd_node_struct{
 	sym_node_t*	table_sym;/* table node in symbol table */
 	que_node_t*	col_assign_list;
 				/* column assignment list */
-#ifdef UNIV_DEBUG
 	ulint		magic_n;
-#define	UPD_NODE_MAGIC_N	1579975
-#endif /* UNIV_DEBUG */
 };
 
+#define	UPD_NODE_MAGIC_N	1579975
+
 /* Node execution states */
 #define UPD_NODE_SET_IX_LOCK	   1	/* execution came to the node from
 					a node above and if the field
diff --git a/innobase/row/row0ins.c b/innobase/row/row0ins.c
index 8f1c1370f256e52493574c164e9ebbb0881f01f6..93d360eaaeba1cd1fee245ad8b75d44488e1eb52 100644
--- a/innobase/row/row0ins.c
+++ b/innobase/row/row0ins.c
@@ -80,9 +80,9 @@ ins_node_create(
 	node->trx_id = ut_dulint_zero;
 	
 	node->entry_sys_heap = mem_heap_create(128);
-#ifdef UNIV_DEBUG
-	node->magic_n = INS_NODE_MAGIC_N;
-#endif /* UNIV_DEBUG */
+
+	node->magic_n = INS_NODE_MAGIC_N;	
+	
 	return(node);
 }
 
@@ -194,7 +194,6 @@ ins_node_set_new_row(
 	ins_node_t*	node,	/* in: insert node */
 	dtuple_t*	row)	/* in: new row (or first row) for the node */
 {
-	ut_ad(node->magic_n == INS_NODE_MAGIC_N);
 	node->state = INS_NODE_SET_IX_LOCK;
 	node->index = NULL;
 	node->entry = NULL;
@@ -2004,7 +2003,6 @@ row_ins(
 	ulint	err;
 	
 	ut_ad(node && thr);
-	ut_ad(node->magic_n == INS_NODE_MAGIC_N);
 
 	if (node->state == INS_NODE_ALLOC_ROW_ID) {
 
@@ -2069,7 +2067,7 @@ row_ins_step(
 	trx_start_if_not_started(trx);
 	
 	node = thr->run_node;
-	ut_ad(node->magic_n == INS_NODE_MAGIC_N);
+
 	ut_ad(que_node_get_type(node) == QUE_NODE_INSERT);
 
 	parent = que_node_get_parent(node);
diff --git a/innobase/row/row0upd.c b/innobase/row/row0upd.c
index e7894e543bcc3ce20724843a7385fd13b1c53430..22f7ba60ca409a177d2bb9e7f402d3de57f04110 100644
--- a/innobase/row/row0upd.c
+++ b/innobase/row/row0upd.c
@@ -287,9 +287,7 @@ upd_node_create(
 	node->select = NULL;
 	
 	node->heap = mem_heap_create(128);
-#ifdef UNIV_DEBUG
-	node->magic_n = UPD_NODE_MAGIC_N;
-#endif /* UNIV_DEBUG */
+	node->magic_n = UPD_NODE_MAGIC_N;	
 
 	node->cmpl_info = 0;
 	
@@ -1805,7 +1803,6 @@ row_upd_step(
 	trx_start_if_not_started(trx);
 
 	node = thr->run_node;
-	ut_ad(node->magic_n == UPD_NODE_MAGIC_N);
 	
 	sel_node = node->select;
 
@@ -1925,7 +1922,6 @@ row_upd_in_place_in_select(
 
 	node = que_node_get_parent(sel_node);
 
-	ut_ad(node->magic_n == UPD_NODE_MAGIC_N);
 	ut_ad(que_node_get_type(node) == QUE_NODE_UPDATE);
 
 	pcur = node->pcur;
diff --git a/innobase/thr/thr0loc.c b/innobase/thr/thr0loc.c
index a17d09fcca6166f5c5b7332ec6678eeb499d76d8..033bb22807f28ed6be8cf8e7c51332eb422b8c70 100644
--- a/innobase/thr/thr0loc.c
+++ b/innobase/thr/thr0loc.c
@@ -46,12 +46,11 @@ struct thr_local_struct{
 	ibool		in_ibuf;/* TRUE if the the thread is doing an ibuf
 				operation */
 	hash_node_t	hash;	/* hash chain node */
-#ifdef UNIV_DEBUG
 	ulint		magic_n;
-#define THR_LOCAL_MAGIC_N	1231234
-#endif /* UNIV_DEBUG */
 };
 
+#define THR_LOCAL_MAGIC_N	1231234
+
 /***********************************************************************
 Returns the local storage struct for a thread. */
 static
@@ -170,9 +169,8 @@ thr_local_create(void)
 
 	local->id = os_thread_get_curr_id();
 	local->handle = os_thread_get_curr();
-#ifdef UNIV_DEBUG
 	local->magic_n = THR_LOCAL_MAGIC_N;
-#endif /* UNIV_DEBUG */
+
  	local->in_ibuf = FALSE;
 	
 	mutex_enter(&thr_local_mutex);
@@ -211,7 +209,7 @@ thr_local_free(
 
 	mutex_exit(&thr_local_mutex);
 				
-	ut_ad(local->magic_n == THR_LOCAL_MAGIC_N);
+	ut_a(local->magic_n == THR_LOCAL_MAGIC_N);
 	
 	mem_free(local);
 }
diff --git a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c
index 43dd457c540677f43b581d820b4b1f95c24e569a..3601599358ff3818d6c6399d27729be5b71664f8 100644
--- a/innobase/trx/trx0sys.c
+++ b/innobase/trx/trx0sys.c
@@ -599,7 +599,6 @@ trx_sys_update_mysql_binlog_offset(
 				MLOG_4BYTES, mtr);				
 }
 
-#ifdef UNIV_HOTBACKUP
 /*********************************************************************
 Prints to stderr the MySQL binlog info in the system header if the
 magic number shows it valid. */
@@ -627,7 +626,6 @@ trx_sys_print_mysql_binlog_offset_from_page(
 		sys_header + TRX_SYS_MYSQL_LOG_INFO + TRX_SYS_MYSQL_LOG_NAME);
 	}
 }
-#endif /* UNIV_HOTBACKUP */
 
 /*********************************************************************
 Prints to stderr the MySQL binlog offset info in the trx system header if