db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r553171 - in /db/derby/code/branches/10.3/java/engine/org/apache/derby: iapi/sql/conn/LanguageConnectionContext.java impl/sql/GenericPreparedStatement.java impl/sql/conn/GenericLanguageConnectionContext.java
Date Wed, 04 Jul 2007 11:07:56 GMT
Author: kahatlen
Date: Wed Jul  4 04:07:55 2007
New Revision: 553171

URL: http://svn.apache.org/viewvc?view=rev&rev=553171
Log:
DERBY-2689: Deadlock with GenericPreparedStatement

Merged fix from trunk (revision 553101).

Modified:
    db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java?view=diff&rev=553171&r1=553170&r2=553171
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
Wed Jul  4 04:07:55 2007
@@ -1053,4 +1053,9 @@
 	 * @return True if SQL standard permissions are being used
 	 */
 	public boolean usesSqlAuthorization();
+
+	/**
+	 * Close any unused activations in this connection context.
+	 */
+	public void closeUnusedActivations() throws StandardException;
 }

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java?view=diff&rev=553171&r1=553170&r2=553171
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
Wed Jul  4 04:07:55 2007
@@ -218,18 +218,27 @@
 	 *
 	 * @exception StandardException thrown if finished.
 	 */
-	public synchronized Activation	getActivation(LanguageConnectionContext lcc, boolean scrollable)
throws StandardException 
+	public Activation getActivation(LanguageConnectionContext lcc,
+									boolean scrollable)
+		throws StandardException
 	{
-		GeneratedClass gc = getActivationClass();
+		Activation ac;
+		synchronized (this) {
+			GeneratedClass gc = getActivationClass();
 
-		if (gc == null) {
-			rePrepare(lcc);
-			gc = getActivationClass();
-		}
+			if (gc == null) {
+				rePrepare(lcc);
+				gc = getActivationClass();
+			}
 
-		Activation ac = new GenericActivationHolder(lcc, gc, this, scrollable);
+			ac = new GenericActivationHolder(lcc, gc, this, scrollable);
 
-		inUseCount++;
+			inUseCount++;
+		}
+		// DERBY-2689. Close unused activations-- this method should be called
+		// when I'm not holding a lock on a prepared statement to avoid
+		// deadlock.
+		lcc.closeUnusedActivations();
 
 		return ac;
 	}

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?view=diff&rev=553171&r1=553170&r2=553171
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
Wed Jul  4 04:07:55 2007
@@ -414,7 +414,11 @@
 		if (acts.size() > maxActsSize) {
 			maxActsSize = acts.size();
 		}
+	}
 
+	public void closeUnusedActivations()
+			throws StandardException
+	{
 		// DERBY-418. Activations which are marked unused,
 		// are closed here. Activations Vector is iterated 
 		// to identify and close unused activations, only if 
@@ -422,6 +426,7 @@
 		// size exceeds 20.
 		if( (unusedActs) && (acts.size() > 20) ) {
 			unusedActs = false;
+
 			for (int i = acts.size() - 1; i >= 0; i--) {
 
 				// it maybe the case that a Activation's reset() ends up



Mime
View raw message