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 mi...@apache.org on 2005/06/29 02:37:26 UTC

svn commit: r202302 - in /incubator/derby/code/trunk/java: engine/org/apache/derby/impl/store/raw/data/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/suites/ testing/org/apache/derbyTesting/function...

Author: mikem
Date: Tue Jun 28 17:37:24 2005
New Revision: 202302

URL: http://svn.apache.org/viewcvs?rev=202302&view=rev
Log:
DERBY-361 fix. 

Needed to force a checkpoint before compress, otherwise during crash recovery
it was possible to redo a page that no longer existed in the file because
of compress.  This fix adds a number of recovery crash and transaction 
abort tests specific to compress into the storerecovery test suite.



Added:
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec1.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec2.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec3.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec4.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec1.java
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec2.java
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec3.java
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec4.java
Modified:
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocExtent.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseContainer.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CompressSpacePageOperation.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/PhysicalUndoOperation.java
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storerecovery.runall
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BaseTest.java
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineCompressTest.java

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocExtent.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocExtent.java?rev=202302&r1=202301&r2=202302&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocExtent.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocExtent.java Tue Jun 28 17:37:24 2005
@@ -587,6 +587,43 @@
         return;
     }
 
+    /**
+     * Undo the compress space operation.
+     * <p>
+     * Undo of this operation doesn't really "undo" the operation, it just
+     * makes sure the data structures are ok after the undo.  We are 
+     * guaranteed at the point of the transaction doing the 
+     * Undo of the compress space operation fixes up the bit maps to
+     * only point at pages within the new_highest_page range.
+     * <p>
+     * Prior to logging the compress space operation all pages greater 
+     * than 
+     * There are only 2 possibilities at this point:
+     * 1) the truncate of pages greater than new_highest_page happened before
+     *    the abort took place.  W
+     * 2) 
+     *
+	 * @return The identifier to be used to open the conglomerate later.
+     *
+     * @param param1 param1 does this.
+     * @param param2 param2 does this.
+     *
+	 * @exception  StandardException  Standard exception policy.
+     **/
+    protected void undoCompressPages(
+    int        new_highest_page,
+    int        num_pages_truncated)
+    {
+        if (new_highest_page >= 0)
+        {
+            freePages.shrink(new_highest_page + 1);
+            unFilledPages.shrink(new_highest_page + 1);
+            preAllocLength = extentLength = (new_highest_page + 1);
+        }
+
+        return;
+    }
+
 	protected long getExtentEnd()
 	{
 		return extentEnd;

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java?rev=202302&r1=202301&r2=202302&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java Tue Jun 28 17:37:24 2005
@@ -916,6 +916,21 @@
         extent.compressPages(new_highest_page, num_pages_truncated);
 	}
 
+    /**
+     * Handle undo of compress space operation.
+     **/
+	protected void undoCompressSpace(
+    LogInstant  instant,
+    int         new_highest_page,
+    int         num_pages_truncated)
+		throws StandardException
+    {
+		logAction(instant);
+
+        extent.undoCompressPages(new_highest_page, num_pages_truncated);
+
+    }
+
 	public String toString()
 	{
 		if (SanityManager.DEBUG)

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseContainer.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseContainer.java?rev=202302&r1=202301&r2=202302&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseContainer.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseContainer.java Tue Jun 28 17:37:24 2005
@@ -221,7 +221,7 @@
 		}
 		finally
 		{
-            ntt.commitNoSync(Transaction.RELEASE_LOCKS);
+            ntt.commit();
 
 			ntt.close();
 		}

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CompressSpacePageOperation.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CompressSpacePageOperation.java?rev=202302&r1=202301&r2=202302&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CompressSpacePageOperation.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/CompressSpacePageOperation.java Tue Jun 28 17:37:24 2005
@@ -182,7 +182,7 @@
 				"undo Page is not an allocPage");
 		}
 
