db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r537091 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data: BaseContainerHandle.java D_BaseContainerHandle.java
Date Fri, 11 May 2007 04:43:51 GMT
Author: mikem
Date: Thu May 10 21:43:51 2007
New Revision: 537091

URL: http://svn.apache.org/viewvc?view=rev&rev=537091
Log:
DERBY-2141

Made BaseContainerHandle.close() synchronized as it may be called concurrently
by a stream passed outside the store and an abort triggered concurrently.  
Making it synchronized will allow the first close to do the proper work and
the subsequent calls will just return with no work to do.
Also made some of the fields private to convince myself no-one outside the
class was counting on something being changed during close.


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

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseContainerHandle.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseContainerHandle.java?view=diff&rev=537091&r1=537090&r2=537091
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseContainerHandle.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseContainerHandle.java
Thu May 10 21:43:51 2007
@@ -74,21 +74,21 @@
 		Container identifier
 		<BR> MT - Immutable
 	*/
-	protected /*final*/ ContainerKey		identity;
+	private /*final*/ ContainerKey		identity;
 
 	/**
 		Is this ContainerHandle active.
 
 		<BR> MT - Mutable : scoped
 	*/
-	protected boolean				active;	
+	private boolean				        active;	
 
 	/**
 		The actual container we are accessing. Only valid when active is true.
 
 		<BR> MT - Mutable : scoped
 	*/
-	protected BaseContainer		container;
+	protected BaseContainer		        container;
 
 	/**
 		the locking policy we opened the container with. 
@@ -97,27 +97,31 @@
 		<BR> MT - Mutable : scoped
 	*/
 
-	private	LockingPolicy		locking;
+	private	LockingPolicy		        locking;
 
 	/**
 		our transaction. Only valid when active is true.
 
 		<BR> MT - Mutable : scoped
 	*/
-	protected	RawTransaction		xact;
+	private	RawTransaction		        xact;
 
 	/**
 		are we going to update?
 
 		<BR> MT - Immutable after container handle becomes active
 	*/
-	private	boolean		forUpdate;
+	private	boolean		                forUpdate;
 
-	protected int mode;	// mode the container was opened in
 
+    /**
+     * mode the conainter was opened in.
+     **/
+	private int                         mode;
 
-	protected PageActions		actionsSet;
-	protected AllocationActions allocActionsSet;
+
+	private PageActions		            actionsSet;
+	private AllocationActions           allocActionsSet;
 
 
 	/*
@@ -388,39 +392,42 @@
 		@see ContainerHandle#close
 	*/
 
-	public void close() 
+	public synchronized void close() 
     {
+        // Close may be called by multiple threads concurrently, for
+        // instance it can be called automatically after an abort and
+        // explicitly by a client.  Depending on timing of machine
+        // these calls may happen concurrently.  Thus close needs to
+        // be synchronized.  
+        //
+        // Another example is that we may hand out an indirect reference
+        // to clients outside of JDBC through an OverFlowInputStream.  
+        // Derby code cannot control when clients may close those 
+        // streams with respect to implicit closes by abort.
 
         if (xact == null) 
         {
-            // Probably be closed explicitly by a client, after closing 
-            // automatically after an abort.
-            
-            if (SanityManager.DEBUG)
-                SanityManager.ASSERT(!active);
-
             return;
         }
 
-		// notify our observers (Pages) that we are closing ...
-		informObservers();
+        // notify our observers (Pages) that we are closing ...
+        informObservers();
 
-		active = false;
+        active = false;
 
-		getLockingPolicy().unlockContainer(xact, this);
+        getLockingPolicy().unlockContainer(xact, this);
 
-		// let go of the container
-		if (container != null) 
+        // let go of the container
+        if (container != null) 
         {
-			container.letGo(this);
-			container = null;
-		}
+            container.letGo(this);
+            container = null;
+        }
 
-		// and remove ourseleves from this transaction
+        // and remove ourseleves from this transaction
         xact.deleteObserver(this);
 
-		xact = null;
-		
+        xact = null;
 	}
 
 	/* cost estimation */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/D_BaseContainerHandle.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/D_BaseContainerHandle.java?view=diff&rev=537091&r1=537090&r2=537091
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/D_BaseContainerHandle.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/D_BaseContainerHandle.java
Thu May 10 21:43:51 2007
@@ -63,11 +63,11 @@
             ")";
         */
 
-        long container_id = ch.identity.getContainerId();
+        long container_id = ch.getId().getContainerId();
 
         long conglom_id   = 
             D_DiagnosticUtil.diag_containerid_to_conglomid(
-                    ch.xact.getDataFactory(),
+                    ch.getTransaction().getDataFactory(),
                     container_id);
 
         if (conglom_id !=  Long.MIN_VALUE)



Mime
View raw message