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 kr...@apache.org on 2010/11/30 15:53:15 UTC
svn commit: r1040551 - in /db/derby/code/branches/10.6: ./
java/engine/org/apache/derby/impl/services/locks/
java/testing/org/apache/derbyTesting/functionTests/tests/engine/
java/testing/org/apache/derbyTesting/junit/
Author: kristwaa
Date: Tue Nov 30 14:53:14 2010
New Revision: 1040551
URL: http://svn.apache.org/viewvc?rev=1040551&view=rev
Log:
DERBY-4711: Hung thread after another thread is interrupted.
Merged fix from trunk (revisions 957902, 958257, 958264, and 958508).
Added:
db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/engine/LockInterruptTest.java
- copied, changed from r958264, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/LockInterruptTest.java
Modified:
db/derby/code/branches/10.6/ (props changed)
db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java
db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/services/locks/LockSet.java
db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/engine/_Suite.java
db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
Propchange: db/derby/code/branches/10.6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 30 14:53:14 2010
@@ -1,2 +1,2 @@
-/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,958163,958522,958555,958618,958939,959550,962716,963206,963705,964115,965647,967304,980684,986689,986834,987539,989099,990292,997325,998170,999119,1002291,1002682,1002853,1021426,1025795,1030043,1033864
+/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,957902,958163,958257,958264,958508,958522,958555,958618,958939,959550,962716,963206,963705,964115,965647,967304,980684,986689,986834,987539,989099,990292,997325,998170,999119,1002291,1002682,1002853,1021426,1025795,1030043,1033864
/db/derby/docs/trunk:954344
Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java?rev=1040551&r1=1040550&r2=1040551&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java (original)
+++ db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java Tue Nov 30 14:53:14 2010
@@ -460,12 +460,22 @@ final class ConcurrentLockSet implements
forever: for (;;) {
- byte wakeupReason = waitingLock.waitForGrant(actualTimeout);
-
+ byte wakeupReason = 0;
ActiveLock nextWaitingLock = null;
Object[] deadlockData = null;
try {
+ try {
+ wakeupReason = waitingLock.waitForGrant(actualTimeout);
+ } catch(StandardException e) {
+ // DERBY-4711: If waitForGrant() fails, we need to
+ // remove ourselves from the queue so that those
+ // behind us in the queue don't get stuck waiting for
+ // us.
+ nextWaitingLock = control.getNextWaiter(waitingLock, true, this);
+ throw e;
+ }
+
boolean willQuitWait;
Enumeration timeoutLockTable = null;
long currentTime = 0;
Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/services/locks/LockSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/services/locks/LockSet.java?rev=1040551&r1=1040550&r2=1040551&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/services/locks/LockSet.java (original)
+++ db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/services/locks/LockSet.java Tue Nov 30 14:53:14 2010
@@ -273,12 +273,22 @@ final class LockSet implements LockTable
forever: for (;;) {
- byte wakeupReason = waitingLock.waitForGrant(actualTimeout);
-
+ byte wakeupReason = 0;
ActiveLock nextWaitingLock = null;
Object[] deadlockData = null;
try {
+ try {
+ wakeupReason = waitingLock.waitForGrant(actualTimeout);
+ } catch(StandardException e) {
+ // DERBY-4711: If waitForGrant() fails, we need to
+ // remove ourselves from the queue so that those
+ // behind us in the queue don't get stuck waiting for
+ // us.
+ nextWaitingLock = control.getNextWaiter(waitingLock, true, this);
+ throw e;
+ }
+
boolean willQuitWait;
Enumeration timeoutLockTable = null;
long currentTime = 0;
Copied: db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/engine/LockInterruptTest.java (from r958264, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/LockInterruptTest.java)
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/engine/LockInterruptTest.java?p2=db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/engine/LockInterruptTest.java&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/LockInterruptTest.java&r1=958264&r2=1040551&rev=1040551&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/LockInterruptTest.java (original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/engine/LockInterruptTest.java Tue Nov 30 14:53:14 2010
@@ -81,8 +81,9 @@ public class LockInterruptTest extends B
Thread.sleep(2000); // give t2 time to enter the wait queue
// Now that the queue of waiters has been set up, interrupt the
- // first thread.
+ // first thread and give the interrupt a little time to do its work.
t1.interrupt();
+ Thread.sleep(1000);
// Release the table lock to allow the waiters to proceed.
commit();
Modified: db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/engine/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/engine/_Suite.java?rev=1040551&r1=1040550&r2=1040551&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/engine/_Suite.java (original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/engine/_Suite.java Tue Nov 30 14:53:14 2010
@@ -47,6 +47,7 @@ public class _Suite extends BaseTestCase
TestSuite suite = new TestSuite("engine");
suite.addTest(ErrorStreamTest.suite());
+ suite.addTest(LockInterruptTest.suite());
suite.addTest(ModuleLoadingTest.suite());
return suite;
Modified: db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=1040551&r1=1040550&r2=1040551&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java (original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java Tue Nov 30 14:53:14 2010
@@ -617,15 +617,15 @@ public abstract class BaseTestCase
* Fail; attaching an exception for more detail on cause.
*
* @param msg message explaining the failure
- * @param e exception related to the cause
+ * @param t the cause of the failure
*
* @exception AssertionFailedError
*/
- public static void fail(String msg, Exception e)
+ public static void fail(String msg, Throwable t)
throws AssertionFailedError {
AssertionFailedError ae = new AssertionFailedError(msg);
- ae.initCause(e);
+ ae.initCause(t);
throw ae;
}
} // End class BaseTestCase