-		((AllocPage)undoPage).compressSpace(
+		((AllocPage)undoPage).undoCompressSpace(
              CLRInstant, newHighestPage, num_pages_truncated);
 	}
 

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java?rev=202302&r1=202301&r2=202302&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java Tue Jun 28 17:37:24 2005
@@ -1351,6 +1351,12 @@
 			return;
         }
 
+        // make sure we don't execute redo recovery on any page
+        // which is getting truncated.  At this point we have an exclusive
+        // table lock on the table, so after checkpoint no page change
+        // can happen between checkpoint log record and compress of space.
+        dataFactory.getRawStoreFactory().checkpoint();
+
 		try
 		{
             synchronized(allocCache)
@@ -1388,6 +1394,7 @@
                 // reset, as pages may not exist after compress
                 lastUnfilledPage    = ContainerHandle.INVALID_PAGE_NUMBER;
                 lastAllocatedPage   = ContainerHandle.INVALID_PAGE_NUMBER;
+
 
                 alloc_page.compress(ntt, this);
             }

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/PhysicalUndoOperation.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/PhysicalUndoOperation.java?rev=202302&r1=202301&r2=202302&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/PhysicalUndoOperation.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/PhysicalUndoOperation.java Tue Jun 28 17:37:24 2005
@@ -146,7 +146,19 @@
 		undoOp.undoMe(xact, this.page, instant, in);
 
 		if (SanityManager.DEBUG) {
-			SanityManager.ASSERT(oldversion < this.page.getPageVersion());
+
+            if (oldversion >= this.page.getPageVersion())
+            {
+                SanityManager.THROWASSERT(
+                    "oldversion = " + oldversion +
+                    ";page version = "  + this.page.getPageVersion() +
+                    "page = " + page + 
+                    "; my class name is " + getClass().getName() +
+                    " undoOp is " + undoOp.getClass().getName() );
+            }
+			SanityManager.ASSERT(
+                oldversion < this.page.getPageVersion());
+
 			if (instant != null &&
 				! instant.equals(this.page.getLastLogInstant()))
 				SanityManager.THROWASSERT(

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec1.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec1.out?rev=202302&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec1.out (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec1.out Tue Jun 28 17:37:24 2005
@@ -0,0 +1,2 @@
+Beginning test: test1
+Ending test: test1

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec2.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec2.out?rev=202302&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec2.out (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec2.out Tue Jun 28 17:37:24 2005
@@ -0,0 +1,2 @@
+Beginning test: test1
+Ending test: test1

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec3.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec3.out?rev=202302&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec3.out (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec3.out Tue Jun 28 17:37:24 2005
@@ -0,0 +1,2 @@
+Beginning test: test1
+Ending test: test1

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec4.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec4.out?rev=202302&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec4.out (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/oc_rec4.out Tue Jun 28 17:37:24 2005
@@ -0,0 +1,2 @@
+Beginning test: test1
+Ending test: test1

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storerecovery.runall
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storerecovery.runall?rev=202302&r1=202301&r2=202302&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storerecovery.runall (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storerecovery.runall Tue Jun 28 17:37:24 2005
@@ -3,3 +3,7 @@
 store/LogChecksumRecovery1.java
 store/MaxLogNumber.java
 store/MaxLogNumberRecovery.java
+store/oc_rec1.java
+store/oc_rec2.java
+store/oc_rec3.java
+store/oc_rec4.java

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BaseTest.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BaseTest.java?rev=202302&r1=202301&r2=202302&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BaseTest.java (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BaseTest.java Tue Jun 28 17:37:24 2005
@@ -107,6 +107,22 @@
     }
 
     /**
+     * Simple wrapper to execute a sql string.
+     **/
+    public void executeQuery(
+    Connection  conn,
+    String      stmt_str,
+    boolean     commit_query)
+        throws SQLException
+    {
+        Statement stmt = conn.createStatement();
+        stmt.executeUpdate(stmt_str);
+        stmt.close();
+        if (commit_query)
+            conn.commit();
+    }
+
+    /**
      * Call consistency checker on the table.
      * <p>
      **/

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineCompressTest.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineCompressTest.java?rev=202302&r1=202301&r2=202302&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineCompressTest.java (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineCompressTest.java Tue Jun 28 17:37:24 2005
@@ -48,7 +48,7 @@
      * Utility test function to call the system procedure.
      *
      **/
-    private void callCompress(
+    protected void callCompress(
     Connection  conn,
     String      schemaName,
     String      tableName,
@@ -173,11 +173,12 @@
      *
 	 * @exception  StandardException  Standard exception policy.
      **/
-    private void createAndLoadTable(
+    protected void createAndLoadTable(
     Connection  conn,
     boolean     create_table,
     String      tblname,
-    int         num_rows)
+    int         num_rows,
+    int         start_value)
         throws SQLException
     {
         if (create_table)
@@ -209,14 +210,14 @@
         int row_count = 0;
         try
         {
-            for (;row_count < num_rows; row_count++)
+            for (int i = start_value; row_count < num_rows; row_count++, i++)
             {
-                insert_stmt.setInt(1, row_count);               // keycol
-                insert_stmt.setInt(2, row_count * 10);          // indcol1
-                insert_stmt.setInt(3, row_count * 100);         // indcol2
-                insert_stmt.setInt(4, -row_count);              // indcol3
-                insert_stmt.setString(5, data1_str);            // data1_data
-                insert_stmt.setString(6, data2_str);            // data2_data
+                insert_stmt.setInt(1, i);               // keycol
+                insert_stmt.setInt(2, i * 10);          // indcol1
+                insert_stmt.setInt(3, i * 100);         // indcol2
+                insert_stmt.setInt(4, -i);              // indcol3
+                insert_stmt.setString(5, data1_str);    // data1_data
+                insert_stmt.setString(6, data2_str);    // data2_data
 
                 insert_stmt.execute();
             }
@@ -384,19 +385,6 @@
         conn.commit();
     }
 
-    private void executeQuery(
-    Connection  conn,
-    String      stmt_str,
-    boolean     commit_query)
-        throws SQLException
-    {
-        Statement stmt = conn.createStatement();
-        stmt.executeUpdate(stmt_str);
-        stmt.close();
-        if (commit_query)
-            conn.commit();
-    }
-
     private void log_wrong_count(
     String  error_msg,
     String  table_name,
@@ -442,7 +430,7 @@
         if (long_table)
             createAndLoadLongTable(conn, create_table, table_name, num_rows);
         else
-            createAndLoadTable(conn, create_table, table_name, num_rows);
+            createAndLoadTable(conn, create_table, table_name, num_rows, 0);
 
         if (verbose)
             testProgress("Calling compress.");
@@ -525,7 +513,7 @@
         if (long_table)
             createAndLoadLongTable(conn, create_table, table_name, num_rows);
         else
-            createAndLoadTable(conn, create_table, table_name, num_rows);
+            createAndLoadTable(conn, create_table, table_name, num_rows, 0);
 
         if (verbose)
             testProgress("Calling compress.");
@@ -601,7 +589,7 @@
         if (long_table)
             createAndLoadLongTable(conn, create_table, table_name, num_rows);
         else
-            createAndLoadTable(conn, create_table, table_name, num_rows);
+            createAndLoadTable(conn, create_table, table_name, num_rows, 0);
 
         // dump_table(conn, schemaName, table_name, false);
 
@@ -728,7 +716,7 @@
         if (long_table)
             createAndLoadLongTable(conn, create_table, table_name, num_rows);
         else
-            createAndLoadTable(conn, create_table, table_name, num_rows);
+            createAndLoadTable(conn, create_table, table_name, num_rows, 0);
         conn.commit();
 
         // delete all rows, and NO commit.

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec1.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec1.java?rev=202302&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec1.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec1.java Tue Jun 28 17:37:24 2005
@@ -0,0 +1,91 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.harness.procedure
+
+   Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.functionTests.tests.store;
+
+import org.apache.derby.iapi.db.OnlineCompress;
+
+import org.apache.derby.iapi.services.sanity.SanityManager;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.derby.tools.ij;
+
+
+public class oc_rec1 extends OnlineCompressTest
+{
+
+    public oc_rec1()
+    {
+    }
+
+    /**
+     * setup for restart recovery test.
+     * <p>
+     * Do setup to test restart recovery of online compress.  Real work
+     * is done in next test oc_rec2 which will run restart recovery on
+     * the work done in this test.
+     *
+     **/
+    private void test1(
+    Connection  conn,
+    String      test_name,
+    String      table_name)
+        throws SQLException
+    {
+        beginTest(conn, test_name);
+        createAndLoadTable(conn, true, table_name, 5000, 0);
+        executeQuery(conn, "delete from " + table_name, true);
+        callCompress(conn, "APP", table_name, true, true, true, true);
+        endTest(conn, test_name);
+    }
+
+    public void testList(Connection conn)
+        throws SQLException
+    {
+        test1(conn, "test1", "TEST1");
+    }
+
+    public static void main(String[] argv) 
+        throws Throwable
+    {
+        oc_rec1 test = new oc_rec1();
+
+   		ij.getPropertyArg(argv); 
+        Connection conn = ij.startJBMS();
+        conn.setAutoCommit(false);
+
+        try
+        {
+            test.testList(conn);
+        }
+        catch (SQLException sqle)
+        {
+			org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(
+                System.out, sqle);
+			sqle.printStackTrace(System.out);
+		}
+    }
+}

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec2.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec2.java?rev=202302&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec2.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec2.java Tue Jun 28 17:37:24 2005
@@ -0,0 +1,107 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.harness.procedure
+
+   Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.functionTests.tests.store;
+
+import org.apache.derby.iapi.db.OnlineCompress;
+
+import org.apache.derby.iapi.services.sanity.SanityManager;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.derby.tools.ij;
+
+
+public class oc_rec2 extends OnlineCompressTest
+{
+
+    public oc_rec2()
+    {
+    }
+
+    /**
+     * setup for restart recovery test.
+     * <p>
+     * Do setup to test restart recovery of online compress.  Real work
+     * is done in next test oc_rec2 which will run restart recovery on
+     * the work done in this test.
+     *
+     **/
+    private void test1(
+    Connection  conn,
+    String      test_name,
+    String      table_name)
+        throws SQLException
+    {
+        beginTest(conn, test_name);
+        if (!checkConsistency(conn, "APP", table_name))
+        {
+            logError("conistency check failed.");
+        }
+        // make sure we can add data to the existing table after redo
+        // recovery.
+        createAndLoadTable(conn, false, table_name, 6000, 0);
+        if (!checkConsistency(conn, "APP", table_name))
+        {
+            logError("conistency check failed.");
+        }
+
+        // setup to test redo recovery on: 
+        //     create table, delete rows, compress, add rows, commit
+        String table_name_2 =  table_name + "_2";
+        createAndLoadTable(conn, true, table_name_2, 2000, 0);
+        executeQuery(conn, "delete from " + table_name, true);
+        callCompress(conn, "APP", table_name, true, true, true, true);
+
+        endTest(conn, test_name);
+    }
+
+    public void testList(Connection conn)
+        throws SQLException
+    {
+        test1(conn, "test1", "TEST1");
+    }
+
+    public static void main(String[] argv) 
+        throws Throwable
+    {
+        oc_rec2 test = new oc_rec2();
+
+   		ij.getPropertyArg(argv); 
+        Connection conn = ij.startJBMS();
+        conn.setAutoCommit(false);
+
+        try
+        {
+            test.testList(conn);
+        }
+        catch (SQLException sqle)
+        {
+			org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(
+                System.out, sqle);
+			sqle.printStackTrace(System.out);
+		}
+    }
+}

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec3.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec3.java?rev=202302&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec3.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec3.java Tue Jun 28 17:37:24 2005
@@ -0,0 +1,109 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.harness.procedure
+
+   Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.functionTests.tests.store;
+
+import org.apache.derby.iapi.db.OnlineCompress;
+
+import org.apache.derby.iapi.services.sanity.SanityManager;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.derby.tools.ij;
+
+
+public class oc_rec3 extends OnlineCompressTest
+{
+
+    public oc_rec3()
+    {
+    }
+
+    /**
+     * setup for restart recovery test.
+     * <p>
+     * Do setup to test restart recovery of online compress.  Real work
+     * is done in next test oc_rec3 which will run restart recovery on
+     * the work done in this test.
+     *
+     **/
+    private void test1(
+    Connection  conn,
+    String      test_name,
+    String      table_name)
+        throws SQLException
+    {
+        beginTest(conn, test_name);
+
+        String table_name_2 =  table_name + "_2";
+        if (!checkConsistency(conn, "APP", table_name_2))
+        {
+            logError("conistency check failed.");
+        }
+
+        // make sure we can add data to the existing table after redo
+        // recovery.
+        createAndLoadTable(conn, false, table_name, 2000, 0);
+        if (!checkConsistency(conn, "APP", table_name))
+        {
+            logError("conistency check failed.");
+        }
+
+        // setup to test redo recovery on: 
+        //     add more rows, delete rows, compress, add more, no commit
+        createAndLoadTable(conn, false, table_name_2, 4000, 2000);
+        executeQuery(conn, "delete from " + table_name_2, true);
+        callCompress(conn, "APP", table_name_2, true, true, true, false);
+
+        endTest(conn, test_name);
+    }
+
+    public void testList(Connection conn)
+        throws SQLException
+    {
+        test1(conn, "test1", "TEST1");
+    }
+
+    public static void main(String[] argv) 
+        throws Throwable
+    {
+        oc_rec3 test = new oc_rec3();
+
+   		ij.getPropertyArg(argv); 
+        Connection conn = ij.startJBMS();
+        conn.setAutoCommit(false);
+
+        try
+        {
+            test.testList(conn);
+        }
+        catch (SQLException sqle)
+        {
+			org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(
+                System.out, sqle);
+			sqle.printStackTrace(System.out);
+		}
+    }
+}

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec4.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec4.java?rev=202302&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec4.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/oc_rec4.java Tue Jun 28 17:37:24 2005
@@ -0,0 +1,104 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.harness.procedure
+
+   Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.functionTests.tests.store;
+
+import org.apache.derby.iapi.db.OnlineCompress;
+
+import org.apache.derby.iapi.services.sanity.SanityManager;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.derby.tools.ij;
+
+
+public class oc_rec4 extends OnlineCompressTest
+{
+
+    public oc_rec4()
+    {
+    }
+
+    /**
+     * setup for restart recovery test.
+     * <p>
+     * Do setup to test restart recovery of online compress.  Real work
+     * is done in next test oc_rec4 which will run restart recovery on
+     * the work done in this test.
+     *
+     **/
+    private void test1(
+    Connection  conn,
+    String      test_name,
+    String      table_name)
+        throws SQLException
+    {
+        beginTest(conn, test_name);
+
+        // oc_rec3 left the table  with no rows, but compress command
+        // did not commit.
+        String table_name_2 =  table_name + "_2";
+        if (!checkConsistency(conn, "APP", table_name_2))
+        {
+            logError("conistency check failed.");
+        }
+
+        // make sure we can add data to the existing table after redo
+        // recovery.
+        createAndLoadTable(conn, false, table_name_2, 6000, 0);
+        if (!checkConsistency(conn, "APP", table_name_2))
+        {
+            logError("conistency check failed.");
+        }
+        endTest(conn, test_name);
+    }
+
+    public void testList(Connection conn)
+        throws SQLException
+    {
+        test1(conn, "test1", "TEST1");
+    }
+
+    public static void main(String[] argv) 
+        throws Throwable
+    {
+        oc_rec4 test = new oc_rec4();
+
+   		ij.getPropertyArg(argv); 
+        Connection conn = ij.startJBMS();
+        conn.setAutoCommit(false);
+
+        try
+        {
+            test.testList(conn);
+        }
+        catch (SQLException sqle)
+        {
+			org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(
+                System.out, sqle);
+			sqle.printStackTrace(System.out);
+		}
+    }
+}