db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1058245 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks: ActiveLock.java ConcurrentLockSet.java Constants.java LockSet.java
Date Wed, 12 Jan 2011 17:27:41 GMT
Author: dag
Date: Wed Jan 12 17:27:40 2011
New Revision: 1058245

URL: http://svn.apache.org/viewvc?rev=1058245&view=rev
Log:
DERBY-4769 Handle interrupt received while waiting for database lock

(subtask of DERBY-4741): Patch derby-4967-locking-1 which lets Derby
throw CONN_INTERRUPT if an interrupt is received while waiting for a
database lock.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/ActiveLock.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/Constants.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/LockSet.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/ActiveLock.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/ActiveLock.java?rev=1058245&r1=1058244&r2=1058245&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/ActiveLock.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/ActiveLock.java Wed
Jan 12 17:27:40 2011
@@ -119,7 +119,7 @@ public final class ActiveLock extends Lo
 				}
 
 			} catch (InterruptedException ie) {
-				throw StandardException.interrupt(ie);
+				wakeUpNow = Constants.WAITING_LOCK_INTERRUPTED;
 			}
 		}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java?rev=1058245&r1=1058244&r2=1058245&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java
Wed Jan 12 17:27:40 2011
@@ -596,9 +596,14 @@ forever:	for (;;) {
 
                         if (deadlockData == null)
                         {
-                            // ending wait because of lock timeout.
+                            // ending wait because of lock timeout or interrupt
 
-                            if (deadlockTrace)
+                            if (wakeupReason == Constants.WAITING_LOCK_INTERRUPTED) {
+
+                                Thread.currentThread().interrupt();
+                                throw StandardException.newException(SQLState.CONN_INTERRUPT);
+
+                            } else if (deadlockTrace)
                             {   
                                 // Turn ON derby.locks.deadlockTrace to build 
                                 // the lockTable.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/Constants.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/Constants.java?rev=1058245&r1=1058244&r2=1058245&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/Constants.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/Constants.java Wed
Jan 12 17:27:40 2011
@@ -46,4 +46,5 @@ public class Constants {
 	static final byte WAITING_LOCK_IN_WAIT = 0;
 	static final byte WAITING_LOCK_GRANT = 1;
 	static final byte WAITING_LOCK_DEADLOCK = 2;
+	static final byte WAITING_LOCK_INTERRUPTED = 3;
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/LockSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/LockSet.java?rev=1058245&r1=1058244&r2=1058245&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/LockSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/locks/LockSet.java Wed
Jan 12 17:27:40 2011
@@ -346,8 +346,9 @@ forever:	for (;;) {
                                 waitingLock, willQuitWait, this);
 
 
-                        // If we were not woken by another then we have
-                        // timed out. Either deadlock out or timeout
+                        // If we were not woken by another then we have timed
+                        // out. Either deadlock out or timeout. Or thread has
+                        // been interrupted.
                         if (willQuitWait) {
 
                             if (SanityManager.DEBUG) 
@@ -405,11 +406,16 @@ forever:	for (;;) {
 
                         }
 
+                        
                         if (deadlockData == null)
                         {
-                            // ending wait because of lock timeout.
+                            // ending wait because of lock timeout or interrupt
+                            if (wakeupReason == Constants.WAITING_LOCK_INTERRUPTED) {
 
-                            if (deadlockTrace)
+                                Thread.currentThread().interrupt();
+                                throw StandardException.newException(SQLState.CONN_INTERRUPT);
+
+                            } else if (deadlockTrace)
                             {   
                                 // Turn ON derby.locks.deadlockTrace to build 
                                 // the lockTable.



Mime
View raw message