Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 35133 invoked from network); 30 Nov 2010 14:54:49 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Nov 2010 14:54:49 -0000 Received: (qmail 9071 invoked by uid 500); 30 Nov 2010 14:54:49 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 9027 invoked by uid 500); 30 Nov 2010 14:54:49 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 9013 invoked by uid 99); 30 Nov 2010 14:54:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Nov 2010 14:54:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Nov 2010 14:54:47 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 85A3423888EA; Tue, 30 Nov 2010 14:53:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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/ Date: Tue, 30 Nov 2010 14:53:15 -0000 To: derby-commits@db.apache.org From: kristwaa@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101130145315.85A3423888EA@eris.apache.org> 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