List:Commits« Previous MessageNext Message »
From:Sunny Bains Date:May 5 2010 7:40am
Subject:bzr commit into mysql-trunk-innodb branch (Sunny.Bains:3047)
View as plain text  
#At file:///Users/sunny/innodb/bzr/kernel_mutex_split/ based on revid:sunny.bains@stripped

 3047 Sunny Bains	2010-05-05
      Rename read_view_close() to read_view_remove().
      Acquire the trx_sys->mutex before calling read_view_remove(). We do this so
      that we can cover the trx->global_read_view and trx->read_view too.

    modified:
      storage/innobase/include/read0read.h
      storage/innobase/read/read0read.c
      storage/innobase/trx/trx0purge.c
      storage/innobase/trx/trx0trx.c
=== modified file 'storage/innobase/include/read0read.h'
--- a/storage/innobase/include/read0read.h	revid:sunny.bains@stripped
+++ b/storage/innobase/include/read0read.h	revid:sunny.bains@stripped
@@ -61,11 +61,11 @@ read_view_oldest_copy_or_open_new(
 	mem_heap_t*	heap);		/*!< in: memory heap from which
 					allocated */
 /*********************************************************************//**
-Closes a read view. */
+Remove read view from the trx_sys->view_list. */
 UNIV_INTERN
 void
-read_view_close(
-/*============*/
+read_view_remove(
+/*=============*/
 	read_view_t*	view);	/*!< in: read view */
 /*********************************************************************//**
 Closes a consistent read view for MySQL. This function is called at an SQL

=== modified file 'storage/innobase/read/read0read.c'
--- a/storage/innobase/read/read0read.c	revid:sunny.bains@stripped
+++ b/storage/innobase/read/read0read.c	revid:sunny.bains@stripped
@@ -319,18 +319,16 @@ read_view_open_now(
 }
 
 /*********************************************************************//**
-Closes a read view. */
+Remove a read view from the trx_sys->view_list. */
 UNIV_INTERN
 void
-read_view_close(
+read_view_remove(
 /*============*/
 	read_view_t*	view)	/*!< in: read view */
 {
-	trx_sys_mutex_enter();
+	ut_ad(trx_sys_mutex_own());
 
 	UT_LIST_REMOVE(view_list, trx_sys->view_list, view);
-
-	trx_sys_mutex_exit();
 }
 
 /*********************************************************************//**
@@ -342,14 +340,18 @@ read_view_close_for_mysql(
 /*======================*/
 	trx_t*	trx)	/*!< in: trx which has a read view */
 {
+	trx_sys_mutex_enter();
+
 	ut_a(trx->global_read_view);
 
-	read_view_close(trx->global_read_view);
+	read_view_remove(trx->global_read_view);
 
 	mem_heap_empty(trx->global_read_view_heap);
 
 	trx->read_view = NULL;
 	trx->global_read_view = NULL;
+
+	trx_sys_mutex_exit();
 }
 
 /*********************************************************************//**
@@ -425,8 +427,11 @@ read_cursor_view_create_for_mysql(
 	curview->n_mysql_tables_in_use = cr_trx->n_mysql_tables_in_use;
 	cr_trx->n_mysql_tables_in_use = 0;
 
+	// FIXME: See next FIXME
 	mutex_enter(&kernel_mutex);
 
+	trx_sys_mutex_enter();
+
 	curview->read_view = read_view_create_low(
 		UT_LIST_GET_LEN(trx_sys->trx_list), curview->heap);
 
@@ -447,6 +452,11 @@ read_cursor_view_create_for_mysql(
 
 	while (trx) {
 
+		// FIXME: This can change behind our back, in fact this
+		// transaction change state needs careful consideration
+		// as it ties in with locking. Quick fix for now is to
+		// acquire the kernel mutex before the trx_sys->mutex
+		// but that is a sub-optimal fix.
 		if (trx->conc_state == TRX_ACTIVE
 		    || trx->conc_state == TRX_PREPARED) {
 
@@ -482,6 +492,8 @@ read_cursor_view_create_for_mysql(
 
 	mutex_exit(&kernel_mutex);
 
+	trx_sys_mutex_exit();
+
 	return(curview);
 }
 
@@ -503,12 +515,13 @@ read_cursor_view_close_for_mysql(
 	belong to this transaction */
 	trx->n_mysql_tables_in_use += curview->n_mysql_tables_in_use;
 
-	mutex_enter(&kernel_mutex);
+	trx_sys_mutex_enter();
+
+	read_view_remove(curview->read_view);
 
-	read_view_close(curview->read_view);
 	trx->read_view = trx->global_read_view;
 
-	mutex_exit(&kernel_mutex);
+	trx_sys_mutex_exit();
 
 	mem_heap_free(curview->heap);
 }
