From bd77a36e68dbd661b5166552834a15c27a37ef6d Mon Sep 17 00:00:00 2001
From: sbains <Unknown>
Date: Thu, 22 Apr 2010 01:09:15 +0000
Subject: [PATCH] branches/innodb+: Add a check for thread suspended time to
 the list of checks for slot recycle. Udpate the comments.

---
 srv/srv0srv.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/srv/srv0srv.c b/srv/srv0srv.c
index 30c3000df77..fbfb60c1b99 100644
--- a/srv/srv0srv.c
+++ b/srv/srv0srv.c
@@ -2264,10 +2264,11 @@ srv_lock_check_wait(
 	trx_t*		trx;
 	double		wait_time;
 	ulong		lock_wait_timeout;
+	ib_time_t	suspend_time = slot->suspend_time;
 
 	ut_ad(srv_sys_mutex_own());
 
-	wait_time = ut_difftime(ut_time(), slot->suspend_time);
+	wait_time = ut_difftime(ut_time(), suspend_time);
 
 	trx = thr_get_trx(slot->thr);
 
@@ -2307,16 +2308,18 @@ srv_lock_check_wait(
 
 			/* We can't compare the pointers here because the
 			memory can be recycled. Transaction ids are not
-			recyled and therefore safe to use. If the transaction
-			has already released its locks there is nothing
-			more we can do. */
+			recyled and therefore safe to use. We also check if
+			the transaction suspend time is the same that we
+			used for calculating the wait earlier. If the
+		       	transaction has already released its locks there
+		       	is nothing more we can do. */
 			if (slot->in_use
+			    && suspend_time == slot->suspend_time
 			    && ut_dulint_cmp(trx->id, slot_trx->id) == 0
 			    && trx->wait_lock != NULL) {
 
 				ut_a(trx->que_state == TRX_QUE_LOCK_WAIT);
 
-				/* Note that the caller is the timeout thread */
 				lock_cancel_waiting_and_release(
 					trx->wait_lock);
 			}