db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1229066 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ResultSetMiscTest.java
Date Mon, 09 Jan 2012 09:18:50 GMT
Author: kahatlen
Date: Mon Jan  9 09:18:49 2012
New Revision: 1229066

URL: http://svn.apache.org/viewvc?rev=1229066&view=rev
Log:
DERBY-5568: AssertionFailedError: Should not hold locks after commit in ResultSetMiscTest

Wait for post-commit work to complete before checking lock table.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ResultSetMiscTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ResultSetMiscTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ResultSetMiscTest.java?rev=1229066&r1=1229065&r2=1229066&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ResultSetMiscTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ResultSetMiscTest.java
Mon Jan  9 09:18:49 2012
@@ -715,30 +715,25 @@ public class ResultSetMiscTest extends B
     }
 
     /**
-     * 
+     * Check if locks are held.
      * 
      * @return true if locks are held.
      * @throws SQLException
      */
     private boolean locksHeld() throws SQLException {
 
-        boolean hasLocks = false;
         Connection con2 = openDefaultConnection();
-        PreparedStatement ps2 = con2
-                .prepareStatement("select XID, count(*) from SYSCS_DIAG.LOCK_TABLE as L group
by XID");
-        ResultSet rs2 = ps2.executeQuery();
-
-        while (rs2.next()) {
-            if (rs2.getInt(2) > 0) {
-                hasLocks = true;
-            } else {
-                // 0 locks held
-                hasLocks = false;
-            }
-        }
+        Statement s2 = con2.createStatement();
+
+        // Wait for post-commit work to complete first. Otherwise, extra
+        // locks may intermittently show up in the lock table. DERBY-5568.
+        s2.execute("CALL WAIT_FOR_POST_COMMIT()");
+
+        ResultSet rs2 = s2.executeQuery("SELECT 1 FROM SYSCS_DIAG.LOCK_TABLE");
+        boolean hasLocks = rs2.next();
 
         rs2.close();
-        ps2.close();
+        s2.close();
         con2.close();
         return hasLocks;
     }
@@ -791,6 +786,12 @@ public class ResultSetMiscTest extends B
                                 + Utilities.stringToHexLiteral("4teen")
                                 + ", null, null)");
 
+                s.execute("CREATE PROCEDURE WAIT_FOR_POST_COMMIT() "
+                        + "LANGUAGE JAVA EXTERNAL NAME "
+                        + "'org.apache.derbyTesting.functionTests.util."
+                        + "T_Access.waitForPostCommitToFinish' "
+                        + "PARAMETER STYLE JAVA");
+
             }
         };
     }



Mime
View raw message