001: /*
002:
003: Derby - Class org.apache.derbyTesting.functionTests.store.MaxLogNumber
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to You under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derbyTesting.functionTests.tests.store;
023:
024: import java.sql.Connection;
025: import java.sql.SQLException;
026: import org.apache.derby.tools.ij;
027: import org.apache.derby.iapi.services.sanity.SanityManager;
028:
029: /*
030: * This class tests recovery logic with large log file id's and the error
031: * handling logic when Max possible log file limit is reached. MaxLogNumber.java
032: * test does the setup, so it should be run before this test.
033: * In Non debug mode, this tests just acts as a plain log recovery test.
034: *
035: * @author <a href="mailto:suresh.thalamati@gmail.com">Suresh Thalamati</a>
036: * @version 1.0
037: * @see MaxLogNumber
038: */
039:
040: public class MaxLogNumberRecovery extends MaxLogNumber {
041:
042: MaxLogNumberRecovery() {
043: super ();
044: }
045:
046: private void runTest(Connection conn) throws SQLException {
047: logMessage("Begin MaxLogNumberRecovery Test");
048: verifyData(conn, 100);
049: boolean hitMaxLogLimitError = false;
050: try {
051: insert(conn, 110, COMMIT, 11);
052: update(conn, 110, ROLLBACK, 5);
053: update(conn, 110, NOACTION, 5);
054: verifyData(conn, 210);
055: if (SanityManager.DEBUG) {
056: // do lot of inserts in debug mode ,
057: // so that actuall reach the max log file number
058: // limit
059: insert(conn, 11000, COMMIT, 5);
060: }
061: } catch (SQLException se) {
062:
063: SQLException ose = se;
064: while (se != null) {
065: if ("XSLAK".equals(se.getSQLState())) {
066: hitMaxLogLimitError = true;
067: break;
068: }
069: se = se.getNextException();
070: }
071: if (!hitMaxLogLimitError)
072: throw ose;
073: }
074:
075: if (SanityManager.DEBUG) {
076: // In the debug build mode , this test should hit the max log limit while
077: // doing above DML.
078: if (!hitMaxLogLimitError)
079: logMessage("Expected: ERROR XSLAK:"
080: + "Database has exceeded largest log file"
081: + "number 8,589,934,591.");
082: }
083:
084: logMessage("End MaxLogNumberRecovery Test");
085: }
086:
087: public static void main(String[] argv) throws Throwable {
088:
089: MaxLogNumberRecovery test = new MaxLogNumberRecovery();
090: ij.getPropertyArg(argv);
091: Connection conn = ij.startJBMS();
092: conn.setAutoCommit(false);
093:
094: try {
095: test.runTest(conn);
096: } catch (SQLException sqle) {
097: org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(
098: System.out, sqle);
099: sqle.printStackTrace(System.out);
100: }
101: }
102: }
|