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 2006/03/13 23:20:12 UTC
svn commit: r385674 [2/3] - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests:
store/ storetests/
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest3.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest3.java?rev=385674&r1=385673&r2=385674&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest3.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest3.java Mon Mar 13 14:20:10 2006
@@ -1,554 +1,554 @@
-/*
-
- Derby - Class org.apache.derbyTesting.functionTests.store.OnlineBackupTest3
-
- 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 java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.Statement;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import org.apache.derby.tools.ij;
-import org.apache.derbyTesting.functionTests.util.TestUtil;
-import java.util.Properties;
-
-/*
- * This class tests online backup when jar actions
- * are running in parallel to the backup thread.
- *
- * @author <a href="mailto:suresh.thalamati@gmail.com">Suresh Thalamati</a>
- * @version 1.0
- */
-
-public class OnlineBackupTest3 {
-
- private static final String TEST_DATABASE_NAME = "wombat" ;
- private static final String BACKUP_PATH = "extinout/onlinebackuptest3";
-
- public static void main(String[] argv) throws Throwable {
-
- OnlineBackupTest3 test = new OnlineBackupTest3();
- ij.getPropertyArg(argv);
-
- try {
- test.runTest();
- }
- catch (SQLException sqle) {
- dumpSQLException(sqle);
- }
- }
-
-
- /*
- * Test online backup with unlogged jar operations running in parallel.
- */
- private void runTest() throws Exception{
- logMessage("Begin Online Backup Test3");
- Connection conn = ij.startJBMS();
- conn.setAutoCommit(false);
- Statement stmt = conn.createStatement();
- stmt.execute("create table t1(a int ) ");
- stmt.execute("insert into t1 values(1)");
- stmt.execute("insert into t1 values(2)");
- stmt.execute("create table customer(id int , name varchar(100))");
- stmt.execute("insert into customer values(1, 'ABC')");
- stmt.execute("insert into customer values(2, 'XYZ')");
- String crproc = "create procedure addCustomer(id INT, name VARCHAR(100)) " +
- "MODIFIES SQL DATA " +
- "external name " +
- "'org.apache.derbyTesting.backupRestore.Customer.addCustomer' " +
- " language java parameter style java ";
-
- stmt.execute(crproc);
-
- String dvfunc = "create function dv(P1 INT) RETURNS INT NO SQL " +
- " external name 'dbytesting.CodeInAJar.doubleMe' " +
- " language java parameter style java " ;
-
- stmt.execute(dvfunc) ;
- conn.commit();
-
- logMessage("Initial Setup Complete");
-
- // perform install jar operation with
- // online backup running in parallel.
- installJarTest();
-
- // perform remove jar operation with
- // online backup running in parallel.
- removeJarTest();
-
- logMessage("End Online Backup Test3");
- }
-
-
- /**
- * Shutdown the datbase
- * @param dbName Name of the database to shutdown.
- */
- void shutdown(String dbName) {
-
- try{
- //shutdown
- if(TestUtil.HAVE_DRIVER_CLASS)
- DriverManager.getConnection("jdbc:derby:" + dbName + ";shutdown=true");
- else
- TestUtil.shutdownUsingDataSource(dbName);
- }catch(SQLException se){
- if (se.getSQLState() != null && se.getSQLState().equals("08006"))
- System.out.println("database shutdown properly");
- else
- dumpSQLException(se);
- }
- }
-
- /*
- * get connection to the test database
- */
- Connection getConnection() throws SQLException
- {
- Connection conn;
- if(TestUtil.HAVE_DRIVER_CLASS)
- conn = DriverManager.getConnection("jdbc:derby:" + TEST_DATABASE_NAME );
- else {
- Properties prop = new Properties();
- prop.setProperty("databaseName", TEST_DATABASE_NAME);
- conn = TestUtil.getDataSourceConnection(prop);
- }
- return conn;
- }
-
-
- /**
- * Write message to the standard output.
- */
- void logMessage(String str){
- System.out.println(str);
- }
-
- /**
- * dump the SQLException to the standard output.
- */
- static private void dumpSQLException(SQLException sqle) {
-
- org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(System.out, sqle);
- sqle.printStackTrace(System.out);
- }
-
-
- private int countRows(Connection conn,
- String tableName)
- throws SQLException
- {
- Statement s = conn.createStatement();
- ResultSet rs = s.executeQuery("SELECT count(*) from " + tableName );
- rs.next();
- int noRows = rs.getInt(1);
- rs.close();
- s.close();
- return noRows;
- }
-
- /*
- * Test install jar running in parallel to backup and vice versa.
- */
- void installJarTest() throws Exception{
- logMessage("Begin Install Jar Test");
- Connection conn1 = getConnection();
- conn1.setAutoCommit(false);
- Statement conn1_stmt = conn1.createStatement();
- Connection conn2 = getConnection();
- conn2.setAutoCommit(false);
- Statement conn2_stmt = conn2.createStatement();
-
-
- conn1_stmt.execute(
- "call sqlj.install_jar('extin/brtestjar.jar', 'math_routines', 0)");
-
- try {
- // followng backup call should fail because jar operation is pending
- conn2_stmt.execute(
- "call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_NOWAIT('extinout/mybackup')");
- } catch (SQLException sqle) {
- //above statement should have failed.
- org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(System.out, sqle);
- }
-
- // invoke backup in another thread, it should block for the above install jar
- // operation to install 'brtestjar.jar to commit.
-
- // start a thread to perform online backup
- OnlineBackup backup = new OnlineBackup(TEST_DATABASE_NAME, BACKUP_PATH);
- Thread backupThread = new Thread(backup, "BACKUP1");
- backupThread.start();
- // wait for the backup to start
- backup.waitForBackupToBegin();
- logMessage("Backup-1 Started");
-
- // sleep for few seconds just to make sure backup thread has actually
- // gone into a wait state for unlogged actions to commit.
- java.lang.Thread.sleep(1000);
-
- // backup should not even start doing real work before the
- // unlogged transaction is commited
- if(!backup.isRunning())
- logMessage("Backup is not waiting for unlogged " +
- "install jar action to commit");
-
- //insert some rows that should appear in the backup.
- conn1_stmt.execute("insert into t1 values(3)");
- conn1_stmt.execute("insert into t1 values(4)");
- conn1_stmt.execute("insert into t1 values(5)");
-
- // set the database class with both the jars installed above.
- conn1_stmt.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( " +
- "'derby.database.classpath', " +
- "'APP.math_routines') " ) ;
-
- //commit the transaction with jar opearation that is blocking the backup.
- conn1.commit();
- logMessage("The transaction that was blocking the backup has ended");
-
- // wait for backup to finish.
- backup.waitForBackupToEnd();
- backupThread.join();
- logMessage("Backup-1 Completed");
-
- // Case : jar op should block if backup is in progress
- // add a index that will block the backup until it is committted.
- conn1_stmt.execute("create index idx1 on customer(id)");
- conn1_stmt.execute("insert into t1 values(6)");
-
- // start a thread to perform online backup
- backup = new OnlineBackup(TEST_DATABASE_NAME, BACKUP_PATH);
- backupThread = new Thread(backup, "BACKUP2");
- backupThread.start();
- // wait for the backup to start
- backup.waitForBackupToBegin();
- logMessage("Backup-2 Started");
-
- // sleep for few seconds just to make sure backup thread is actually
- // gone to a wait state for unlogged actions to commit.
- java.lang.Thread.sleep(1000);
-
- // backup should not even start doing real work before the
- // unlogged transaction is commited
- if(!backup.isRunning())
- logMessage("Backup is not waiting for unlogged " +
- "index action to commit");
-
-
- // add another jar file , this one should block and
- // should not get into the backup. Backup does not allow new
- // jar operation if it is already waiting for backup blocking
- // to complete(commit/rollback).
-
- AsyncStatementThread asyncJarActionThread =
- new AsyncStatementThread(conn2,
- "call sqlj.install_jar('extin/obtest_customer.jar', 'customer_app', 0)");
- asyncJarActionThread.start();
- logMessage("Started obtest_customer.jar addition in seperate thread");
-
- //sleep for few seconds to give a chance for the
- //jar addition thread to get into action.
- java.lang.Thread.sleep(1000);
-
- //roll back the index op. Backup should proceed now.
- conn1.rollback();
- logMessage("The transaction that was blocking the backup has ended");
-
- // wait for backup to finish.
- backup.waitForBackupToEnd();
- backupThread.join();
- logMessage("Backup-2 Completed");
-
- // wait for customer app jar installation to finish now.
- asyncJarActionThread.join();
- logMessage("obtest_customer.jar addition is complete");
-
- // set the database class with both the jars installed above.
- conn1_stmt.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( " +
- "'derby.database.classpath', " +
- "'APP.customer_app:APP.math_routines') " ) ;
-
- conn1.commit();
-
- // second jar must have got installed after the backup.
- // call a function in the custome_app jar
- conn1_stmt.execute("call addCustomer(3 , 'John')");
- conn1.commit();
-
- logMessage("No of rows in table t1: " + countRows(conn1, "T1"));
- logMessage("No of rows in table customer: " +
- countRows(conn1, "customer"));
- conn1.commit();
- conn2.commit();
- conn1_stmt.close();
- conn2_stmt.close();
- conn1.close();
- conn2.close();
-
- //shutdown the test db
- shutdown(TEST_DATABASE_NAME);
- // restore the database from the backup and run some checks
- backup.restoreFromBackup();
- logMessage("Restored From the Backup");
- Connection conn = getConnection();
- Statement stmt = conn.createStatement();
- logMessage("No of rows in table t1: " + countRows(conn, "T1"));
- logMessage("No of rows in table customer: " +
- countRows(conn, "customer"));
- // execute select statement using the "dv" funciont.
- stmt.execute("select dv(a) from t1");
-
-
- try {
- // set the database class with both the jars installed above.
- stmt.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( " +
- "'derby.database.classpath', " +
- "'APP.customer_app:APP.math_routines') " ) ;
- stmt.execute("call addCustomer(3 , 'John')");
- }catch(SQLException se) {
- //ignore for now. No sure way to
- //check that jar did not get into backup
- //without debug flags.
- }
-
- stmt.close();
- conn.close();
-
- //shutdown the test db
- shutdown(TEST_DATABASE_NAME);
- logMessage("End Of Install Jar Test.");
-
- }
-
-
- /*
- * Test remove jar running in parallel to backup and vice versa.
- */
- void removeJarTest() throws Exception{
- logMessage("Begin Remove Jar Test");
- Connection conn1 = getConnection();
- conn1.setAutoCommit(false);
- Statement conn1_stmt = conn1.createStatement();
- Connection conn2 = getConnection();
- conn2.setAutoCommit(false);
- Statement conn2_stmt = conn2.createStatement();
- try {
- conn1_stmt.execute(
- "call sqlj.install_jar('extin/obtest_customer.jar', 'customer_app', 0)");
- }catch(SQLException se) {
- //it is ok if was jar already there.
- }
-
- // remove both the jars from the class path ,
- // so that we can remove them from the database.
- conn1_stmt.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( " +
- "'derby.database.classpath', '')") ;
- conn1.commit();
-
- conn1_stmt.execute(
- "call sqlj.remove_jar('APP.math_routines', 0)");
-
- // Case 0: backup call that is not waiting for unlogged
- // opereation to complete should fail when a remove jar
- // is not ended when backup started.
-
- try {
- // followng backup call should fail because remove
- // jar operation is pending
- conn2_stmt.execute(
- "call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_NOWAIT('extinout/mybackup')");
- } catch (SQLException sqle) {
- //above statement should have failed.
- org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(System.out, sqle);
- }
-
-
-
- // Case 1: backup should block because when a remove jar
- // is not ended when backup started.
-
- // invoke backup in another thread, should block for
- // the above remove jar to commit.
-
- // start a thread to perform online backup
- OnlineBackup backup = new OnlineBackup(TEST_DATABASE_NAME, BACKUP_PATH);
- Thread backupThread = new Thread(backup, "BACKUP3");
- backupThread.start();
- // wait for the backup to start
- backup.waitForBackupToBegin();
- logMessage("Backup-3 Started");
-
- // sleep for few seconds just to make sure backup thread is actually
- // gone to a wait state for unlogged actions to commit.
- java.lang.Thread.sleep(1000);
-
- // backup should not even start doing real work before the
- // unlogged transaction is commited
- if(!backup.isRunning())
- logMessage("Backup is not waiting for unlogged " +
- "remove jar action to commit");
-
- //insert some rows that should appear in the backup.
- conn1_stmt.execute("insert into t1 values(10)");
- conn1_stmt.execute("insert into t1 values(11)");
-
- //commit the transaction with jar opearation that is blocking the backup.
- conn1.commit();
- logMessage("The transaction that was blocking the backup has ended");
-
- // wait for backup to finish.
- backup.waitForBackupToEnd();
- backupThread.join();
-
- logMessage("Backup-3 Completed");
-
- // Case 2: remove jar op should block if backup is in progress
- // add a index that will block the backup until it is committted.
- conn1_stmt.execute("create index idx1 on customer(id)");
- conn1_stmt.execute("insert into t1 values(12)");
-
- // start a thread to perform online backup
- backup = new OnlineBackup(TEST_DATABASE_NAME, BACKUP_PATH);
- backupThread = new Thread(backup, "BACKUP4");
- backupThread.start();
- // wait for the backup to start
- backup.waitForBackupToBegin();
- logMessage("Backup-4 Started");
-
- // sleep for few seconds just to make sure backup thread is actually
- // gone to a wait state for unlogged actions to commit.
- java.lang.Thread.sleep(1000);
-
- // backup should not even start doing real work before the
- // unlogged transaction is commited
- if(!backup.isRunning())
- logMessage("Backup is not waiting for unlogged " +
- "index action to commit");
-
-
- // remove another jar file , this one should block and
- // should not get into the backup. Backup does not allow new
- // jar operation if it is already waiting for backup blocking
- // to complete(commit/rollback).
-
- AsyncStatementThread asyncJarActionThread =
- new AsyncStatementThread(conn2,
- "call sqlj.remove_jar('APP.customer_app', 0)");
- asyncJarActionThread.start();
- logMessage("Started obtest_customer.jar remove in seperate thread");
-
- //sleep for few seconds to give a chance for the
- //jar addition thread to get into action.
- java.lang.Thread.sleep(1000);
-
- //roll back the index op. Backup should proceed now.
- conn1.rollback();
- logMessage("The transaction that was blocking the backup has ended");
- // wait for backup to finish.
- backup.waitForBackupToEnd();
- backupThread.join();
- logMessage("Backup-4 Completed");
-
- // wait for customer app jar removal to finish now.
- asyncJarActionThread.join();
- logMessage("obtest_customer.jar remove is complete");
-
- //this insert should not apprear on restore.
- conn1_stmt.execute("insert into t1 values(13)");
-
- logMessage("No of rows in table t1: " + countRows(conn1, "T1"));
- logMessage("No of rows in table customer: " +
- countRows(conn1, "customer"));
- conn1.commit();
- conn2.commit();
- conn1_stmt.close();
- conn2_stmt.close();
- conn1.close();
- conn2.close();
-
- //shutdown the test db
- shutdown(TEST_DATABASE_NAME);
- // restore the database from the backup and run some checks
- backup.restoreFromBackup();
- logMessage("Restored From the Backup");
- Connection conn = getConnection();
- Statement stmt = conn.createStatement();
- logMessage("No of rows in table t1: " + countRows(conn, "T1"));
- logMessage("No of rows in table customer: " +
- countRows(conn, "customer"));
-
- // check if the jar removal was successful.
- // APP.math_routines should not be in backup.
- try {
- // set the database class path with the jar removed above,
- // it should fail.
- stmt.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( " +
- "'derby.database.classpath', " +
- "'APP.math_routines') " ) ;
- }catch (SQLException sqle) {
- //above statement should have failed.
- org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(System.out, sqle);
- }
-
-
- stmt.close();
- conn.close();
-
- //shutdown the test db
- shutdown(TEST_DATABASE_NAME);
- logMessage("End Of Remove Jar Test.");
-
- }
-
-
- /*
- * Run a sql statement in a seperate thread.
- */
- class AsyncStatementThread extends Thread {
- Connection conn;
- String stmt;
-
- AsyncStatementThread(Connection conn, String stmt) {
- this.conn = conn;
- this.stmt = stmt;
- }
-
- public void run() {
- Statement aStatement = null;
- try {
- aStatement = conn.createStatement();
- aStatement.execute(stmt);
- aStatement.close();
- // commit here, it is possible that
- // this thread may have got into action
- // before the backup went into wait state.
- conn.commit();
- } catch (SQLException sqle) {
- org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(System.out, sqle);
- sqle.printStackTrace(System.out);
- }
- aStatement = null;
- }
- }
-
-}
+/*
+
+ Derby - Class org.apache.derbyTesting.functionTests.store.OnlineBackupTest3
+
+ 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 java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import org.apache.derby.tools.ij;
+import org.apache.derbyTesting.functionTests.util.TestUtil;
+import java.util.Properties;
+
+/*
+ * This class tests online backup when jar actions
+ * are running in parallel to the backup thread.
+ *
+ * @author <a href="mailto:suresh.thalamati@gmail.com">Suresh Thalamati</a>
+ * @version 1.0
+ */
+
+public class OnlineBackupTest3 {
+
+ private static final String TEST_DATABASE_NAME = "wombat" ;
+ private static final String BACKUP_PATH = "extinout/onlinebackuptest3";
+
+ public static void main(String[] argv) throws Throwable {
+
+ OnlineBackupTest3 test = new OnlineBackupTest3();
+ ij.getPropertyArg(argv);
+
+ try {
+ test.runTest();
+ }
+ catch (SQLException sqle) {
+ dumpSQLException(sqle);
+ }
+ }
+
+
+ /*
+ * Test online backup with unlogged jar operations running in parallel.
+ */
+ private void runTest() throws Exception{
+ logMessage("Begin Online Backup Test3");
+ Connection conn = ij.startJBMS();
+ conn.setAutoCommit(false);
+ Statement stmt = conn.createStatement();
+ stmt.execute("create table t1(a int ) ");
+ stmt.execute("insert into t1 values(1)");
+ stmt.execute("insert into t1 values(2)");
+ stmt.execute("create table customer(id int , name varchar(100))");
+ stmt.execute("insert into customer values(1, 'ABC')");
+ stmt.execute("insert into customer values(2, 'XYZ')");
+ String crproc = "create procedure addCustomer(id INT, name VARCHAR(100)) " +
+ "MODIFIES SQL DATA " +
+ "external name " +
+ "'org.apache.derbyTesting.backupRestore.Customer.addCustomer' " +
+ " language java parameter style java ";
+
+ stmt.execute(crproc);
+
+ String dvfunc = "create function dv(P1 INT) RETURNS INT NO SQL " +
+ " external name 'dbytesting.CodeInAJar.doubleMe' " +
+ " language java parameter style java " ;
+
+ stmt.execute(dvfunc) ;
+ conn.commit();
+
+ logMessage("Initial Setup Complete");
+
+ // perform install jar operation with
+ // online backup running in parallel.
+ installJarTest();
+
+ // perform remove jar operation with
+ // online backup running in parallel.
+ removeJarTest();
+
+ logMessage("End Online Backup Test3");
+ }
+
+
+ /**
+ * Shutdown the datbase
+ * @param dbName Name of the database to shutdown.
+ */
+ void shutdown(String dbName) {
+
+ try{
+ //shutdown
+ if(TestUtil.HAVE_DRIVER_CLASS)
+ DriverManager.getConnection("jdbc:derby:" + dbName + ";shutdown=true");
+ else
+ TestUtil.shutdownUsingDataSource(dbName);
+ }catch(SQLException se){
+ if (se.getSQLState() != null && se.getSQLState().equals("08006"))
+ System.out.println("database shutdown properly");
+ else
+ dumpSQLException(se);
+ }
+ }
+
+ /*
+ * get connection to the test database
+ */
+ Connection getConnection() throws SQLException
+ {
+ Connection conn;
+ if(TestUtil.HAVE_DRIVER_CLASS)
+ conn = DriverManager.getConnection("jdbc:derby:" + TEST_DATABASE_NAME );
+ else {
+ Properties prop = new Properties();
+ prop.setProperty("databaseName", TEST_DATABASE_NAME);
+ conn = TestUtil.getDataSourceConnection(prop);
+ }
+ return conn;
+ }
+
+
+ /**
+ * Write message to the standard output.
+ */
+ void logMessage(String str){
+ System.out.println(str);
+ }
+
+ /**
+ * dump the SQLException to the standard output.
+ */
+ static private void dumpSQLException(SQLException sqle) {
+
+ org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(System.out, sqle);
+ sqle.printStackTrace(System.out);
+ }
+
+
+ private int countRows(Connection conn,
+ String tableName)
+ throws SQLException
+ {
+ Statement s = conn.createStatement();
+ ResultSet rs = s.executeQuery("SELECT count(*) from " + tableName );
+ rs.next();
+ int noRows = rs.getInt(1);
+ rs.close();
+ s.close();
+ return noRows;
+ }
+
+ /*
+ * Test install jar running in parallel to backup and vice versa.
+ */
+ void installJarTest() throws Exception{
+ logMessage("Begin Install Jar Test");
+ Connection conn1 = getConnection();
+ conn1.setAutoCommit(false);
+ Statement conn1_stmt = conn1.createStatement();
+ Connection conn2 = getConnection();
+ conn2.setAutoCommit(false);
+ Statement conn2_stmt = conn2.createStatement();
+
+
+ conn1_stmt.execute(
+ "call sqlj.install_jar('extin/brtestjar.jar', 'math_routines', 0)");
+
+ try {
+ // followng backup call should fail because jar operation is pending
+ conn2_stmt.execute(
+ "call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_NOWAIT('extinout/mybackup')");
+ } catch (SQLException sqle) {
+ //above statement should have failed.
+ org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(System.out, sqle);
+ }
+
+ // invoke backup in another thread, it should block for the above install jar
+ // operation to install 'brtestjar.jar to commit.
+
+ // start a thread to perform online backup
+ OnlineBackup backup = new OnlineBackup(TEST_DATABASE_NAME, BACKUP_PATH);
+ Thread backupThread = new Thread(backup, "BACKUP1");
+ backupThread.start();
+ // wait for the backup to start
+ backup.waitForBackupToBegin();
+ logMessage("Backup-1 Started");
+
+ // sleep for few seconds just to make sure backup thread has actually
+ // gone into a wait state for unlogged actions to commit.
+ java.lang.Thread.sleep(1000);
+
+ // backup should not even start doing real work before the
+ // unlogged transaction is commited
+ if(!backup.isRunning())
+ logMessage("Backup is not waiting for unlogged " +
+ "install jar action to commit");
+
+ //insert some rows that should appear in the backup.
+ conn1_stmt.execute("insert into t1 values(3)");
+ conn1_stmt.execute("insert into t1 values(4)");
+ conn1_stmt.execute("insert into t1 values(5)");
+
+ // set the database class with both the jars installed above.
+ conn1_stmt.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( " +
+ "'derby.database.classpath', " +
+ "'APP.math_routines') " ) ;
+
+ //commit the transaction with jar opearation that is blocking the backup.
+ conn1.commit();
+ logMessage("The transaction that was blocking the backup has ended");
+
+ // wait for backup to finish.
+ backup.waitForBackupToEnd();
+ backupThread.join();
+ logMessage("Backup-1 Completed");
+
+ // Case : jar op should block if backup is in progress
+ // add a index that will block the backup until it is committted.
+ conn1_stmt.execute("create index idx1 on customer(id)");
+ conn1_stmt.execute("insert into t1 values(6)");
+
+ // start a thread to perform online backup
+ backup = new OnlineBackup(TEST_DATABASE_NAME, BACKUP_PATH);
+ backupThread = new Thread(backup, "BACKUP2");
+ backupThread.start();
+ // wait for the backup to start
+ backup.waitForBackupToBegin();
+ logMessage("Backup-2 Started");
+
+ // sleep for few seconds just to make sure backup thread is actually
+ // gone to a wait state for unlogged actions to commit.
+ java.lang.Thread.sleep(1000);
+
+ // backup should not even start doing real work before the
+ // unlogged transaction is commited
+ if(!backup.isRunning())
+ logMessage("Backup is not waiting for unlogged " +
+ "index action to commit");
+
+
+ // add another jar file , this one should block and
+ // should not get into the backup. Backup does not allow new
+ // jar operation if it is already waiting for backup blocking
+ // to complete(commit/rollback).
+
+ AsyncStatementThread asyncJarActionThread =
+ new AsyncStatementThread(conn2,
+ "call sqlj.install_jar('extin/obtest_customer.jar', 'customer_app', 0)");
+ asyncJarActionThread.start();
+ logMessage("Started obtest_customer.jar addition in seperate thread");
+
+ //sleep for few seconds to give a chance for the
+ //jar addition thread to get into action.
+ java.lang.Thread.sleep(1000);
+
+ //roll back the index op. Backup should proceed now.
+ conn1.rollback();
+ logMessage("The transaction that was blocking the backup has ended");
+
+ // wait for backup to finish.
+ backup.waitForBackupToEnd();
+ backupThread.join();
+ logMessage("Backup-2 Completed");
+
+ // wait for customer app jar installation to finish now.
+ asyncJarActionThread.join();
+ logMessage("obtest_customer.jar addition is complete");
+
+ // set the database class with both the jars installed above.
+ conn1_stmt.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( " +
+ "'derby.database.classpath', " +
+ "'APP.customer_app:APP.math_routines') " ) ;
+
+ conn1.commit();
+
+ // second jar must have got installed after the backup.
+ // call a function in the custome_app jar
+ conn1_stmt.execute("call addCustomer(3 , 'John')");
+ conn1.commit();
+
+ logMessage("No of rows in table t1: " + countRows(conn1, "T1"));
+ logMessage("No of rows in table customer: " +
+ countRows(conn1, "customer"));
+ conn1.commit();
+ conn2.commit();
+ conn1_stmt.close();
+ conn2_stmt.close();
+ conn1.close();
+ conn2.close();
+
+ //shutdown the test db
+ shutdown(TEST_DATABASE_NAME);
+ // restore the database from the backup and run some checks
+ backup.restoreFromBackup();
+ logMessage("Restored From the Backup");
+ Connection conn = getConnection();
+ Statement stmt = conn.createStatement();
+ logMessage("No of rows in table t1: " + countRows(conn, "T1"));
+ logMessage("No of rows in table customer: " +
+ countRows(conn, "customer"));
+ // execute select statement using the "dv" funciont.
+ stmt.execute("select dv(a) from t1");
+
+
+ try {
+ // set the database class with both the jars installed above.
+ stmt.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( " +
+ "'derby.database.classpath', " +
+ "'APP.customer_app:APP.math_routines') " ) ;
+ stmt.execute("call addCustomer(3 , 'John')");
+ }catch(SQLException se) {
+ //ignore for now. No sure way to
+ //check that jar did not get into backup
+ //without debug flags.
+ }
+
+ stmt.close();
+ conn.close();
+
+ //shutdown the test db
+ shutdown(TEST_DATABASE_NAME);
+ logMessage("End Of Install Jar Test.");
+
+ }
+
+
+ /*
+ * Test remove jar running in parallel to backup and vice versa.
+ */
+ void removeJarTest() throws Exception{
+ logMessage("Begin Remove Jar Test");
+ Connection conn1 = getConnection();
+ conn1.setAutoCommit(false);
+ Statement conn1_stmt = conn1.createStatement();
+ Connection conn2 = getConnection();
+ conn2.setAutoCommit(false);
+ Statement conn2_stmt = conn2.createStatement();
+ try {
+ conn1_stmt.execute(
+ "call sqlj.install_jar('extin/obtest_customer.jar', 'customer_app', 0)");
+ }catch(SQLException se) {
+ //it is ok if was jar already there.
+ }
+
+ // remove both the jars from the class path ,
+ // so that we can remove them from the database.
+ conn1_stmt.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( " +
+ "'derby.database.classpath', '')") ;
+ conn1.commit();
+
+ conn1_stmt.execute(
+ "call sqlj.remove_jar('APP.math_routines', 0)");
+
+ // Case 0: backup call that is not waiting for unlogged
+ // opereation to complete should fail when a remove jar
+ // is not ended when backup started.
+
+ try {
+ // followng backup call should fail because remove
+ // jar operation is pending
+ conn2_stmt.execute(
+ "call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_NOWAIT('extinout/mybackup')");
+ } catch (SQLException sqle) {
+ //above statement should have failed.
+ org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(System.out, sqle);
+ }
+
+
+
+ // Case 1: backup should block because when a remove jar
+ // is not ended when backup started.
+
+ // invoke backup in another thread, should block for
+ // the above remove jar to commit.
+
+ // start a thread to perform online backup
+ OnlineBackup backup = new OnlineBackup(TEST_DATABASE_NAME, BACKUP_PATH);
+ Thread backupThread = new Thread(backup, "BACKUP3");
+ backupThread.start();
+ // wait for the backup to start
+ backup.waitForBackupToBegin();
+ logMessage("Backup-3 Started");
+
+ // sleep for few seconds just to make sure backup thread is actually
+ // gone to a wait state for unlogged actions to commit.
+ java.lang.Thread.sleep(1000);
+
+ // backup should not even start doing real work before the
+ // unlogged transaction is commited
+ if(!backup.isRunning())
+ logMessage("Backup is not waiting for unlogged " +
+ "remove jar action to commit");
+
+ //insert some rows that should appear in the backup.
+ conn1_stmt.execute("insert into t1 values(10)");
+ conn1_stmt.execute("insert into t1 values(11)");
+
+ //commit the transaction with jar opearation that is blocking the backup.
+ conn1.commit();
+ logMessage("The transaction that was blocking the backup has ended");
+
+ // wait for backup to finish.
+ backup.waitForBackupToEnd();
+ backupThread.join();
+
+ logMessage("Backup-3 Completed");
+
+ // Case 2: remove jar op should block if backup is in progress
+ // add a index that will block the backup until it is committted.
+ conn1_stmt.execute("create index idx1 on customer(id)");
+ conn1_stmt.execute("insert into t1 values(12)");
+
+ // start a thread to perform online backup
+ backup = new OnlineBackup(TEST_DATABASE_NAME, BACKUP_PATH);
+ backupThread = new Thread(backup, "BACKUP4");
+ backupThread.start();
+ // wait for the backup to start
+ backup.waitForBackupToBegin();
+ logMessage("Backup-4 Started");
+
+ // sleep for few seconds just to make sure backup thread is actually
+ // gone to a wait state for unlogged actions to commit.
+ java.lang.Thread.sleep(1000);
+
+ // backup should not even start doing real work before the
+ // unlogged transaction is commited
+ if(!backup.isRunning())
+ logMessage("Backup is not waiting for unlogged " +
+ "index action to commit");
+
+
+ // remove another jar file , this one should block and
+ // should not get into the backup. Backup does not allow new
+ // jar operation if it is already waiting for backup blocking
+ // to complete(commit/rollback).
+
+ AsyncStatementThread asyncJarActionThread =
+ new AsyncStatementThread(conn2,
+ "call sqlj.remove_jar('APP.customer_app', 0)");
+ asyncJarActionThread.start();
+ logMessage("Started obtest_customer.jar remove in seperate thread");
+
+ //sleep for few seconds to give a chance for the
+ //jar addition thread to get into action.
+ java.lang.Thread.sleep(1000);
+
+ //roll back the index op. Backup should proceed now.
+ conn1.rollback();
+ logMessage("The transaction that was blocking the backup has ended");
+ // wait for backup to finish.
+ backup.waitForBackupToEnd();
+ backupThread.join();
+ logMessage("Backup-4 Completed");
+
+ // wait for customer app jar removal to finish now.
+ asyncJarActionThread.join();
+ logMessage("obtest_customer.jar remove is complete");
+
+ //this insert should not apprear on restore.
+ conn1_stmt.execute("insert into t1 values(13)");
+
+ logMessage("No of rows in table t1: " + countRows(conn1, "T1"));
+ logMessage("No of rows in table customer: " +
+ countRows(conn1, "customer"));
+ conn1.commit();
+ conn2.commit();
+ conn1_stmt.close();
+ conn2_stmt.close();
+ conn1.close();
+ conn2.close();
+
+ //shutdown the test db
+ shutdown(TEST_DATABASE_NAME);
+ // restore the database from the backup and run some checks
+ backup.restoreFromBackup();
+ logMessage("Restored From the Backup");
+ Connection conn = getConnection();
+ Statement stmt = conn.createStatement();
+ logMessage("No of rows in table t1: " + countRows(conn, "T1"));
+ logMessage("No of rows in table customer: " +
+ countRows(conn, "customer"));
+
+ // check if the jar removal was successful.
+ // APP.math_routines should not be in backup.
+ try {
+ // set the database class path with the jar removed above,
+ // it should fail.
+ stmt.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY( " +
+ "'derby.database.classpath', " +
+ "'APP.math_routines') " ) ;
+ }catch (SQLException sqle) {
+ //above statement should have failed.
+ org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(System.out, sqle);
+ }
+
+
+ stmt.close();
+ conn.close();
+
+ //shutdown the test db
+ shutdown(TEST_DATABASE_NAME);
+ logMessage("End Of Remove Jar Test.");
+
+ }
+
+
+ /*
+ * Run a sql statement in a seperate thread.
+ */
+ class AsyncStatementThread extends Thread {
+ Connection conn;
+ String stmt;
+
+ AsyncStatementThread(Connection conn, String stmt) {
+ this.conn = conn;
+ this.stmt = stmt;
+ }
+
+ public void run() {
+ Statement aStatement = null;
+ try {
+ aStatement = conn.createStatement();
+ aStatement.execute(stmt);
+ aStatement.close();
+ // commit here, it is possible that
+ // this thread may have got into action
+ // before the backup went into wait state.
+ conn.commit();
+ } catch (SQLException sqle) {
+ org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(System.out, sqle);
+ sqle.printStackTrace(System.out);
+ }
+ aStatement = null;
+ }
+ }
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest3.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest3_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest3_app.properties?rev=385674&r1=385673&r2=385674&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest3_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest3_app.properties Mon Mar 13 14:20:10 2006
@@ -1,22 +1,22 @@
-#
-# *** DO NOT PUT PROPERTIES FOR THE DERBY SYSTEM IN THIS FILE. THEY BELONG
-# *** IN the _derby.properties file.
-#
-# It will get handed to the test on the command line in a -p <filename>
-# argument.
-#
-# This causes ij (or the GUI on ij) to load the driver and make an
-# initial connection to the database.
-#
-#
-
-#database=jdbc:derby:wombat;create=true;logDevice=extinout/br1logDir
-usedefaults=true
-useextdirs=true
-supportfiles=tests/store/brtestjar.jar,tests/store/obtest_customer.jar
-
-#Exclude for J2ME/Foundation - test uses procedure with server-side JDBC
-runwithfoundation=false
-
-# Test fails with security manager due to bug DEBRY-537
-noSecurityManager=true
+#
+# *** DO NOT PUT PROPERTIES FOR THE DERBY SYSTEM IN THIS FILE. THEY BELONG
+# *** IN the _derby.properties file.
+#
+# It will get handed to the test on the command line in a -p <filename>
+# argument.
+#
+# This causes ij (or the GUI on ij) to load the driver and make an
+# initial connection to the database.
+#
+#
+
+#database=jdbc:derby:wombat;create=true;logDevice=extinout/br1logDir
+usedefaults=true
+useextdirs=true
+supportfiles=tests/store/brtestjar.jar,tests/store/obtest_customer.jar
+
+#Exclude for J2ME/Foundation - test uses procedure with server-side JDBC
+runwithfoundation=false
+
+# Test fails with security manager due to bug DEBRY-537
+noSecurityManager=true
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest3_app.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/dropcrash.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/dropcrash.java?rev=385674&r1=385673&r2=385674&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/dropcrash.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/dropcrash.java Mon Mar 13 14:20:10 2006
@@ -1,188 +1,188 @@
-/*
-
- 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.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;
-
-
-/**
-
-The purpose of this test is to reproduce JIRA DERBY-662:
-
-Sometimes during redo the system would incorrectly remove the file associated
-with a table. The bug required the following conditions to reproduce:
-1) The OS/filesystem must be case insensitive such that a request to delete
- a file named C2080.dat would also remove c2080.dat. This is true in
- windows default file systems, not true in unix/linux filesystems that
- I am aware of.
-2) The system must be shutdown not in a clean manner, such that a subsequent
- access of the database causes a REDO recovery action of a drop table
- statement. This means that a drop table statement must have happened
- since the last checkpoint in the log file. Examples of things that cause
- checkpoints are:
- o clean shutdown from ij using the "exit" command
- o clean shutdown of database using the "shutdown=true" url
- o calling the checkpoint system procedure
- o generating enough log activity to cause a regularly scheduled checkpoint.
-3) If the conglomerate number of the above described drop table is TABLE_1,
- then for a problem to occur there must also exist in the database a table
- such that it's HEX(TABLE_2) = TABLE_1
-4) Either TABLE_2 must not be accessed during REDO prior to the REDO operation
- of the drop of TABLE_1 or there must be enough other table references during
- the REDO phase to push the caching of of the open of TABLE_2 out of cache.
-
-If all of the above conditions are met then during REDO the system will
-incorrectly delete TABLE_2 while trying to redo the drop of TABLE_1.
-<p>
-This test reproduces the problem by doing the following:
-1) create 500 tables, need enough tables to insure that conglomerate number
- 2080 (c820.dat) and 8320 (c2080.dat) exist.
-2) checkpoint the database so that create does not happen during REDO
-3) drop table with conglomerate number 2080, mapping to c820.dat. It looks
- it up in the catalog in case conglomerate number assignment changes for
- some reason.
-4) exit the database without a clean shudown, this is the default for test
- suites which run multiple tests in a single db - no clean shutdown is done.
- Since we only do a single drop since the last checkpoint, test will cause
- the drop during the subsequent REDO.
-5) run next test program dropcrash2, which will cause redo of the drop. At
- this point the bug will cause file c2080.dat to be incorrectly deleted and
- thus accesses to conglomerate 8320 will throw container does not exist
- errors.
-6) check the consistency of the database which will find the container does
- not exist error.
-
-**/
-
-public class dropcrash extends BaseTest
-{
- boolean verbose = false;
-
- public dropcrash()
- {
- }
-
- /**
- * create tables, commit, and cause checkpoint of db.
- **/
- public void drop_crash_setup(
- Connection conn,
- int num_create)
- throws SQLException
- {
- beginTest(conn, "creating " + num_create + " tables.");
- String create_stmt_str1 = "create table dropcrash_";
- String create_stmt_str2 = " (a int)";
-
- for (int i = 0; i < num_create; i++)
- {
- executeQuery(conn, create_stmt_str1 + i + create_stmt_str2, false);
- }
- conn.commit();
-
- // during redo insure that drop is the only thing redone, if there
- // are other files in the open file cache then bug will not reproduce
- // because delete on the open file will fail.
- executeQuery(
- conn, "CALL SYSCS_UTIL.SYSCS_CHECKPOINT_DATABASE()", false);
-
- endTest(conn, "creating " + num_create + " tables.");
- }
-
- /**
- * Reproduce JIRA DERBY-662
- * <p>
- * Find the conglomerate with number 2080, and drop it. The bug is
- * that during redo the system, on windows, will incorrectly delete
- * C2080.dat because it did not do the hex conversion on the conglomerate
- * number. This will result in conglomerate 8320 not having it's
- * associate data file c2080.dat.
- *
- * @exception StandardException Standard exception policy.
- **/
- public void drop_crash_drop_table(Connection conn)
- throws SQLException
- {
- beginTest(conn, "dropping table with conglomerate number 2080.");
- PreparedStatement ps =
- conn.prepareStatement(
- "select sys.systables.tablename, sys.sysconglomerates.conglomeratenumber from sys.systables, sys.sysconglomerates where sys.systables.tableid = sys.sysconglomerates.tableid and sys.systables.schemaid = sys.sysconglomerates.schemaid and sys.sysconglomerates.conglomeratenumber = ?");
- ps.setInt(1, 2080);
- ResultSet rs = ps.executeQuery();
-
- if (!rs.next())
- {
- System.out.println("ERROR, did not find conglomerate to drop");
- }
- String drop_name = rs.getString(1);
-
- // don't print table name out to test output as it could change if
- // other recovery tests are added, or system catalogs are added.
- // System.out.println("dropping table:" + drop_name + " with conglomerate number " + rs.getInt(2));
- executeQuery(conn, "drop table " + drop_name, false);
- conn.commit();
-
- // at this point it is important for this test to exit with not a
- // clean shutdown, so that the next test will force recovery redo
- // of this drop.
- endTest(conn, "dropping table with conglomerate number 2080.");
- }
-
- public void testList(Connection conn)
- throws SQLException
- {
- // create enough tables to insure congloms 2080 and 8320 exist
- drop_crash_setup(conn, 500);
- // drop 2080 and exit program so that drop will be in REDO recovery
- drop_crash_drop_table(conn);
- }
-
- public static void main(String[] argv)
- throws Throwable
- {
- dropcrash test = new dropcrash();
-
- 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);
- }
- }
-}
+/*
+
+ 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.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;
+
+
+/**
+
+The purpose of this test is to reproduce JIRA DERBY-662:
+
+Sometimes during redo the system would incorrectly remove the file associated
+with a table. The bug required the following conditions to reproduce:
+1) The OS/filesystem must be case insensitive such that a request to delete
+ a file named C2080.dat would also remove c2080.dat. This is true in
+ windows default file systems, not true in unix/linux filesystems that
+ I am aware of.
+2) The system must be shutdown not in a clean manner, such that a subsequent
+ access of the database causes a REDO recovery action of a drop table
+ statement. This means that a drop table statement must have happened
+ since the last checkpoint in the log file. Examples of things that cause
+ checkpoints are:
+ o clean shutdown from ij using the "exit" command
+ o clean shutdown of database using the "shutdown=true" url
+ o calling the checkpoint system procedure
+ o generating enough log activity to cause a regularly scheduled checkpoint.
+3) If the conglomerate number of the above described drop table is TABLE_1,
+ then for a problem to occur there must also exist in the database a table
+ such that it's HEX(TABLE_2) = TABLE_1
+4) Either TABLE_2 must not be accessed during REDO prior to the REDO operation
+ of the drop of TABLE_1 or there must be enough other table references during
+ the REDO phase to push the caching of of the open of TABLE_2 out of cache.
+
+If all of the above conditions are met then during REDO the system will
+incorrectly delete TABLE_2 while trying to redo the drop of TABLE_1.
+<p>
+This test reproduces the problem by doing the following:
+1) create 500 tables, need enough tables to insure that conglomerate number
+ 2080 (c820.dat) and 8320 (c2080.dat) exist.
+2) checkpoint the database so that create does not happen during REDO
+3) drop table with conglomerate number 2080, mapping to c820.dat. It looks
+ it up in the catalog in case conglomerate number assignment changes for
+ some reason.
+4) exit the database without a clean shudown, this is the default for test
+ suites which run multiple tests in a single db - no clean shutdown is done.
+ Since we only do a single drop since the last checkpoint, test will cause
+ the drop during the subsequent REDO.
+5) run next test program dropcrash2, which will cause redo of the drop. At
+ this point the bug will cause file c2080.dat to be incorrectly deleted and
+ thus accesses to conglomerate 8320 will throw container does not exist
+ errors.
+6) check the consistency of the database which will find the container does
+ not exist error.
+
+**/
+
+public class dropcrash extends BaseTest
+{
+ boolean verbose = false;
+
+ public dropcrash()
+ {
+ }
+
+ /**
+ * create tables, commit, and cause checkpoint of db.
+ **/
+ public void drop_crash_setup(
+ Connection conn,
+ int num_create)
+ throws SQLException
+ {
+ beginTest(conn, "creating " + num_create + " tables.");
+ String create_stmt_str1 = "create table dropcrash_";
+ String create_stmt_str2 = " (a int)";
+
+ for (int i = 0; i < num_create; i++)
+ {
+ executeQuery(conn, create_stmt_str1 + i + create_stmt_str2, false);
+ }
+ conn.commit();
+
+ // during redo insure that drop is the only thing redone, if there
+ // are other files in the open file cache then bug will not reproduce
+ // because delete on the open file will fail.
+ executeQuery(
+ conn, "CALL SYSCS_UTIL.SYSCS_CHECKPOINT_DATABASE()", false);
+
+ endTest(conn, "creating " + num_create + " tables.");
+ }
+
+ /**
+ * Reproduce JIRA DERBY-662
+ * <p>
+ * Find the conglomerate with number 2080, and drop it. The bug is
+ * that during redo the system, on windows, will incorrectly delete
+ * C2080.dat because it did not do the hex conversion on the conglomerate
+ * number. This will result in conglomerate 8320 not having it's
+ * associate data file c2080.dat.
+ *
+ * @exception StandardException Standard exception policy.
+ **/
+ public void drop_crash_drop_table(Connection conn)
+ throws SQLException
+ {
+ beginTest(conn, "dropping table with conglomerate number 2080.");
+ PreparedStatement ps =
+ conn.prepareStatement(
+ "select sys.systables.tablename, sys.sysconglomerates.conglomeratenumber from sys.systables, sys.sysconglomerates where sys.systables.tableid = sys.sysconglomerates.tableid and sys.systables.schemaid = sys.sysconglomerates.schemaid and sys.sysconglomerates.conglomeratenumber = ?");
+ ps.setInt(1, 2080);
+ ResultSet rs = ps.executeQuery();
+
+ if (!rs.next())
+ {
+ System.out.println("ERROR, did not find conglomerate to drop");
+ }
+ String drop_name = rs.getString(1);
+
+ // don't print table name out to test output as it could change if
+ // other recovery tests are added, or system catalogs are added.
+ // System.out.println("dropping table:" + drop_name + " with conglomerate number " + rs.getInt(2));
+ executeQuery(conn, "drop table " + drop_name, false);
+ conn.commit();
+
+ // at this point it is important for this test to exit with not a
+ // clean shutdown, so that the next test will force recovery redo
+ // of this drop.
+ endTest(conn, "dropping table with conglomerate number 2080.");
+ }
+
+ public void testList(Connection conn)
+ throws SQLException
+ {
+ // create enough tables to insure congloms 2080 and 8320 exist
+ drop_crash_setup(conn, 500);
+ // drop 2080 and exit program so that drop will be in REDO recovery
+ drop_crash_drop_table(conn);
+ }
+
+ public static void main(String[] argv)
+ throws Throwable
+ {
+ dropcrash test = new dropcrash();
+
+ 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);
+ }
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/dropcrash.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/dropcrash2.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/dropcrash2.java?rev=385674&r1=385673&r2=385674&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/dropcrash2.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/dropcrash2.java Mon Mar 13 14:20:10 2006
@@ -1,73 +1,73 @@
-/*
-
- 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.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 dropcrash2 extends dropcrash
-{
- boolean verbose = false;
-
- public dropcrash2()
- {
- }
-
- public void testList(Connection conn)
- throws SQLException
- {
- // make sure after redo phase that all tables are consistent, without
- // bug fix one of the tables will get a container not found exception.
- beginTest(conn, "check consistency of all tables");
- checkAllConsistency(conn);
- endTest(conn, "check consistency of all tables");
- }
-
- public static void main(String[] argv)
- throws Throwable
- {
- dropcrash2 test = new dropcrash2();
-
- 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);
- }
- }
-}
+/*
+
+ 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.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 dropcrash2 extends dropcrash
+{
+ boolean verbose = false;
+
+ public dropcrash2()
+ {
+ }
+
+ public void testList(Connection conn)
+ throws SQLException
+ {
+ // make sure after redo phase that all tables are consistent, without
+ // bug fix one of the tables will get a container not found exception.
+ beginTest(conn, "check consistency of all tables");
+ checkAllConsistency(conn);
+ endTest(conn, "check consistency of all tables");
+ }
+
+ public static void main(String[] argv)
+ throws Throwable
+ {
+ dropcrash2 test = new dropcrash2();
+
+ 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);
+ }
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/dropcrash2.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest2.sql
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest2.sql?rev=385674&r1=385673&r2=385674&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest2.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest2.sql Mon Mar 13 14:20:10 2006
@@ -1,192 +1,192 @@
--- This script tests online backup functionality
--- 1) in a non-idle tranaction.
--- 2) mutiple backup calls on the same connection.
--- 3) when unlogged operations are running in parallel
--- to the backup thread.
-
-connect 'wombat' as c1 ;
-create procedure sleep(t INTEGER) dynamic result sets 0
-language java external name 'java.lang.Thread.sleep'
-parameter style java;
-
-create function fileExists(fileName varchar(128))
-returns VARCHAR(100) external name
- 'org.apache.derbyTesting.functionTests.util.FTFileUtil.fileExists'
-language java parameter style java;
-
-create function removeDirectory(fileName varchar(128))
-returns VARCHAR(100) external name
- 'org.apache.derbyTesting.functionTests.util.FTFileUtil.removeDirectory'
-language java parameter style java;
-
-
-autocommit off;
-create table t1(a int ) ;
-insert into t1 values(1) ;
-insert into t1 values(2) ;
-commit ;
--- make sure backup calls are not allowed in a transaction that
--- has executed unlogged operations before the backup calls.
-insert into t1 values(3);
-create index idx1 on t1(a);
-call SYSCS_UTIL.SYSCS_BACKUP_DATABASE('extinout/mybackup') ;
-call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_NOWAIT('extinout/mybackup') ;
-call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(
- 'extinout/mybackup', 1);
-call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE_NOWAIT(
- 'extinout/mybackup', 1);
---backup failures should not rollback/commit the transaction.
-select * from t1 ;
-insert into t1 values(4) ;
-commit;
-drop index idx1;
-commit;
---- make sure backup calls can be run one after another.
-insert into t1 values(5) ;
-call SYSCS_UTIL.SYSCS_BACKUP_DATABASE('extinout/mybackup') ;
-call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_NOWAIT('extinout/mybackup');
-call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(
- 'extinout/mybackup', 1);
-call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE_NOWAIT(
- 'extinout/mybackup', 1);
-call SYSCS_UTIL.SYSCS_DISABLE_LOG_ARCHIVE_MODE(1);
-commit;
--- make sure backup is not allowed when non-logged
--- operations are pending
-connect 'wombat' as c2 ;
-autocommit off ;
--- index creaton is a non-logged ops, backup should not run
--- until it is committed
-create index idx1 on t1(a) ;
-
-set connection c1 ;
--- following two backup calls should fail , because they are not waiting
--- for the unlogged index creation in anothere transaction to commit/rollback.
-
-call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_NOWAIT('extinout/mybackup') ;
-
-call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE_NOWAIT(
- 'extinout/mybackup', 1);
-
-set connection c2;
-rollback ;
-
--- make sure backup call waits, if wait parameter value is non-zero or
--- the procedures used from before 10.2( old backup procedures wait by
--- default for unlogged operation to finish.)
-
--- This testing is done by starting backup in a different thread and then
--- wait for few seconds and check if the backup dir is created ?
--- If backup dir is not created , the backup thread is waiting for unlogged
--- op to finih.
-
--- Note: Not a 100% foolproof approach because checking for backupdir
--- might occur before backup thread gets into action. But I think
--- test will fail atleast on some systems, if backup is not waiting
--- for unlogged ops to complete.
-
--- case1 : simple database backup with unlogged ops pending.
-set connection c2;
--- index is a non-logged operation
-create index idx1 on t1(a) ;
-
-set connection c1;
--- make sure backup does not already exists at the backup location.
-values removeDirectory('extinout/ulbackup1');
-values fileExists('extinout/ulbackup1');
-async bthread1 'call SYSCS_UTIL.SYSCS_BACKUP_DATABASE(
- ''extinout/ulbackup1'')' ;
-set connection c2;
--- sleep for a while for the backup thread to
--- really get into the wait state
-call sleep(1000);
--- make sure backup did not really proceed, backup dir should not exist
-values fileExists('extinout/ulbackup1');
-
--- rollback the unlogged op for backup to proceed.
-rollback;
-
-set connection c1;
--- wait for backup thread to finish the work.
-wait for bthread1;
--- check if backup is created.
-values fileExists('extinout/ulbackup1');
-commit;
-
--- case2: simple backup call with the default wait for ulogged ops
-set connection c2;
-create index idx1 on t1(a) ;
-
-set connection c1;
--- make sure backup does not already exists at the backup location.
-values removeDirectory('extinout/ulbackup2');
-values fileExists('extinout/ulbackup2');
-async bthread1
- 'call SYSCS_UTIL.SYSCS_BACKUP_DATABASE(''extinout/ulbackup2'')';
-set connection c2;
--- sleep for a while for the backup thread to
--- really get into the wait state
-call sleep(1000);
--- make sure backup did not really proceed, backup dir should not exist
-values fileExists('extinout/ulbackup2');
--- rollback the unlogged op for backup to proceed.
-rollback;
-
-set connection c1;
--- wait for backup thread to finish the work.
-wait for bthread1;
--- check if backup is created.
-values fileExists('extinout/ulbackup2');
-commit;
-
---- case 3: log archive backup with with unlogged ops pending.
-set connection c2;
-create index idx1 on t1(a) ;
-
-set connection c1;
---make sure backup does not already exists at the backup location.
-values removeDirectory('extinout/ulbackup3');
-values fileExists('extinout/ulbackup3');
-async bthread1
- 'call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(
- ''extinout/ulbackup3'' , 1)' ;
-set connection c2;
--- sleep for a while for the backup thread to
--- really get into the wait state
-call sleep(1000);
--- make sure backup did not really proceed, backup dir should not exist
-values fileExists('extinout/ulbackup3');
--- rollback the unlogged op for backup to proceed.
-rollback;
-set connection c1;
--- wait for backup thread to finish the work.
-wait for bthread1;
--- check if backup is created.
-values fileExists('extinout/ulbackup3');
-call SYSCS_UTIL.SYSCS_DISABLE_LOG_ARCHIVE_MODE(1);
-
--- case4 : log archive backup with the defailt wait for unlogged ops.
-set connection c2;
-create index idx1 on t1(a) ;
-
-set connection c1;
---make sure backup does not already exists at the backup location.
-values removeDirectory('extinout/ulbackup4');
-values fileExists('extinout/ulbackup4');
-async bthread1
- 'call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(
- ''extinout/ulbackup4'' , 1)' ;
-set connection c2;
--- sleep for a while for the backup thread to
--- really get into the wait state
-call sleep(1000);
--- make sure backup did not really proceed, backup dir should not exist
-values fileExists('extinout/ulbackup4');
--- commit the unlogged op for backup to proceed.
-commit;
-set connection c1;
--- wait for backup thread to finish the work.
-wait for bthread1;
--- check if backup is created.
-values fileExists('extinout/ulbackup4');
-call SYSCS_UTIL.SYSCS_DISABLE_LOG_ARCHIVE_MODE(1);
+-- This script tests online backup functionality
+-- 1) in a non-idle tranaction.
+-- 2) mutiple backup calls on the same connection.
+-- 3) when unlogged operations are running in parallel
+-- to the backup thread.
+
+connect 'wombat' as c1 ;
+create procedure sleep(t INTEGER) dynamic result sets 0
+language java external name 'java.lang.Thread.sleep'
+parameter style java;
+
+create function fileExists(fileName varchar(128))
+returns VARCHAR(100) external name
+ 'org.apache.derbyTesting.functionTests.util.FTFileUtil.fileExists'
+language java parameter style java;
+
+create function removeDirectory(fileName varchar(128))
+returns VARCHAR(100) external name
+ 'org.apache.derbyTesting.functionTests.util.FTFileUtil.removeDirectory'
+language java parameter style java;
+
+
+autocommit off;
+create table t1(a int ) ;
+insert into t1 values(1) ;
+insert into t1 values(2) ;
+commit ;
+-- make sure backup calls are not allowed in a transaction that
+-- has executed unlogged operations before the backup calls.
+insert into t1 values(3);
+create index idx1 on t1(a);
+call SYSCS_UTIL.SYSCS_BACKUP_DATABASE('extinout/mybackup') ;
+call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_NOWAIT('extinout/mybackup') ;
+call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(
+ 'extinout/mybackup', 1);
+call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE_NOWAIT(
+ 'extinout/mybackup', 1);
+--backup failures should not rollback/commit the transaction.
+select * from t1 ;
+insert into t1 values(4) ;
+commit;
+drop index idx1;
+commit;
+--- make sure backup calls can be run one after another.
+insert into t1 values(5) ;
+call SYSCS_UTIL.SYSCS_BACKUP_DATABASE('extinout/mybackup') ;
+call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_NOWAIT('extinout/mybackup');
+call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(
+ 'extinout/mybackup', 1);
+call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE_NOWAIT(
+ 'extinout/mybackup', 1);
+call SYSCS_UTIL.SYSCS_DISABLE_LOG_ARCHIVE_MODE(1);
+commit;
+-- make sure backup is not allowed when non-logged
+-- operations are pending
+connect 'wombat' as c2 ;
+autocommit off ;
+-- index creaton is a non-logged ops, backup should not run
+-- until it is committed
+create index idx1 on t1(a) ;
+
+set connection c1 ;
+-- following two backup calls should fail , because they are not waiting
+-- for the unlogged index creation in anothere transaction to commit/rollback.
+
+call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_NOWAIT('extinout/mybackup') ;
+
+call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE_NOWAIT(
+ 'extinout/mybackup', 1);
+
+set connection c2;
+rollback ;
+
+-- make sure backup call waits, if wait parameter value is non-zero or
+-- the procedures used from before 10.2( old backup procedures wait by
+-- default for unlogged operation to finish.)
+
+-- This testing is done by starting backup in a different thread and then
+-- wait for few seconds and check if the backup dir is created ?
+-- If backup dir is not created , the backup thread is waiting for unlogged
+-- op to finih.
+
+-- Note: Not a 100% foolproof approach because checking for backupdir
+-- might occur before backup thread gets into action. But I think
+-- test will fail atleast on some systems, if backup is not waiting
+-- for unlogged ops to complete.
+
+-- case1 : simple database backup with unlogged ops pending.
+set connection c2;
+-- index is a non-logged operation
+create index idx1 on t1(a) ;
+
+set connection c1;
+-- make sure backup does not already exists at the backup location.
+values removeDirectory('extinout/ulbackup1');
+values fileExists('extinout/ulbackup1');
+async bthread1 'call SYSCS_UTIL.SYSCS_BACKUP_DATABASE(
+ ''extinout/ulbackup1'')' ;
+set connection c2;
+-- sleep for a while for the backup thread to
+-- really get into the wait state
+call sleep(1000);
+-- make sure backup did not really proceed, backup dir should not exist
+values fileExists('extinout/ulbackup1');
+
+-- rollback the unlogged op for backup to proceed.
+rollback;
+
+set connection c1;
+-- wait for backup thread to finish the work.
+wait for bthread1;
+-- check if backup is created.
+values fileExists('extinout/ulbackup1');
+commit;
+
+-- case2: simple backup call with the default wait for ulogged ops
+set connection c2;
+create index idx1 on t1(a) ;
+
+set connection c1;
+-- make sure backup does not already exists at the backup location.
+values removeDirectory('extinout/ulbackup2');
+values fileExists('extinout/ulbackup2');
+async bthread1
+ 'call SYSCS_UTIL.SYSCS_BACKUP_DATABASE(''extinout/ulbackup2'')';
+set connection c2;
+-- sleep for a while for the backup thread to
+-- really get into the wait state
+call sleep(1000);
+-- make sure backup did not really proceed, backup dir should not exist
+values fileExists('extinout/ulbackup2');
+-- rollback the unlogged op for backup to proceed.
+rollback;
+
+set connection c1;
+-- wait for backup thread to finish the work.
+wait for bthread1;
+-- check if backup is created.
+values fileExists('extinout/ulbackup2');
+commit;
+
+--- case 3: log archive backup with with unlogged ops pending.
+set connection c2;
+create index idx1 on t1(a) ;
+
+set connection c1;
+--make sure backup does not already exists at the backup location.
+values removeDirectory('extinout/ulbackup3');
+values fileExists('extinout/ulbackup3');
+async bthread1
+ 'call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(
+ ''extinout/ulbackup3'' , 1)' ;
+set connection c2;
+-- sleep for a while for the backup thread to
+-- really get into the wait state
+call sleep(1000);
+-- make sure backup did not really proceed, backup dir should not exist
+values fileExists('extinout/ulbackup3');
+-- rollback the unlogged op for backup to proceed.
+rollback;
+set connection c1;
+-- wait for backup thread to finish the work.
+wait for bthread1;
+-- check if backup is created.
+values fileExists('extinout/ulbackup3');
+call SYSCS_UTIL.SYSCS_DISABLE_LOG_ARCHIVE_MODE(1);
+
+-- case4 : log archive backup with the defailt wait for unlogged ops.
+set connection c2;
+create index idx1 on t1(a) ;
+
+set connection c1;
+--make sure backup does not already exists at the backup location.
+values removeDirectory('extinout/ulbackup4');
+values fileExists('extinout/ulbackup4');
+async bthread1
+ 'call SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(
+ ''extinout/ulbackup4'' , 1)' ;
+set connection c2;
+-- sleep for a while for the backup thread to
+-- really get into the wait state
+call sleep(1000);
+-- make sure backup did not really proceed, backup dir should not exist
+values fileExists('extinout/ulbackup4');
+-- commit the unlogged op for backup to proceed.
+commit;
+set connection c1;
+-- wait for backup thread to finish the work.
+wait for bthread1;
+-- check if backup is created.
+values fileExists('extinout/ulbackup4');
+call SYSCS_UTIL.SYSCS_DISABLE_LOG_ARCHIVE_MODE(1);
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest2.sql
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest2_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest2_app.properties?rev=385674&r1=385673&r2=385674&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest2_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest2_app.properties Mon Mar 13 14:20:10 2006
@@ -1,2 +1,2 @@
-usedefaults=true
-useextdirs=true
+usedefaults=true
+useextdirs=true
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest2_app.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest4.sql
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest4.sql?rev=385674&r1=385673&r2=385674&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest4.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest4.sql Mon Mar 13 14:20:10 2006
@@ -1,54 +1,54 @@
--- This script tests online backup functionality and restore.
-connect 'wombat' as c1 ;
-connect 'wombat' as c2;
-
-set connection c1;
-autocommit off;
--- check backup/restore work with in place compress operation.
-create table ctest(id int primary key, name char(200)) ;
-insert into ctest values(1, 'derby backup/compress test') ;
-insert into ctest values(2, 'derby backup/compress test') ;
-insert into ctest select id+2, name from ctest;
-insert into ctest select id+4, name from ctest;
-insert into ctest select id+8, name from ctest;
-insert into ctest select id+16, name from ctest;
-insert into ctest select id+32, name from ctest;
-insert into ctest select id+64, name from ctest;
-insert into ctest select id+128, name from ctest;
-insert into ctest select id+256, name from ctest;
-
-commit ;
-delete from ctest where id > 2 and id < 509 and id != 300;
-select * from ctest;
-commit;
-
---start backup in a seperare thread.
-set connection c2;
-async bthread
- 'call SYSCS_UTIL.SYSCS_BACKUP_DATABASE(''extinout/mybackup'')';
-
--- start compress in seperate thread.
-set connection c1;
-async cthread
- 'call SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE(''APP'' ,
- ''CTEST'' , 1, 1, 1)';
-set connection c2;
--- wait for backup thread to finish the work.
-wait for bthread;
-commit;
-disconnect;
-
-set connection c1;
--- wait for compress thread to finish the work.
-wait for cthread;
-commit;
-disconnect;
-
---shutdown the database
-connect 'wombat;shutdown=true';
-
-connect 'wombat;restoreFrom=extinout/mybackup/wombat';
-select * from ctest;
-insert into ctest values(2000, 'restore was successfil') ;
-
-
+-- This script tests online backup functionality and restore.
+connect 'wombat' as c1 ;
+connect 'wombat' as c2;
+
+set connection c1;
+autocommit off;
+-- check backup/restore work with in place compress operation.
+create table ctest(id int primary key, name char(200)) ;
+insert into ctest values(1, 'derby backup/compress test') ;
+insert into ctest values(2, 'derby backup/compress test') ;
+insert into ctest select id+2, name from ctest;
+insert into ctest select id+4, name from ctest;
+insert into ctest select id+8, name from ctest;
+insert into ctest select id+16, name from ctest;
+insert into ctest select id+32, name from ctest;
+insert into ctest select id+64, name from ctest;
+insert into ctest select id+128, name from ctest;
+insert into ctest select id+256, name from ctest;
+
+commit ;
+delete from ctest where id > 2 and id < 509 and id != 300;
+select * from ctest;
+commit;
+
+--start backup in a seperare thread.
+set connection c2;
+async bthread
+ 'call SYSCS_UTIL.SYSCS_BACKUP_DATABASE(''extinout/mybackup'')';
+
+-- start compress in seperate thread.
+set connection c1;
+async cthread
+ 'call SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE(''APP'' ,
+ ''CTEST'' , 1, 1, 1)';
+set connection c2;
+-- wait for backup thread to finish the work.
+wait for bthread;
+commit;
+disconnect;
+
+set connection c1;
+-- wait for compress thread to finish the work.
+wait for cthread;
+commit;
+disconnect;
+
+--shutdown the database
+connect 'wombat;shutdown=true';
+
+connect 'wombat;restoreFrom=extinout/mybackup/wombat';
+select * from ctest;
+insert into ctest values(2000, 'restore was successfil') ;
+
+
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest4.sql
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest4_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest4_app.properties?rev=385674&r1=385673&r2=385674&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest4_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest4_app.properties Mon Mar 13 14:20:10 2006
@@ -1,2 +1,2 @@
-usedefaults=true
-useextdirs=true
+usedefaults=true
+useextdirs=true
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest4_app.properties
------------------------------------------------------------------------------
svn:eol-style = native