db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r745982 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java
Date Thu, 19 Feb 2009 20:09:16 GMT
Author: kmarsden
Date: Thu Feb 19 20:09:16 2009
New Revision: 745982

URL: http://svn.apache.org/viewvc?rev=745982&view=rev
Log:
DERBY-4059 If space reclamation cannot obtain container lock it will not retry getting the
lock

This change does make the change so that the retry occurs but in practical application it
is unlikely that we will get the lock after three retries, because the retry happens so quickly.
See https://issues.apache.org/jira/browse/DERBY-4055?focusedCommentId=12673436#action_12673436
for suggestions on long term solutions to the retry problem.



Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java?rev=745982&r1=745981&r2=745982&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java
Thu Feb 19 20:09:16 2009
@@ -42,6 +42,7 @@
 
 import org.apache.derby.iapi.store.raw.xact.RawTransaction;
 import org.apache.derby.iapi.store.raw.data.RawContainerHandle;
+import org.apache.derby.shared.common.reference.SQLState;
 
 
 /**
@@ -259,6 +260,9 @@
             }
 
 			if (work.incrAttempts() < 3) // retry this for serveral times
+				// it is however, unlikely that three tries will be 
+				// enough because there is no delay between retries.
+				// See DERBY-4059 and DERBY-4055 for details.
             {
 				return Serviceable.REQUEUE;
             }
@@ -509,17 +513,34 @@
 
 
 	/**
-		Open container shared no wait
+	 *	Open container shared no wait
+	 *
+	 * @param tran   Transaction
+	 * @param rlock  LockingPolicy
+	 * @param containerId container id.
+	 * 
+	 * @return ContainerHandle or null if it could not obtain lock.
+	 * 
+	 * @throws StandardException
 	 */
 	private static ContainerHandle openContainerNW(Transaction tran,
 		LockingPolicy rlock, ContainerKey containerId)
 		throws StandardException
 	{
-		ContainerHandle containerHdl = tran.openContainer
-			(containerId, rlock,
-			 ContainerHandle.MODE_FORUPDATE |
-			 ContainerHandle.MODE_LOCK_NOWAIT); 
-
+		ContainerHandle containerHdl = null;
+		try {
+				containerHdl = tran.openContainer
+				(containerId, rlock,
+						ContainerHandle.MODE_FORUPDATE |
+						ContainerHandle.MODE_LOCK_NOWAIT); 
+		} catch (StandardException se) {
+			// DERBY-4059
+			// if this is a lock timeout just return null.
+			// otherwise throw the exception
+			if (!se.getSQLState().equals(SQLState.LOCK_TIMEOUT)) {
+				throw se;
+			}
+		}
 		return containerHdl;
 	}
 



Mime
View raw message