Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 45474 invoked from network); 27 Apr 2005 15:42:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 27 Apr 2005 15:42:33 -0000 Received: (qmail 32093 invoked by uid 500); 27 Apr 2005 15:43:25 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 32064 invoked by uid 500); 27 Apr 2005 15:43:25 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Development" Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 32045 invoked by uid 99); 27 Apr 2005 15:43:24 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from e32.co.us.ibm.com (HELO e32.co.us.ibm.com) (32.97.110.130) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 27 Apr 2005 08:43:24 -0700 Received: from westrelay02.boulder.ibm.com (westrelay02.boulder.ibm.com [9.17.195.11]) by e32.co.us.ibm.com (8.12.10/8.12.9) with ESMTP id j3RFgRAa328716 for ; Wed, 27 Apr 2005 11:42:27 -0400 Received: from [127.0.0.1] (sig-9-48-122-247.mts.ibm.com [9.48.122.247]) by westrelay02.boulder.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id j3RFgQtZ367874 for ; Wed, 27 Apr 2005 09:42:26 -0600 Message-ID: <426FB2DD.6040508@sbcglobal.net> Date: Wed, 27 Apr 2005 08:42:21 -0700 From: Mike Matrigali User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Derby Development Subject: Re: [PATCH] upgrade fix related to checksum support for transaction log to recognize out of order log writes during recovery (Derby-96) References: <42669D4F.7000007@gmail.com> <4268394C.2090201@sbcglobal.net> <42692D1D.3030306@debrunners.com> <42694347.5040704@sbcglobal.net> <426A9E64.5060002@gmail.com> <426D5577.7030100@debrunners.com> <426E77F1.5050009@gmail.com> In-Reply-To: <426E77F1.5050009@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I committed this change with svn 164994. Suresh Thalamati wrote: > > Thanks Dan. Attached is the new patch which I hope fixes the problem. > > -suresh > > Daniel John Debrunner wrote: > >> Suresh Thalamati wrote: >> >> >> >>> Attached is the new patch with the suggested changes to make >>> softupgrade correctly with the transaction log >>> checksum feature in 10.1 Added checkVersion() method to log factory it >>> self, becuase that is where >>> the version numbers are read from from the log control file , but did >>> not export the call it to the >>> rawstore factory as it is not needed now. (This can be done easlily >>> when there is a need for upgrade >>> checks in the other store modules..) >>> >> >> >> >> + boolean checkVersion(int requiredMajorVersion, int >> requiredMinorVersion) >> + { >> + if(onDiskMajorVersion >= requiredMajorVersion && >> + onDiskMinorVersion >= requiredMinorVersion) >> + return true; >> + else >> + return false; >> + } >> >> >> >> Won't this method return the incorrect result if the on disk is 11.0 >> (major.minor) and the required version is 10.1? Ie. with this >> combination the method should return true. >> >> Dan. >> >> >> >> >> > > > ------------------------------------------------------------------------ > > Index: java/engine/org/apache/derby/impl/store/raw/log/LogAccessFile.java > =================================================================== > --- java/engine/org/apache/derby/impl/store/raw/log/LogAccessFile.java (revision 164711) > +++ java/engine/org/apache/derby/impl/store/raw/log/LogAccessFile.java (working copy) > @@ -35,6 +35,7 @@ > > import org.apache.derby.iapi.services.io.FormatIdOutputStream; > import org.apache.derby.iapi.services.io.ArrayOutputStream; > +import org.apache.derby.iapi.store.raw.RawStoreFactory; > > > /** > @@ -116,7 +117,7 @@ > private long checksumInstant = -1; > private int checksumLength; > private int checksumLogRecordSize; //checksumLength + LOG_RECORD_FIXED_OVERHEAD_SIZE > - private boolean writeChecksum = true; //gets set to false incase of a soft upgrade. > + private boolean writeChecksum; > private ChecksumOperation checksumLogOperation; > private LogRecord checksumLogRecord; > private LogToFile logFactory; > @@ -152,7 +153,14 @@ > } > > currentBuffer = (LogAccessFileBuffer) freeBuffers.removeFirst(); > - > + > + // Support for Transaction Log Checksum in Derby was added in 10.1 > + // Check to see if the Store have been upgraded to 10.1 or later before > + // writing the checksum log records. Otherwise recovery will fail > + // incase user tries to revert back to versions before 10.1 in > + // soft upgrade mode. > + writeChecksum = logFactory.checkVersion(RawStoreFactory.DERBY_STORE_MAJOR_VERSION_10, > + RawStoreFactory.DERBY_STORE_MINOR_VERSION_1); > if(writeChecksum) > { > /** > Index: java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java > =================================================================== > --- java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java (revision 164711) > +++ java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java (working copy) > @@ -3885,6 +3885,29 @@ > return logArchived; > } > > + /** > + Check to see if a database has been upgraded to the required > + level in order to use a store feature. > + @param requiredMajorVersion required database Engine major version > + @param requiredMinorVersion required database Engine minor version > + @return True if the database has been upgraded to the required level, false otherwise. > + **/ > + boolean checkVersion(int requiredMajorVersion, int requiredMinorVersion) > + { > + if(onDiskMajorVersion > requiredMajorVersion ) > + { > + return true; > + } > + else > + { > + if(onDiskMajorVersion == requiredMajorVersion && > + onDiskMinorVersion >= requiredMinorVersion) > + return true; > + } > + > + return false; > + } > + > /* > ** Sending information to the user without throwing exception. > ** There are times when unusual external or system related things happen in > Index: java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java > =================================================================== > --- java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java (revision 164711) > +++ java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java (working copy) > @@ -94,7 +94,15 @@ > > public interface RawStoreFactory extends Corruptable { > > + /** Store engine version numbers indicating the database must be upgraded to > + * or created at the current engine level > + */ > > + /** Derby Store Minor Version (1) **/ > + public static final int DERBY_STORE_MINOR_VERSION_1 = 1; > + /** Derby 10 Store Major version */ > + public static final int DERBY_STORE_MAJOR_VERSION_10 = 10; > + > /** > Default value for PAGE_SIZE_PARAMETER (4096). > */