@@ -526,7 +539,7 @@ read_cursor_set_for_mysql(
 {
 	ut_a(trx);
 
-	mutex_enter(&kernel_mutex);
+	trx_sys_mutex_enter();
 
 	if (UNIV_LIKELY(curview != NULL)) {
 		trx->read_view = curview->read_view;
@@ -534,5 +547,5 @@ read_cursor_set_for_mysql(
 		trx->read_view = trx->global_read_view;
 	}
 
-	mutex_exit(&kernel_mutex);
+	trx_sys_mutex_exit();
 }

=== modified file 'storage/innobase/trx/trx0purge.c'
--- a/storage/innobase/trx/trx0purge.c	revid:sunny.bains@stripped
+++ b/storage/innobase/trx/trx0purge.c	revid:sunny.bains@stripped
@@ -282,14 +282,13 @@ trx_purge_sys_close(void)
 	purge_sys->sess = NULL;
 
 	if (purge_sys->view != NULL) {
-		/* Because acquiring the kernel mutex is a pre-condition
-		of read_view_close(). We don't really need it here. */
-		mutex_enter(&kernel_mutex);
+		trx_sys_mutex_enter();
 
-		read_view_close(purge_sys->view);
-		purge_sys->view = NULL;
+		read_view_remove(purge_sys->view);
 
-		mutex_exit(&kernel_mutex);
+		trx_sys_mutex_exit();
+
+		purge_sys->view = NULL;
 	}
 
 	trx_undo_arr_free(purge_sys->arr);
@@ -1131,7 +1130,11 @@ trx_purge(
 
 	/* Close and free the old purge view */
 
-	read_view_close(purge_sys->view);
+	trx_sys_mutex_enter();
+
+	read_view_remove(purge_sys->view);
+
+	trx_sys_mutex_exit();
 
 	purge_sys->view = NULL;
 

=== modified file 'storage/innobase/trx/trx0trx.c'
--- a/storage/innobase/trx/trx0trx.c	revid:sunny.bains@stripped
+++ b/storage/innobase/trx/trx0trx.c	revid:sunny.bains@stripped
@@ -852,12 +852,16 @@ trx_commit_off_kernel(
 
 	lock_release_off_kernel(trx);
 
+	trx_sys_mutex_enter();
+
 	if (trx->global_read_view) {
-		read_view_close(trx->global_read_view);
+		read_view_remove(trx->global_read_view);
 		mem_heap_empty(trx->global_read_view_heap);
 		trx->global_read_view = NULL;
 	}
 
+	trx_sys_mutex_exit();
+
 	trx->read_view = NULL;
 
 	if (lsn) {
@@ -991,9 +995,9 @@ trx_assign_read_view(
 		trx->read_view = read_view_open_now(
 			trx->id, trx->global_read_view_heap);
 
-		trx_sys_mutex_exit();
-
 		trx->global_read_view = trx->read_view;
+
+		trx_sys_mutex_exit();
 	}
 
 	return(trx->read_view);


Attachment: [text/bzr-bundle] bzr/sunny.bains@oracle.com-20100505073829-lamtzl3cq4y74iwm.bundle
Thread
bzr commit into mysql-trunk-innodb branch (Sunny.Bains:3047) Sunny Bains5 May