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 my...@apache.org on 2012/05/01 02:45:07 UTC

svn commit: r1332484 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DatabasePropertyTestSetup.java

Author: myrnavl
Date: Tue May  1 00:45:07 2012
New Revision: 1332484

URL: http://svn.apache.org/viewvc?rev=1332484&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. 
  Another attempt to catch the error and print info - now if it happens in 
  DatabasePropertyTestSetup.setUp.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DatabasePropertyTestSetup.java

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=1332484&r1=1332483&r2=1332484&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 Tue May  1 00:45:07 2012
@@ -292,7 +292,7 @@ public class DatabasePropertyTestSetup e
             if (sqle.getSQLState().equals("25502")) {
                 // firstly, check on the state of the connection when we
                 // get this error
-                System.out.println("Apparently this is a read-only connection? Get some data:");
+                System.out.println("Apparently this is a read-only connection in teardown()? Get some data:");
                 System.out.println("conn.isClosed: " + conn.isClosed());
                 System.out.println("conn.isReadOnly: " + conn.isReadOnly());
                 System.out.println("conn.getHoldability: " + conn.getHoldability());
@@ -351,6 +351,46 @@ public class DatabasePropertyTestSetup e
     private void setProperties(Properties values) throws SQLException
     {
         Connection conn = getConnection();
+        try {
+            attemptSetProperties(values, conn);
+        } catch (SQLException sqle) {
+            // To try to prevent the error situation of DERBY-5686, which
+            // cascades to many test failures, catch ERROR 25502, and if it occurs
+            // try to gather some information, close the connection,
+            // and retry the clearing of the properties on a new connection
+            if (sqle.getSQLState().equals("25502")) {
+                // firstly, check on the state of the connection when we
+                // get this error
+                System.out.println("Apparently this is a read-only connection? Get some data:");
+                System.out.println("conn.isClosed: " + conn.isClosed());
+                System.out.println("conn.isReadOnly: " + conn.isReadOnly());
+                System.out.println("conn.getHoldability: " + conn.getHoldability());
+                System.out.println("conn.getTransactionIsolation: " + conn.getTransactionIsolation());
+                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();
+                Connection conn2 = getConnection();
+                // check if this second connection is read-only
+                if (conn2.isReadOnly())
+                {
+                    System.out.println("Sorry, conn2 is also read-only, won't retry");
+                    // give up
+                    throw sqle;
+                }
+                else
+                {   
+                    // retry
+                    System.out.println("retrying to set the Properties");
+                    attemptSetProperties(values, conn2);
+                }
+            }
+        }
+    }
+    
+    private void attemptSetProperties(Properties values, Connection coonn) throws SQLException
+    {
+        Connection conn = getConnection();
         conn.setAutoCommit(false);
         
         PreparedStatement getDBP =  conn.prepareStatement(