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 ma...@apache.org on 2012/03/22 01:17:35 UTC

svn commit: r1303630 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/LobLimitsTest.java

Author: mamta
Date: Thu Mar 22 00:17:35 2012
New Revision: 1303630

URL: http://svn.apache.org/viewvc?rev=1303630&view=rev
Log:
DERBY-5638 intermittent test failure in test_05_ClobNegative when running full largedata._Suite; LobLimitsTestjava.sql.SQLException: Table/View 'BLOBTBL' already exists in Schema 'APP'.


Adding a new test fixture to LobLimitsTest.java which will shutdown the databases. This test fixture will be the last one to get executed in the suite since the tests are run in order in this particular suite. This shutdown will ensure that all the logs are applied to the database and hence there are no unapplied log files left at the end of the suite. Large data suite deals will large data objects which can cause us to have large log files and if the database is not shutdown at the end of the suite, the suite will finish successfully but will leave a database directory with large number of big log files. Nightly machines which run this suite on a regular basis can eventually run out of disk space if those machines do not delete the database directories from multiple runs.

I ran the large data suite on my machine and it ran with no problems. I checked the size of the database wombat after the suite finished and the size of the db was much smaller because of addition of shutdown databases fixture.

Another change made as part of the code changes is to do a truncate table after doing delete from table. TRUNCATE table will avoid post-commit work and shouldn't cause any concurrent locking to happen. We do not want to remove delete from table though because it exercises separate code path in Derby compared to TRUNCATE.


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/LobLimitsTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/LobLimitsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/LobLimitsTest.java?rev=1303630&r1=1303629&r2=1303630&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/LobLimitsTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/LobLimitsTest.java Thu Mar 22 00:17:35 2012
@@ -213,11 +213,11 @@ public class LobLimitsTest extends BaseJ
         selectUpdateBlob2("BlobTest #6", selectBlob2, selectBlob,
                 BIG_LOB_SZ, 0, 1, DATAFILE);
 
-        deleteTable("BLOBTBL2", 1);
+        deleteAndTruncateTable("BLOBTBL2", 1);
 
         commit();
 
-        deleteTable("BLOBTBL", 3);
+        deleteAndTruncateTable("BLOBTBL", 3);
     }
 
     public void test_02_BlobNegative() throws SQLException {
@@ -384,7 +384,7 @@ public class LobLimitsTest extends BaseJ
             // stream length is one less than actual length of the stream
             assertSQLState("XSDA4", sqle);
         }
-        deleteTable("CLOBTBL2", 2);
+        deleteAndTruncateTable("CLOBTBL2", 2);
 
         try {
             // give -ve streamlength
@@ -397,7 +397,7 @@ public class LobLimitsTest extends BaseJ
 
         selectClob("ClobTest #12.2", selectClob, BIG_LOB_SZ, 4, 0);
 
-        deleteTable("CLOBTBL", 2);
+        deleteAndTruncateTable("CLOBTBL", 2);
 
         // Negative tests use the setClob API to insert a 4GB clob
 
@@ -427,6 +427,21 @@ public class LobLimitsTest extends BaseJ
         // ADD NEW TESTS HERE
     }
 
+    //DERBY-5638
+    // Following shutdown will ensure that all the logs are applied to the
+    // database and hence there are no unapplied log files left at the end 
+    // of the suite. 
+    //This test deals will large data objects which can cause us to have 
+    // large log files and if the database is not shutdown at the end of the 
+    // suite, the suite will finish successfully but will leave a database 
+    // directory with large number of big log files. Nightly machines which
+    // run this suite on a regular basis can eventually run out of disk space
+    // if those machines do not delete the database directories from multiple 
+    // runs.
+    public void test_06_shutdownDB() throws Exception {
+        TestConfiguration.getCurrent().shutdownDatabase();
+    }
+
     private void negativeSpaceTruncationTest(String msg)
             throws Exception {
         PreparedStatement insertClob2 =
@@ -825,10 +840,19 @@ public class LobLimitsTest extends BaseJ
         assertEquals(file, lobstream);
     }
 
-    private void deleteTable(String table,
+    private void deleteAndTruncateTable(String table,
             int expectedRows) throws SQLException {
-        int count = createStatement().executeUpdate(
+    	Statement s = createStatement();
+        //Keep the delete call to exercise delete of long blobs and clobs.
+    	// This is a separate code path through Derby compared to truncate
+    	// table code path.
+        int count = s.executeUpdate(
                 "DELETE FROM " + JDBC.escape(table));
+        //DERBY-5638
+        //Adding truncate call which will give back the disk space being 
+        // used by the table at commit time rather than wait for test 
+        // infrastructure to drop the table.
+        s.executeUpdate("TRUNCATE TABLE " + JDBC.escape(table));
         commit();
         verifyTest(count, expectedRows, "Rows deleted =");
     }