db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r749839 - /db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java
Date Tue, 03 Mar 2009 23:28:18 GMT
Author: kmarsden
Date: Tue Mar  3 23:28:18 2009
New Revision: 749839

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


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

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java?rev=749839&r1=749838&r2=749839&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java
Tue Mar  3 23:28:18 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