You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2011/10/26 10:08:48 UTC

svn commit: r1189067 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java

Author: kahatlen
Date: Wed Oct 26 08:08:47 2011
New Revision: 1189067

URL: http://svn.apache.org/viewvc?rev=1189067&view=rev
Log:
DERBY-5406: Intermittent failures in CompressTableTest and TruncateTableTest

If GenericActivationHolder determines that a recompile is needed, it now
throws an exception to signal that to the caller instead of doing the
recompilation itself. This way, if the statement is invalidated again
during the recompilation, the already existing retry logic in the caller
(that is, GenericPreparedStatement.executeStmt()) will be used to detect
that the recompilation must be retried.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java?rev=1189067&r1=1189066&r2=1189067&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java Wed Oct 26 08:08:47 2011
@@ -261,23 +261,24 @@ final public class GenericActivationHold
 		{
 			/* Has the activation class changed or has the activation been
 			 * invalidated? */
-			if (gc != ps.getActivationClass() || !ac.isValid())
+            final boolean needNewClass =
+                    gc == null || gc != ps.getActivationClass();
+			if (needNewClass || !ac.isValid())
 			{
 
                 GeneratedClass newGC;
 
-				if (gc != ps.getActivationClass()) {
-					// ensure the statement is valid by rePreparing it.
-					// DERBY-3260: If someone else reprepares the statement at
-					// the same time as we do, there's a window between the
-					// calls to rePrepare() and getActivationClass() when the
-					// activation class can be set to null, leading to
-					// NullPointerException being thrown later. Therefore,
-					// synchronize on ps to close the window.
-					synchronized (ps) {
-						ps.rePrepare(getLanguageConnectionContext());
-						newGC = ps.getActivationClass();
-					}
+				if (needNewClass) {
+                    // The statement has been re-prepared since the last time
+                    // we executed it. Get the new activation class.
+                    newGC = ps.getActivationClass();
+                    if (newGC == null) {
+                        // There is no class associated with the statement.
+                        // Tell the caller that the statement needs to be
+                        // recompiled.
+                        throw StandardException.newException(
+                                SQLState.LANG_STATEMENT_NEEDS_RECOMPILE);
+                    }
 				} else {
 					// Reuse the generated class, we just want a new activation
 					// since the old is no longer valid.