MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:Osku Salerma Date:August 17 2005 8:56am
Subject:bk commit into 5.0 tree (osku:1.1989) BUG#12588
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of osku. When osku does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1989 05/08/17 11:56:04 osku@127.(none) +1 -0
  Fix bug #12588, InnoDB's deadlock detector running out of stack space.

  innobase/lock/lock0lock.c
    1.65 05/08/17 11:55:41 osku@127.(none) +17 -6
    Limit recursion depth in lock_deadlock_recursive to 200.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	osku
# Host:	127.(none)
# Root:	/home/osku/mysql-5.0-2

--- 1.64/innobase/lock/lock0lock.c	2005-08-12 11:29:56 +03:00
+++ 1.65/innobase/lock/lock0lock.c	2005-08-17 11:55:41 +03:00
@@ -47,6 +47,10 @@
 graph of transactions */
 #define LOCK_MAX_N_STEPS_IN_DEADLOCK_CHECK 1000000
 
+/* Restricts the recursion depth of the search we will do in the waits-for
+graph of transactions */
+#define LOCK_MAX_DEPTH_IN_DEADLOCK_CHECK 200
+
 /* When releasing transaction locks, this specifies how often we release
 the kernel mutex for a moment to give also others access to it */
 
@@ -389,9 +393,12 @@
 	trx_t*	start,		/* in: recursion starting point */
 	trx_t*	trx,		/* in: a transaction waiting for a lock */
 	lock_t*	wait_lock,	/* in: the lock trx is waiting to be granted */
-	ulint*	cost);		/* in/out: number of calculation steps thus
+	ulint*	cost,		/* in/out: number of calculation steps thus
 				far: if this exceeds LOCK_MAX_N_STEPS_...
-				we return TRUE */
+				we return LOCK_VICTIM_IS_START */
+	uint depth);            /* in: recursion depth: if this exceeds
+				LOCK_MAX_DEPTH_IN_DEADLOCK_CHECK, we
+				return LOCK_VICTIM_IS_START */
 
 /*************************************************************************
 Gets the type of a lock. */
@@ -3180,7 +3187,7 @@
 		mark_trx = UT_LIST_GET_NEXT(trx_list, mark_trx);
 	}
 
-	ret = lock_deadlock_recursive(trx, trx, lock, &cost);
+	ret = lock_deadlock_recursive(trx, trx, lock, &cost, 0);
 
 	if (ret == LOCK_VICTIM_IS_OTHER) {
 		/* We chose some other trx as a victim: retry if there still
@@ -3226,9 +3233,12 @@
 	trx_t*	start,		/* in: recursion starting point */
 	trx_t*	trx,		/* in: a transaction waiting for a lock */
 	lock_t*	wait_lock,	/* in: the lock trx is waiting to be granted */
-	ulint*	cost)		/* in/out: number of calculation steps thus
+	ulint*	cost,		/* in/out: number of calculation steps thus
 				far: if this exceeds LOCK_MAX_N_STEPS_...
 				we return LOCK_VICTIM_IS_START */
+	uint depth)		/* in: recursion depth: if this exceeds
+				LOCK_MAX_DEPTH_IN_DEADLOCK_CHECK, we
+				return LOCK_VICTIM_IS_START */
 {
 	lock_t*	lock;
 	ulint	bit_no		= ULINT_UNDEFINED;
@@ -3249,7 +3259,8 @@
 
 	*cost = *cost + 1;
 
-	if (*cost > LOCK_MAX_N_STEPS_IN_DEADLOCK_CHECK) {
+	if ((depth > LOCK_MAX_DEPTH_IN_DEADLOCK_CHECK)
+		|| (*cost > LOCK_MAX_N_STEPS_IN_DEADLOCK_CHECK)) {
 
 		return(LOCK_VICTIM_IS_START);
 	}
@@ -3375,7 +3386,7 @@
 				a lock */
 
 				ret = lock_deadlock_recursive(start, lock_trx,
-						lock_trx->wait_lock, cost);
+					lock_trx->wait_lock, cost, depth + 1);
 				if (ret != 0) {
 
 					return(ret);
Thread
bk commit into 5.0 tree (osku:1.1989) BUG#12588Osku Salerma17 Aug