You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2011/03/17 14:13:39 UTC

svn commit: r1082480 - in /db/derby/code/branches/10.7: ./ java/engine/org/apache/derby/impl/services/locks/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/

Author: kmarsden
Date: Thu Mar 17 13:13:39 2011
New Revision: 1082480

URL: http://svn.apache.org/viewvc?rev=1082480&view=rev
Log:
DERBY-3980 Conflicting select then update with REPEATABLE_READ gives lock timeout instead of deadlock


Added:
    db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeadlockDetectionTest.java
      - copied unchanged from r1081455, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DeadlockDetectionTest.java
Modified:
    db/derby/code/branches/10.7/   (props changed)
    db/derby/code/branches/10.7/java/engine/org/apache/derby/impl/services/locks/Deadlock.java
    db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java

Propchange: db/derby/code/branches/10.7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Mar 17 13:13:39 2011
@@ -1 +1 @@
-/db/derby/code/trunk:1035603,1036769,1038514,1038813,1039084,1039268,1040658,1041338,1043227,1043389,1044096,1051026,1053724,1055169,1059888,1060480,1062096,1063809,1065061,1066290,1067250,1067357,1071463,1076387,1078461,1078693
+/db/derby/code/trunk:1035603,1036769,1038514,1038813,1039084,1039268,1040658,1041338,1043227,1043389,1044096,1051026,1053724,1055169,1059888,1060480,1062096,1063809,1065061,1066290,1067250,1067357,1071463,1076387,1078461,1078693,1081455

Modified: db/derby/code/branches/10.7/java/engine/org/apache/derby/impl/services/locks/Deadlock.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/engine/org/apache/derby/impl/services/locks/Deadlock.java?rev=1082480&r1=1082479&r2=1082480&view=diff
==============================================================================
--- db/derby/code/branches/10.7/java/engine/org/apache/derby/impl/services/locks/Deadlock.java (original)
+++ db/derby/code/branches/10.7/java/engine/org/apache/derby/impl/services/locks/Deadlock.java Thu Mar 17 13:13:39 2011
@@ -167,40 +167,59 @@ inner:		for (;;) {
 				}
 				chain.push(space);
 
-				Lock waitingLock = (Lock) waiters.get(space);
-				if (waitingLock == null) {
-					// end of the road, no deadlock in this path
-					// pop items until the previous Stack
-					rollback(chain);
-					continue outer;
-				}
+                skip_space: while (true) {
 
-				// Is a LockControl or another ActiveLock
-				Object waitOn = waiters.get(waitingLock); 
-				if (waitOn instanceof LockControl) {
-
-					LockControl waitOnControl = (LockControl) waitOn;
-
-					// This lock control may have waiters but no
-					// one holding the lock. This is true if lock
-					// has just been released but the waiters haven't
-					// woken up, or they are trying to get the synchronization we hold.
-
-					if (waitOnControl.isUnlocked()) {
-						// end of the road, no deadlock in this path
-						// pop items until the previous Stack
-						rollback(chain);
-						continue outer;
-					}
+                    Lock waitingLock = (Lock) waiters.get(space);
+                    if (waitingLock == null) {
+                        // end of the road, no deadlock in this path
+                        // pop items until the previous Stack
+                        rollback(chain);
+                        continue outer;
+                    }
 
-					chain.push(waitOnControl.getGrants());
+                    // Is a LockControl or another ActiveLock
+                    Object waitOn = waiters.get(waitingLock);
+                    if (waitOn instanceof LockControl) {
+
+                        LockControl waitOnControl = (LockControl) waitOn;
+
+                        // This lock control may have waiters but no
+                        // one holding the lock. This is true if lock
+                        // has just been released but the waiters haven't
+                        // woken up, or they are trying to get the
+                        // synchronization we hold.
+
+                        if (waitOnControl.isUnlocked()) {
+                            // end of the road, no deadlock in this path
+                            // pop items until the previous Stack
+                            rollback(chain);
+                            continue outer;
+                        }
 
-					continue outer;
-				} else {
-					// simply waiting on another waiter
-					space = waitingLock.getCompatabilitySpace();
-				}
-		}
+                        chain.push(waitOnControl.getGrants());
+
+                        continue outer;
+                    } else {
+                        // simply waiting on another waiter
+                        ActiveLock waitOnLock = (ActiveLock) waitOn;
+
+                        space = waitOnLock.getCompatabilitySpace();
+
+                        if (waitingLock.getLockable().requestCompatible(
+                                waitingLock.getQualifier(),
+                                waitOnLock.getQualifier())) {
+                            // We're behind another waiter in the queue, but we
+                            // request compatible locks, so we'll get the lock
+                            // too once it gets it. Since we're not actually
+                            // blocked by the waiter, skip it and see what's
+                            // blocking it instead.
+                            continue skip_space;
+                        } else {
+                            continue inner;
+                        }
+                    }
+                }
+            }
 		}
 
 		return null;

Modified: db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java?rev=1082480&r1=1082479&r2=1082480&view=diff
==============================================================================
--- db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java (original)
+++ db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java Thu Mar 17 13:13:39 2011
@@ -149,6 +149,7 @@ public class _Suite extends BaseTestCase
         suite.addTest(UniqueConstraintSetNullTest.suite());
         suite.addTest(UniqueConstraintMultiThreadedTest.suite());
         suite.addTest(ViewsTest.suite());
+        suite.addTest(DeadlockDetectionTest.suite());
         suite.addTest(DeadlockModeTest.suite());
         suite.addTest(AnsiSignaturesTest.suite());
         suite.addTest(PredicatePushdownTest.suite());