List:Commits« Previous MessageNext Message »
From:Sunny Bains Date:April 30 2010 4:22am
Subject:bzr commit into mysql-trunk-innodb branch (Sunny.Bains:3050)
View as plain text  
#At file:///Users/sunny/innodb/bzr/mysql-trunk-innodb/ based on revid:sunny.bains@stripped

 3050 Sunny Bains	2010-04-30
      Add comments
      Create the per purge node undo recs vector lazily
      Add assertion to check for latching order violation when incrementing
      purge_sys->n_completed. The code is safe when used with atomics though.

    modified:
      storage/innobase/row/row0purge.c
      storage/innobase/trx/trx0purge.c
=== modified file 'storage/innobase/row/row0purge.c'
--- a/storage/innobase/row/row0purge.c	revid:sunny.bains@stripped
+++ b/storage/innobase/row/row0purge.c	revid:sunny.bains@stripped
@@ -769,6 +769,11 @@ row_purge_end(
 
 	mem_heap_empty(node->heap);
 
+	/* The purge sys mutex is at a higher level than the
+	kernel mutex, make sure that the order is not violated.
+	The code will however work with atomics. */
+	ut_ad(!mutex_own(&kernel_mutex));
+
 	os_atomic_inc_ulint(&purge_sys->mutex, &purge_sys->n_completed, 1);
 }
 
@@ -792,7 +797,7 @@ row_purge_step(
 
 	ut_a(node->undo_recs);
 
-	if (!ib_vector_is_empty(node->undo_recs)) {
+	if (!(node->undo_recs == NULL || ib_vector_is_empty(node->undo_recs))) {
 		trx_purge_rec_t*purge_rec;
 
 		purge_rec = ib_vector_pop(node->undo_recs);

=== 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
@@ -1096,24 +1096,8 @@ trx_purge_attach_undo_recs(
 
 	ut_ad(mutex_own(&purge_sys->mutex));
 
-	thr = UT_LIST_GET_FIRST(purge_sys->query->thrs);
-
-	while (thr) {
-		purge_node_t*	node;
-
-		ut_a(!thr->is_active);
-
-		/* Get the purge node. */
-		node = thr->child;
-
-		ut_a(que_node_get_type(node) == QUE_NODE_PURGE);
-		ut_a(node->undo_recs == NULL);
-
-		node->undo_recs = ib_vector_create(node->heap, limit);
-
-		thr = UT_LIST_GET_NEXT(thrs, thr);
-	}
-
+	/* Fetch and parse the UNDO records. The UNDO records are added
+	to a per purge node vector. */
 	thr = UT_LIST_GET_FIRST(purge_sys->query->thrs);
 
 	while (thr) {
@@ -1133,6 +1117,11 @@ trx_purge_attach_undo_recs(
 
 		if (purge_rec->undo_rec != NULL) {
 
+			if (node->undo_recs == NULL) {
+				node->undo_recs = ib_vector_create(
+					node->heap, limit);
+			}
+
 			ib_vector_push(node->undo_recs, purge_rec);
 
 			if (ib_vector_size(node->undo_recs) >= limit) {
@@ -1190,9 +1179,12 @@ trx_purge(
 		mutex_enter(&kernel_mutex);
 	}
 
+	/* We release the mutex to preserve the latch order. */
 	mutex_exit(&kernel_mutex);
 
+	/* There should be no outstanding tasks. */
 	ut_a(srv_get_task_queue_length() == 0);
+	/* The number of tasks submitted should be completed. */
 	ut_a(purge_sys->n_submitted == purge_sys->n_completed);
 
 	rw_lock_x_lock(&purge_sys->latch);
@@ -1241,6 +1233,7 @@ trx_purge(
 		trx_purge_truncate_if_arr_empty();
 	}
 
+	/* Fetch and parse the UNDO recs that need to be purged. */
 	trx_purge_attach_undo_recs(limit);
 
 	rw_lock_x_unlock(&purge_sys->latch);


Attachment: [text/bzr-bundle] bzr/sunny.bains@oracle.com-20100430042036-szlj38yux28xv2sh.bundle
Thread
bzr commit into mysql-trunk-innodb branch (Sunny.Bains:3050) Sunny Bains30 Apr