db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1083074 - in /db/derby/code/branches/10.5: ./ java/engine/org/apache/derby/impl/services/locks/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Fri, 18 Mar 2011 21:26:09 GMT
Author: kmarsden
Date: Fri Mar 18 21:26:09 2011
New Revision: 1083074

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

Contributed by Knut Anders Hatlen


Added:
    db/derby/code/branches/10.5/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.5/   (props changed)
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/services/locks/Deadlock.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 18 21:26:09 2011
@@ -1,2 +1,2 @@
 /db/derby/code/branches/10.6:942027,957000,957287,958621,962738,965351,987678,997790*,1031623,1055601,1068474,1071167
-/db/derby/code/trunk:757811,764912,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792001,792254,792434,793089,793588,794106,794276,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803336,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,826263,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,891350,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915177,915733,916075,916897,917771,918152,918359,921028,927430,928065,929085,931076,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952237,952581,954748,955001,955634,956075,956445,956659,957260,958163,958618,959550,961892,962716,964039,964402,96
 5647,966393,967201,967304,980089,980684,986689,986834,987539,989099,997325*,998170,999119,999485,1002291,1002682,1002853,1021426,1024511,1024528,1025615,1025795,1030043,1040658,1053724,1055169,1062096,1063809,1065061,1067250
+/db/derby/code/trunk:757811,764912,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792001,792254,792434,793089,793588,794106,794276,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803336,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,826263,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,891350,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915177,915733,916075,916897,917771,918152,918359,921028,927430,928065,929085,931076,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952237,952581,954748,955001,955634,956075,956445,956659,957260,958163,958618,959550,961892,962716,964039,964402,96
 5647,966393,967201,967304,980089,980684,986689,986834,987539,989099,997325*,998170,999119,999485,1002291,1002682,1002853,1021426,1024511,1024528,1025615,1025795,1030043,1040658,1053724,1055169,1062096,1063809,1065061,1067250,1081455

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/services/locks/Deadlock.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/services/locks/Deadlock.java?rev=1083074&r1=1083073&r2=1083074&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/services/locks/Deadlock.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/services/locks/Deadlock.java
Fri Mar 18 21:26:09 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.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java?rev=1083074&r1=1083073&r2=1083074&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
Fri Mar 18 21:26:09 2011
@@ -140,6 +140,7 @@ public class _Suite extends BaseTestCase
         suite.addTest(OLAPTest.suite());
         suite.addTest(UniqueConstraintSetNullTest.suite());
         suite.addTest(ViewsTest.suite());
+        suite.addTest(DeadlockDetectionTest.suite());
         suite.addTest(DeadlockModeTest.suite());
         suite.addTest(AnsiSignaturesTest.suite());
         suite.addTest(PredicatePushdownTest.suite());



Mime
View raw message