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 7FB4EC3C6 for ; Wed, 9 May 2012 18:50:03 +0000 (UTC) Received: (qmail 66274 invoked by uid 500); 9 May 2012 18:50:03 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 66224 invoked by uid 500); 9 May 2012 18:50:03 -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 66213 invoked by uid 99); 9 May 2012 18:50:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 May 2012 18:50:03 +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 May 2012 18:50:02 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 06E72238890B; Wed, 9 May 2012 18:49:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1336349 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit: CleanDatabaseTestSetup.java DatabasePropertyTestSetup.java Date: Wed, 09 May 2012 18:49:41 -0000 To: derby-commits@db.apache.org From: myrnavl@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120509184942.06E72238890B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: myrnavl Date: Wed May 9 18:49:41 2012 New Revision: 1336349 URL: http://svn.apache.org/viewvc?rev=1336349&view=rev Log: DERBY-5686; multiple intermittent errors in nightly tests during DriverMgrAuthenticationTest test. reason: An SQL data change is not permitted for a read-only connection, user or database. updating retry logic in DatabasePropertyTestSetup also adding code to CleanDatabaseTestSetup to catch any test leaving a connection in read-only mode and making it fail. Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DatabasePropertyTestSetup.java Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java?rev=1336349&r1=1336348&r2=1336349&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java Wed May 9 18:49:41 2012 @@ -150,7 +150,17 @@ public class CleanDatabaseTestSetup exte */ protected void tearDown() throws Exception { Connection conn = getConnection(); + // See DERBY-5686 - perhaps there's a test that leaves a + // connection in read-only state - let's check here and + // if there's a conn that's read-only, unset it, and make + // the test fail so we find it. conn.setAutoCommit(false); + boolean ok=true; + if (conn.isReadOnly()) + { + conn.setReadOnly(false); + ok=false; + } // Clean the database, ensures that any failure dropping // objects can easily be linked to test fixtures that @@ -162,6 +172,8 @@ public class CleanDatabaseTestSetup exte // Compress is a somewhat expensive operation so avoid it if possible. CleanDatabaseTestSetup.cleanDatabase(conn, false); super.tearDown(); + if (!ok) + fail("the test that was just run left the conn read-only"); } /** Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DatabasePropertyTestSetup.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DatabasePropertyTestSetup.java?rev=1336349&r1=1336348&r2=1336349&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DatabasePropertyTestSetup.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DatabasePropertyTestSetup.java Wed May 9 18:49:41 2012 @@ -300,7 +300,19 @@ public class DatabasePropertyTestSetup e System.out.println("conn.getAutoCommit: " + conn.getAutoCommit()); // now try to close the connection, then try open a new one, // and try to executeUpdate again. - conn.close(); + try { + conn.close(); + } catch (SQLException isqle) { + if (sqle.getSQLState()=="25001") + { + // the transaction is still active. let's commit what we have. + conn.commit(); + conn.close(); + } else { + System.out.println("close failed - see SQLState."); + throw sqle; + } + } Connection conn2 = getConnection(); // check if this second connection is read-only if (conn2.isReadOnly()) @@ -369,8 +381,21 @@ public class DatabasePropertyTestSetup e System.out.println("conn.getAutoCommit: " + conn.getAutoCommit()); // now try to close the connection, then try open a new one, // and try to executeUpdate again. - conn.close(); + try { + conn.close(); + } catch (SQLException isqle) { + if (sqle.getSQLState()=="25001") + { + // the transaction is still active. let's commit what we have. + conn.commit(); + conn.close(); + } else { + System.out.println("close failed - see SQLState."); + throw sqle; + } + } Connection conn2 = getConnection(); + // check if this second connection is read-only if (conn2.isReadOnly()) {