Return-Path: X-Original-To: apmail-db-derby-commits-archive@www.apache.org Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9F51210C89 for ; Wed, 9 Oct 2013 16:01:22 +0000 (UTC) Received: (qmail 4999 invoked by uid 500); 9 Oct 2013 16:01:22 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 4926 invoked by uid 500); 9 Oct 2013 16:01:19 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 4919 invoked by uid 99); 9 Oct 2013 16:01:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Oct 2013 16:01:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Oct 2013 16:01:15 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C84892388BEC; Wed, 9 Oct 2013 16:00:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: derby-commits@db.apache.org From: kmarsden@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131009160054.C84892388BEC@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 {