db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1530696 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_derby715.java
Date Wed, 09 Oct 2013 16:00:54 GMT
Author: kmarsden
Date: Wed Oct  9 16:00:54 2013
New Revision: 1530696

URL: http://svn.apache.org/r1530696
Log:
DERBY-3624 testfailure in storetests/st_derby715 with ibm 1.5 on iseries machine; one deadlock
message missing

Change test to check locks rather than sleep for synchronization.


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_derby715.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_derby715.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_derby715.java?rev=1530696&r1=1530695&r2=1530696&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_derby715.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_derby715.java
Wed Oct  9 16:00:54 2013
@@ -40,7 +40,7 @@ import org.apache.derby.tools.ij;
 
 The purpose of this test is to reproduce JIRA DERBY-715:
 
-Sometimes a deadlock would be incorrectly reported as a deadlock.  The
+Sometimes a deadlock would be incorrectly reported as a timeout.  The
 bug seemed to always reproduce at least once if the following test
 was run (at least one of the iterations in the loop would get an
 incorrect timeout vs. a deadlock).
@@ -129,7 +129,7 @@ public class st_derby715 extends BaseTes
                     System.out.println("Thread 1 after all next.");
 
                 // give thread 2 a chance to catch up.
-                Thread.sleep(500);
+                waitForLocks(conn, 2);
 
                 if (verbose)
                     System.out.println("Thread 1 before inserting into a...");
@@ -204,10 +204,8 @@ public class st_derby715 extends BaseTes
 
                 if (verbose)
                     System.out.println("Thread 2 after all next.");
+                waitForLocks(conn,2);
 
-
-                Thread.sleep(500);
-                
                 if (verbose)
                     System.out.println("Thread 2 before inserting into b");
 
@@ -245,7 +243,34 @@ public class st_derby715 extends BaseTes
         }
     }
     
-
+    /**
+     * Wait for a specified number of locks before continuing
+     *
+     * @param conn Connection to use for lock query
+     * @param num  Number of locks to check for
+     */
+    private static void waitForLocks(Connection conn, int num) throws InterruptedException,
SQLException {
+        int totalWait = 0;
+        do {
+            totalWait += 500;
+            Thread.sleep(500);
+        } while (numlocks(conn) < num && totalWait < 60000);
+       
+    }
+    /**
+     * Get the number of locks in the lock table 
+     * @return number of locks
+     * @throws SQLException
+     */
+    private static int numlocks(Connection conn) throws SQLException {
+        Statement s = conn.createStatement();
+        ResultSet rs = s.executeQuery("SELECT count(*) from syscs_diag.lock_table");
+        rs.next();
+        int num = rs.getInt(1);
+        rs.close();
+        return num;
+    }
+    
     public void testList(Connection conn)
         throws SQLException
     {



Mime
View raw message